Skip to content

Commit 745628b

Browse files
committed
save format in room labels
1 parent c9b53dd commit 745628b

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

server/migrations.js

+6
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ const migrations = {
519519
return true
520520
},
521521

522+
D20250214_default_square_format: async function(db) {
523+
const roomlabels = db.collection('roomlabels')
524+
await roomlabels.updateMany({ format: { $exists: false } }, { $set: { format: 'square' } })
525+
return true
526+
}
527+
522528
}
523529

524530
async function migrate(db, options) {

server/models/RoomLabel.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const RoomLabel = model('RoomLabel', new Schema({
1111
type: String,
1212
},
1313
size: Number, // la dimensione effettiva sara cm: 2^(size/2)
14+
format: String, // square, rectangle
1415
state: {
1516
type: String,
1617
enum: ['submitted', 'managed'],

src/processes/RoomLabels.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ function Display({roomLabel, onSave}) {
1313
const printRef = useRef(null)
1414
const blue = "#08467b"
1515
const [size, setSize] = useState(roomLabel?.size || 0)
16-
const [format, setFormat] = useState('square')
16+
const [format, setFormat] = useState(roomLabel?.format || 'square')
1717
const [lastId, setLastId] = useState(null)
1818

1919
if (lastId !== roomLabel._id) {
2020
setLastId(roomLabel._id)
2121
setSize(roomLabel?.size || 0)
22+
setFormat(roomLabel?.format || 'square')
2223
}
2324

2425
const dimensions = format === 'square'
@@ -216,7 +217,8 @@ export default function ManageRoomLabels() {
216217
const [roomLabel, setRoomLabel] = useState({
217218
names: ["Nome Cognome"],
218219
number: "123",
219-
fontSize: 0
220+
fontSize: 0,
221+
format: 'square'
220222
})
221223
// const patchRoomLabel = engine.usePatch('roomLabel')
222224
const [urlId, setUrlId] = useState(window.location.search.substring(1))

0 commit comments

Comments
 (0)