architwin 1.8.2 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +21 -0
  2. package/lib/architwin.d.ts +61 -2
  3. package/lib/architwin.js +6563 -1
  4. package/lib/atwinui/components/toolbar/i18n.js +47 -2
  5. package/lib/atwinui/components/toolbar/index.js +9 -1
  6. package/lib/atwinui/components/toolbar/menuBar.d.ts +3 -0
  7. package/lib/atwinui/components/toolbar/menuBar.js +32 -16
  8. package/lib/atwinui/components/toolbar/objectListPane.js +1 -1
  9. package/lib/atwinui/components/toolbar/roomCreation/roomFormPane.d.ts +12 -0
  10. package/lib/atwinui/components/toolbar/roomCreation/roomFormPane.js +586 -0
  11. package/lib/atwinui/components/toolbar/roomCreation/roomLayerListPane.d.ts +33 -0
  12. package/lib/atwinui/components/toolbar/roomCreation/roomLayerListPane.js +448 -0
  13. package/lib/atwinui/components/toolbar/tagListPane.js +1 -2
  14. package/lib/atwinui/components/toolbar/themePane.js +1 -1
  15. package/lib/atwinui/events.d.ts +3 -1
  16. package/lib/atwinui/events.js +245 -5
  17. package/lib/atwinui/index.js +3 -1
  18. package/lib/convert.d.ts +1 -14
  19. package/lib/convert.js +6 -63
  20. package/lib/loaders/index.d.ts +2 -1
  21. package/lib/loaders/index.js +2 -1
  22. package/lib/loaders/polydrawerLoader.d.ts +148 -0
  23. package/lib/loaders/polydrawerLoader.js +771 -0
  24. package/lib/types.d.ts +88 -1
  25. package/lib/types.js +16 -0
  26. package/lib/utils.d.ts +2 -0
  27. package/lib/utils.js +16 -0
  28. package/lib/vertexPlacer.d.ts +18 -0
  29. package/lib/vertexPlacer.js +69 -0
  30. package/lib/zoom.d.ts +6 -1
  31. package/lib/zoom.js +10 -1
  32. package/package.json +4 -2
  33. package/static/atwinui.css +431 -2
  34. package/static/utility.css +39 -1
  35. package/lib/atwinui/components/toolbar/menu-bar.d.ts +0 -4
  36. package/lib/atwinui/components/toolbar/menu-bar.js +0 -35
  37. package/lib/atwinui/components/toolbar/sidebar-container.d.ts +0 -5
  38. package/lib/atwinui/components/toolbar/sidebar-container.js +0 -27
@@ -0,0 +1,586 @@
1
+ import i18n from '../i18n';
2
+ import { batchAddEventListenerByClassName } from "../../../events";
3
+ import { startDraw, cancelDraw } from '../../../../architwin';
4
+ import { generateUUID, extractUUID } from '../../../../utils';
5
+ import { getCurrentEditRoomData } from './roomLayerListPane';
6
+ let isDrawing = false;
7
+ let roomFormMode = "ADD" /* FORM_MODE.ADD */;
8
+ let isSaving = false;
9
+ let currentPolygonData = null;
10
+ let currentPartitionDataArray = [];
11
+ let currentEditPartitionData = null;
12
+ let currentEditRoomData = null;
13
+ export function renderRoomFormPane() {
14
+ console.info("__@ renderRoomFormPane");
15
+ const element = document.createElement('div');
16
+ element.classList.add('at_container');
17
+ element.classList.add('at_w-12');
18
+ element.classList.add('at_h-full');
19
+ element.setAttribute('id', 'at-room-form-pane');
20
+ element.setAttribute('data-cy', 'at-room-form-pane');
21
+ element.innerHTML = `
22
+ <div class="at_panel_header" id="at-room-form-title">
23
+ </div>
24
+ <form class="at_form_container at_scrollable_container at_h-min-70" id="at-room-form" data-cy="at-room-form">
25
+ <div class="at-field at_flex_row">
26
+ <label for="">${i18n.t('Name')}</label>
27
+ <input class="at_field_input at_w-full" type="text" name="room_name" id="at-room-name-input" data-cy="at-room-name-input" placeholder="Room 1">
28
+ </div>
29
+ <div class="at-field at_flex_column">
30
+ <label for="">${i18n.t('Memo')}</label>
31
+ <textarea name="memo" id="at-room-memo-input" data-cy="at-room-memo-input" class="at_textarea"></textarea>
32
+ </div>
33
+ <div class="at-field at_flex_row" id="at-room-wall-height" data-cy="at-room-wall-height">
34
+ <label for="">
35
+ ${i18n.t('WallHeight')}
36
+ <span class="mdi mdi-help-circle-outline"></span>
37
+ <div class="at_icon_tooltip" data-cy="at-tooltip-room-wall-height">Sample Explanation on the definition of wall height</div>
38
+ </label>
39
+ <input class="at_field_input at_w-full" type="number" name="wall_height" id="at-room-wall-height-input" data-cy="at-room-wall-height-input" value="3">
40
+ </div>
41
+ <div class="at-field at_flex_row" id="at-room-floor-level" data-cy="at-room-floor-level">
42
+ <label for="">
43
+ ${i18n.t('FloorLevel')}
44
+ <span class="mdi mdi-help-circle-outline"></span>
45
+ <div class="at_icon_tooltip" data-cy="at-tooltip-room-floor-level">Sample Explanation on the definition of wall height</div>
46
+ </label>
47
+ <input class="at_field_input at_w-full" type="number" name="floor_level" id="at-room-floor-level-input" data-cy="at-room-floor-level-input" value="0">
48
+ </div>
49
+ <div class="at_button at_draw_partition_btn at_w-full" id="at-draw-partition-form-btn" data-cy="at-draw-partition-form-btn">
50
+ ${i18n.t('DrawPartition')}
51
+ <span class="mdi mdi-cube-outline"></span>
52
+ </div>
53
+ <div class="at_partition_list_container at_h-min-40" id="at-partition-list-container" data-cy="at-partition-list-container">
54
+ <div class="at_face_title" id="at-face-title" style="display: none;">
55
+ <span class="mdi mdi-chevron-left" id="at-back-partition"></span>
56
+ <label for="">
57
+ <span class="mdi mdi-vector-polygon"></span>
58
+ ${i18n.t('FloorsAndWalls')}
59
+ </label>
60
+ <div> </div>
61
+ </div>
62
+
63
+ <div class="at_partition_title" id="at-partition-title">
64
+ <div> </div>
65
+ <label for="">
66
+ <span class="mdi mdi-cube-unfolded"></span>
67
+ ${i18n.t('Partitions')}
68
+ </label>
69
+ <div> </div>
70
+ </div>
71
+ <div class="at_edit_name_input" id="at-edit-partition-name">
72
+ <input class="at_edit_partition_name_input" type="text" name="edit_partition_name" id="at-edit-partition-name-input" data-cy="at-edit-partition-name-input">
73
+ <span class="mdi mdi-check" id="at-confirm-edit-partition-name"></span>
74
+ </div>
75
+
76
+ <!-- Partition Add Mode -->
77
+
78
+ <div class="at_partition_item_container at_scrollable_container" id="at-partition-item-container" data-cy="at-partition-item-container">
79
+
80
+ <!-- Insert Partition Items Here -->
81
+
82
+ </div>
83
+
84
+ <!-- Partition Edit Mode -->
85
+
86
+ <div class="at_face_vertex_container at_scrollable_container" id="at-face-vertex-container" data-cy="at-face-vertex-container">
87
+
88
+ <!-- Insert Face & Vertex Items Here -->
89
+
90
+ </div>
91
+
92
+ <!-- No Partition Display -->
93
+
94
+ <div class="at_empty-display" id="at-no-partition-display" data-cy="at-no-partition-display">
95
+ <label for="">
96
+ ${i18n.t('NoPartitionDisplay')}
97
+ </label>
98
+ </div>
99
+ </div>
100
+ <div class="at_button at_delete_room_btn at_w-full" id="at-delete-room-btn" data-cy="at-delete-room-btn">
101
+ ${i18n.t('DeleteRoom')}
102
+ </div>
103
+ </form>
104
+ <div class="at_button_row at_justify_between">
105
+ <div class="at_button at_ghost" id="at-cancel-room-form-btn" data-cy="at-cancel-room-form-btn" target-pane="at-room-tree-pane">
106
+ ${i18n.t('Cancel')}
107
+ <span class="mdi mdi-close-circle-outline" id="at-cancel-room-form-btn"></span>
108
+ </div>
109
+ <div class="at_button at_ghost" id="at-save-room-btn" data-cy="at-save-room-btn" target-pane="at-room-tree-pane">
110
+ ${i18n.t('Save')}
111
+ <span class="mdi mdi-content-save" id="at-save-room-btn"></span>
112
+ </div>
113
+ </div>
114
+ `;
115
+ return element;
116
+ }
117
+ export function toggleDrawPartionButton() {
118
+ console.log("__@ toggleDrawRoomButton()");
119
+ if (!isDrawing) {
120
+ startDrawing();
121
+ }
122
+ else {
123
+ const partitionItem = document.getElementById('at-partition-item-container');
124
+ const partitionList = document.getElementById('at-partition-list-container');
125
+ const vertexList = document.getElementById('at-face-vertex-container');
126
+ cancelDrawing();
127
+ setPartitionData();
128
+ if (currentPartitionDataArray.length != 0) {
129
+ partitionItem.style.display = 'flex';
130
+ vertexList.style.display = 'none';
131
+ partitionList.style.justifyContent = 'start';
132
+ renderPartitions(currentPartitionDataArray);
133
+ hideNoPartitionDisplay();
134
+ }
135
+ currentPolygonData = undefined;
136
+ }
137
+ }
138
+ export function renderRoomFormMode() {
139
+ console.log("__@ renderRoomFormMode()");
140
+ renderFormTitle();
141
+ if (roomFormMode == "EDIT" /* FORM_MODE.EDIT */) {
142
+ currentEditRoomData = getCurrentEditRoomData();
143
+ populateRoomForm(currentEditRoomData);
144
+ renderDeleteButton();
145
+ }
146
+ else if (roomFormMode == "ADD" /* FORM_MODE.ADD */) {
147
+ renderNoPartitionDisplay();
148
+ renderWallHeightInput();
149
+ }
150
+ else {
151
+ console.error("Error occured");
152
+ }
153
+ }
154
+ function populateRoomForm(room) {
155
+ console.log("populateRoomForm()", room);
156
+ const name = document.getElementById('at-room-name-input');
157
+ name.value = room.name;
158
+ const floorLevel = document.getElementById('at-room-floor-level-input');
159
+ const memo = document.getElementById('at-room-memo-input');
160
+ if (room.polygon_json != null) {
161
+ memo.value = JSON.parse(room.polygon_json).memo;
162
+ }
163
+ currentPartitionDataArray = room.children;
164
+ if (currentPartitionDataArray.length != 0) {
165
+ floorLevel.value = JSON.parse(room.children[0].polygon_json).floor.floor_level;
166
+ renderPartitions(currentPartitionDataArray);
167
+ hideNoPartitionDisplay();
168
+ }
169
+ else {
170
+ renderNoPartitionDisplay();
171
+ }
172
+ }
173
+ function renderFormTitle() {
174
+ const title = document.getElementById('at-room-form-title');
175
+ title.innerHTML = '';
176
+ const span = document.createElement('span');
177
+ span.textContent = roomFormMode === 'ADD'
178
+ ? i18n.t('AddRoom')
179
+ : i18n.t('EditRoom');
180
+ title.appendChild(span);
181
+ }
182
+ function renderNoPartitionDisplay() {
183
+ const displayDiv = document.getElementById('at-no-partition-display');
184
+ displayDiv.style.display = "flex";
185
+ }
186
+ function hideNoPartitionDisplay() {
187
+ const displayDiv = document.getElementById('at-no-partition-display');
188
+ displayDiv.style.display = "none";
189
+ }
190
+ function renderWallHeightInput() {
191
+ const wallHeight = document.getElementById('at-room-wall-height');
192
+ wallHeight.style.display = "block";
193
+ }
194
+ function renderDeleteButton() {
195
+ const deleteBtn = document.getElementById('at-delete-room-btn');
196
+ deleteBtn.style.display = 'block';
197
+ }
198
+ function renderPartitions(partitions) {
199
+ console.log("renderPartitions()", partitions);
200
+ const partitionContainer = document.getElementById('at-partition-item-container');
201
+ partitionContainer.style.display = 'flex';
202
+ partitionContainer.innerHTML = ``;
203
+ partitions.forEach((partition, index) => {
204
+ const row = renderPartitionRow(partition, index);
205
+ partitionContainer.appendChild(row);
206
+ });
207
+ batchAddEventListenerByClassName('at_edit_partition_btn', (event) => {
208
+ console.log('Event', event);
209
+ const partitionTitle = document.getElementById('at-partition-title');
210
+ const faceTitle = document.getElementById('at-face-title');
211
+ const partitionLists = document.getElementById('at-partition-item-container');
212
+ const faceLists = document.getElementById('at-face-vertex-container');
213
+ const editPartitionName = document.getElementById('at-edit-partition-name');
214
+ const editPartitionNameInput = document.getElementById('at-edit-partition-name-input');
215
+ partitionTitle.style.display = 'none';
216
+ faceTitle.style.display = 'flex';
217
+ partitionLists.style.display = 'none';
218
+ faceLists.style.display = 'flex';
219
+ editPartitionName.style.display = 'flex';
220
+ const targetElement = event.target;
221
+ const partitionId = extractUUID(targetElement.id);
222
+ const partition = partitions.find(partition => partition.uuid === partitionId);
223
+ editPartitionNameInput.value = partition.name;
224
+ currentEditPartitionData = partition;
225
+ renderFaces(partition);
226
+ });
227
+ addEventListenerById('at-confirm-edit-partition-name', (event) => {
228
+ console.log('Event', event);
229
+ const editPartitionNameInput = document.getElementById('at-edit-partition-name-input');
230
+ const newPartitionName = editPartitionNameInput === null || editPartitionNameInput === void 0 ? void 0 : editPartitionNameInput.value; // Get the new name
231
+ if (newPartitionName && currentEditPartitionData) {
232
+ // Find and update the partition in the currentPartitionDataArray
233
+ const partitionIndex = currentPartitionDataArray.findIndex(partition => partition.uuid === currentEditPartitionData.uuid);
234
+ if (partitionIndex !== -1) {
235
+ currentPartitionDataArray[partitionIndex].name = newPartitionName;
236
+ }
237
+ }
238
+ else {
239
+ console.warn("Partition name is invalid or no partition is selected for editing.");
240
+ }
241
+ });
242
+ }
243
+ function renderPartitionRow(partition, index) {
244
+ console.log("renderPartitionRow()");
245
+ const element = document.createElement('div');
246
+ element.classList.add('at_partition_item');
247
+ element.innerHTML = `
248
+ <div class="at_icon_left">
249
+ <span class="mdi mdi-cube-outline"></span>
250
+ </div>
251
+ <div class="at_partition_name">
252
+ <div> </div>
253
+ <label for="">
254
+ ${i18n.t(`${partition.name}`)}
255
+ </label>
256
+ <span class="mdi mdi-pencil at_icon_right at_edit_partition_btn" id="at-edit-partition-${partition.uuid}"></span>
257
+ </div>
258
+ <div class="at_icon_right">
259
+ <span class="mdi mdi-delete-outline at_delete_partition_btn" id="at-delete-partition-${partition.uuid}"></span>
260
+ </div>
261
+ `;
262
+ return element;
263
+ }
264
+ function renderFaces(partition) {
265
+ console.log("renderFaces()", partition);
266
+ const faceVertexContainer = document.getElementById('at-face-vertex-container');
267
+ faceVertexContainer.innerHTML = '';
268
+ const element = document.createElement('div');
269
+ element.classList.add('at_face_vertex_item');
270
+ const polygonJson = JSON.parse(partition.polygon_json);
271
+ console.log("polygonJson", polygonJson);
272
+ console.log("polygonJson", polygonJson.floor);
273
+ element.appendChild(renderFloor(polygonJson.floor));
274
+ polygonJson.walls.forEach((wall, index) => {
275
+ element.appendChild(renderWalls(wall, index));
276
+ });
277
+ // Append the element to the container
278
+ faceVertexContainer.appendChild(element);
279
+ // Back button event listener
280
+ addEventListenerById('at-back-partition', goBackToPartitionList);
281
+ // Toggle face details visibility
282
+ batchAddEventListenerByClassName('at_face_name', event => {
283
+ const targetElement = event.target;
284
+ const faceId = extractUUID(targetElement.id);
285
+ const vertexItem = document.getElementById(`at-vertex-list-${faceId}`);
286
+ const isHidden = vertexItem.style.display === 'none' || vertexItem.style.display === '';
287
+ vertexItem.style.display = isHidden ? 'flex' : 'none';
288
+ // Disregard for now for edting wall and floor names
289
+ // const editNameInput = document.getElementById(`at-edit-name-${faceId}`);
290
+ // editNameInput.style.display = isHidden ? 'flex' : 'none';
291
+ const chevronIcon = document.getElementById(`at-expand-btn-${faceId}`).querySelector(isHidden ? '.mdi-chevron-down' : '.mdi-chevron-up');
292
+ chevronIcon.classList.toggle('mdi-chevron-down');
293
+ chevronIcon.classList.toggle('mdi-chevron-up');
294
+ });
295
+ // Disregard for now for editing wall and floor names
296
+ // batchAddEventListenerByClassNames(['.at_edit_name_text', '.at_confirm_edit_name'], toggleEditName);
297
+ }
298
+ function goBackToPartitionList() {
299
+ document.getElementById('at-partition-title').style.display = 'flex';
300
+ document.getElementById('at-face-title').style.display = 'none';
301
+ document.getElementById('at-partition-item-container').style.display = 'flex';
302
+ document.getElementById('at-face-vertex-container').style.display = 'none';
303
+ document.getElementById('at-edit-partition-name').style.display = 'none';
304
+ renderPartitions(currentPartitionDataArray);
305
+ currentEditPartitionData = null;
306
+ }
307
+ // Disregard for now for editing wall and floor names
308
+ function toggleEditFaceName(event) {
309
+ console.log('toggleEditName()');
310
+ const targetElement = event.target;
311
+ const faceId = targetElement.id.split("-").pop();
312
+ const editNameText = document.getElementById(`at-edit-name-text-${faceId}`);
313
+ const editNameInput = document.getElementById(`at-edit-name-input-${faceId}`);
314
+ if (editNameText) {
315
+ editNameText.style.display = editNameText.style.display === 'flex' || editNameText.style.display === '' ? 'none' : 'flex';
316
+ }
317
+ if (editNameInput) {
318
+ editNameInput.style.display = editNameText.style.display === 'none' ? 'flex' : 'none';
319
+ }
320
+ }
321
+ function renderFloor(floor) {
322
+ console.log('renderFloor()', floor);
323
+ const element = document.createElement('div');
324
+ element.innerHTML =
325
+ `
326
+ <div class="at_face_item">
327
+ <div class="at_icon_left">
328
+ <span class="mdi mdi-perspective-less"></span>
329
+ </div>
330
+ <div class="at_face_name" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}">
331
+ ${i18n.t(`${floor.name}`)}
332
+ <span class="mdi mdi-chevron-down" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}"></span>
333
+ </div>
334
+ <div class="at_icon_right">
335
+ <span class="mdi mdi-delete-outline"></span>
336
+ </div>
337
+ </div>
338
+ <div class="at_edit_name" id="at-edit-name-${floor.uuid}" data-cy="at-edit-name-${floor.uuid}">
339
+ <div class="at_edit_name_text" id="at-edit-name-text-${floor.uuid}" data-cy="at-edit-name-text-${floor.uuid}">
340
+ ${i18n.t('ClickEditName')}
341
+ <span class="mdi mdi-pencil at_icon_right" id="at-edit-name-text-${floor.uuid}"></span>
342
+ </div>
343
+ <div class="at_edit_name_input" id="at-edit-name-input-${floor.uuid}" data-cy="at-edit-name-input-${floor.uuid}">
344
+ <input class="at_edit_face_name_input" type="text" name="edit_face_name" id="at-edit-face-name-input" data-cy="at-edit-face-name-input" placeholder="Enter name here">
345
+ <span class="mdi mdi-check at_confirm_edit_name" id="at-confirm-edit-name-${floor.uuid}" data-cy="at-confirm-edit-name-${floor.uuid}"></span>
346
+ </div>
347
+ </div>
348
+ <div class="at_vertex_list" id="at-vertex-list-${floor.uuid}" data-cy="at-vertex-list-${floor.uuid}">
349
+ </div>
350
+ `;
351
+ // Get the at_vertex_list container for this floor
352
+ const vertexListContainer = element.querySelector(`#at-vertex-list-${floor.uuid}`);
353
+ // Append lines to the at_vertex_list container
354
+ floor.edges.forEach((vertex, index) => {
355
+ const row = renderLines(vertex, index + 1, 'floor');
356
+ vertexListContainer.appendChild(row); // Append to the correct container
357
+ });
358
+ return element;
359
+ }
360
+ function renderWalls(wall, index) {
361
+ console.log('renderWall()', wall);
362
+ const element = document.createElement('div');
363
+ const match = wall.name.match(/_wall-(\d+)$/);
364
+ let wallName = '';
365
+ if (match) {
366
+ console.log("HELLO");
367
+ wallName = `${i18n.t(`Wall`)} ${match[1]}`;
368
+ }
369
+ element.innerHTML =
370
+ `
371
+ <div class="at_face_item">
372
+ <div class="at_icon_left">
373
+ <span class="mdi mdi-perspective-less at_face_icon_rotate_270"></span>
374
+ </div>
375
+ <div class="at_face_name" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}">
376
+ ${wallName}
377
+ <span class="mdi mdi-chevron-down" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}"></span>
378
+ </div>
379
+ <div class="at_icon_right">
380
+ <span class=""></span>
381
+ </div>
382
+ </div>
383
+ <div class="at_edit_name" id="at-edit-name-${wall.uuid}" data-cy="at-edit-name-${wall.uuid}" >
384
+ <div class="at_edit_name_text" id="at-edit-name-text-${wall.uuid}" data-cy="at-edit-name-text-${wall.uuid}">
385
+ ${i18n.t('ClickEditName')}
386
+ <span class="mdi mdi-pencil at_icon_right" id="at-edit-name-text-${wall.uuid}"></span>
387
+ </div>
388
+ <div class="at_edit_name_input" id="at-edit-name-input-${wall.uuid}" data-cy="at-edit-name-input-${wall.uuid}">
389
+ <input class="at_edit_face_name_input" type="text" name="edit_face_name" id="at-edit-face-name-input" data-cy="at-edit-face-name-input" placeholder="Enter name here">
390
+ <span class="mdi mdi-check at_confirm_edit_name" id="at-confirm-edit-name-${wall.uuid}" data-cy="at-confirm-edit-name-${wall.uuid}"></span>
391
+ </div>
392
+ </div>
393
+ <div class="at_vertex_list" id="at-vertex-list-${wall.uuid}" data-cy="at-vertex-list-${wall.uuid}">
394
+ </div>
395
+ `;
396
+ // Get the at_vertex_list container for this floor
397
+ const vertexListContainer = element.querySelector(`#at-vertex-list-${wall.uuid}`);
398
+ // Append lines to the at_vertex_list container
399
+ wall.edges.forEach((vertex, index) => {
400
+ const row = renderLines(vertex, index + 1, 'wall');
401
+ vertexListContainer.appendChild(row); // Append to the correct container
402
+ });
403
+ return element;
404
+ }
405
+ function renderLines(vertex, index, faceType) {
406
+ const element = document.createElement('div');
407
+ element.classList.add('at_vertex_item');
408
+ element.innerHTML =
409
+ `
410
+ <div class="at_vertex_icon_left">
411
+ <span class="mdi mdi-vector-line"></span>
412
+ </div>
413
+ <div class="at_vertex_center">
414
+ <div class="at_vertex_name">
415
+ ${i18n.t('Line') + " " + index}
416
+ </div>
417
+ <div class="at_vertex_distance">
418
+ ${vertex.length + " m"}
419
+ </div>
420
+ </div>
421
+ ${faceType === 'floor' ?
422
+ `
423
+ <div class="at_vertex_icon_right">
424
+ <span class="mdi mdi-delete-outline"></span>
425
+ </div>
426
+ ` :
427
+ `
428
+ <div class="at_vertex_icon_right at_invisible">
429
+ <span class="mdi mdi-delete-outline"></span>
430
+ </div>
431
+ `}
432
+
433
+ `;
434
+ return element;
435
+ }
436
+ function addEventListenerById(id, callback) {
437
+ if (id) {
438
+ const elements = document.getElementById(id);
439
+ elements.addEventListener('click', callback);
440
+ }
441
+ }
442
+ export function clearRoomForm() {
443
+ console.log("__@ clearRoomForm()");
444
+ goBackToPartitionList();
445
+ cancelDrawing();
446
+ const wallHeight = document.getElementById('at-room-wall-height');
447
+ const deleteBtn = document.getElementById('at-delete-room-btn');
448
+ const partitionContainer = document.getElementById('at-partition-item-container');
449
+ wallHeight.style.display = 'none';
450
+ deleteBtn.style.display = 'none';
451
+ partitionContainer.style.display = 'none';
452
+ document.getElementById('at-room-form').reset();
453
+ currentPartitionDataArray = [];
454
+ currentEditRoomData = null;
455
+ currentEditPartitionData = null;
456
+ currentPolygonData = null;
457
+ }
458
+ function cancelDrawing() {
459
+ cancelDraw();
460
+ isDrawing = false;
461
+ const drawRoomBtn = document.getElementById('at-draw-partition-form-btn');
462
+ drawRoomBtn.classList.remove('at_draw_partition_btn_active');
463
+ drawRoomBtn.classList.add('at_draw_partition_btn');
464
+ drawRoomBtn.innerHTML = `
465
+ ${i18n.t('DrawPartition')}
466
+ <span class="mdi mdi-cube-outline"></span>
467
+ `;
468
+ }
469
+ function startDrawing() {
470
+ startDraw();
471
+ isDrawing = true;
472
+ const drawRoomBtn = document.getElementById('at-draw-partition-form-btn');
473
+ drawRoomBtn.classList.remove('at_draw_partition_btn');
474
+ drawRoomBtn.classList.add('at_draw_partition_btn_active');
475
+ drawRoomBtn.innerHTML = `
476
+ ${i18n.t('CompleteDrawing')}
477
+ <span class="mdi mdi-check-bold"></span>
478
+ `;
479
+ }
480
+ export function getRoomFormData() {
481
+ var _a, _b;
482
+ const name = ((_a = document.getElementById('at-room-name-input')) === null || _a === void 0 ? void 0 : _a.value) || null;
483
+ let memo = ((_b = document.getElementById('at-room-memo-input')) === null || _b === void 0 ? void 0 : _b.value) || null;
484
+ const currentUrl = window.location.href;
485
+ const spaceUUID = extractUUID(currentUrl);
486
+ let payload = {
487
+ space_uuid: spaceUUID,
488
+ name: name,
489
+ parent_uuid: null,
490
+ polygon_json: JSON.stringify({ memo: memo }),
491
+ children: null,
492
+ };
493
+ if (!memo) {
494
+ payload.polygon_json = null;
495
+ }
496
+ if (currentEditRoomData) {
497
+ payload = currentEditRoomData;
498
+ payload.name = name;
499
+ payload.polygon_json = JSON.stringify({ memo: memo }),
500
+ payload.children = null;
501
+ }
502
+ return payload;
503
+ }
504
+ export function getPartitionFormData() {
505
+ var _a;
506
+ const floorLevel = ((_a = document.getElementById('at-room-floor-level-input')) === null || _a === void 0 ? void 0 : _a.value) || null;
507
+ console.log("getPartitionFormData() currentPartitionDataArray", currentPartitionDataArray);
508
+ currentPartitionDataArray.forEach(partition => {
509
+ const polygonJson = JSON.parse(partition.polygon_json);
510
+ polygonJson.floor.floor_level = Number(floorLevel);
511
+ partition.polygon_json = JSON.stringify(polygonJson);
512
+ });
513
+ return currentPartitionDataArray;
514
+ }
515
+ // ==== SETTERS AND GETTERS ==== //
516
+ export function setPartitionSavingMode(mode) {
517
+ isSaving = mode;
518
+ }
519
+ export function getPartitionSavingMode() {
520
+ return isSaving;
521
+ }
522
+ export function setRoomFormMode(formType) {
523
+ roomFormMode = formType;
524
+ }
525
+ export function getRoomFormMode() {
526
+ return roomFormMode;
527
+ }
528
+ export function setPolygonData(payload) {
529
+ // Helper function to round numbers to 2 decimals
530
+ function roundToTwoDecimals(value) {
531
+ if (typeof value === "number") {
532
+ return Math.round(value * 100) / 100; // Round to 2 decimals
533
+ }
534
+ else if (Array.isArray(value)) {
535
+ return value.map(roundToTwoDecimals); // Recursively round each item in the array
536
+ }
537
+ else if (typeof value === "object" && value !== null) {
538
+ return Object.keys(value).reduce((acc, key) => {
539
+ acc[key] = roundToTwoDecimals(value[key]); // Recursively process each object property
540
+ return acc;
541
+ }, {});
542
+ }
543
+ return value; // Return as-is for non-numerical values
544
+ }
545
+ // Round numbers in the polygon JSON recursively
546
+ if (payload) {
547
+ payload = roundToTwoDecimals(payload);
548
+ }
549
+ // Set floor UUID and name
550
+ if (payload.floor) {
551
+ payload.floor.uuid = payload.floor.uuid || generateUUID();
552
+ payload.floor.name = `Floor`; // Always name the floor "Floor"
553
+ }
554
+ // Iterate over walls to set UUID and names like "Wall 1", "Wall 2", etc.
555
+ if (payload.walls && payload.walls.length > 0) {
556
+ payload.walls = payload.walls.map((wall, index) => {
557
+ var _a, _b, _c, _d;
558
+ return (Object.assign(Object.assign({}, roundToTwoDecimals(wall)), { name: `_wall-${index + 1}`, uuid: wall.uuid || generateUUID(), options: {
559
+ color: (_b = (_a = wall.options) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : 0xffffff,
560
+ opacity: (_d = (_c = wall.options) === null || _c === void 0 ? void 0 : _c.opacity) !== null && _d !== void 0 ? _d : 1.0 // Default opacity (fully opaque)
561
+ } }));
562
+ });
563
+ }
564
+ currentPolygonData = payload;
565
+ }
566
+ function setPartitionData() {
567
+ var _a;
568
+ const floorLevel = ((_a = document.getElementById('at-room-floor-level-input')) === null || _a === void 0 ? void 0 : _a.value) || null;
569
+ const currentUrl = window.location.href;
570
+ const spaceUUID = extractUUID(currentUrl);
571
+ if (currentPolygonData) {
572
+ let polygonData = currentPolygonData;
573
+ polygonData.floor.floor_level = Number(floorLevel);
574
+ const payload = {
575
+ uuid: generateUUID(),
576
+ space_uuid: spaceUUID,
577
+ name: `${i18n.t('Partition')} ${currentPartitionDataArray.length + 1}`,
578
+ parent_uuid: null,
579
+ polygon_json: JSON.stringify(polygonData)
580
+ };
581
+ if (currentEditRoomData) {
582
+ payload.parent_uuid = currentEditRoomData.uuid;
583
+ }
584
+ currentPartitionDataArray.push(payload);
585
+ }
586
+ }
@@ -0,0 +1,33 @@
1
+ import { RoomNode } from "../../../../types";
2
+ /**
3
+ * Renders and returns the HTML element for the room layer list pane.
4
+ * @returns {HTMLElement} The HTML element representing the room layer list pane.
5
+ */
6
+ export declare function renderRoomLayerListPane(): HTMLElement;
7
+ /**
8
+ * Renders the UI for the Room tree structure.
9
+ * @param rooms - Details of the rooms to construct the tree.
10
+ */
11
+ export declare function renderRoomTree(rooms: Array<RoomNode>): void;
12
+ /**
13
+ * Renders the UI for the specified room.
14
+ * @param room - The details of the room to be rendered.
15
+ */
16
+ export declare function renderRoom(room: RoomNode): HTMLUListElement;
17
+ /**
18
+ * Renders the partitions for a specific room.
19
+ * @param roomPartitions - The details of the room partitions to be rendered.
20
+ * @param roomId - The identifier of the room to which the partitions belong.
21
+ */
22
+ export declare function renderPartitions(roomPartitions: RoomNode[], roomId: string): void;
23
+ /**
24
+ * Renders the items within a specific partition.
25
+ * @param partitionItems - The details of the partition items to be rendered.
26
+ */
27
+ export declare function renderPartitionItems(partitionItems: any): string;
28
+ export declare function updateParentVisibility(isPartition: boolean, currentBtn: HTMLElement): void;
29
+ /**
30
+ * Retrieves the current room data being edited.
31
+ * @returns The current room node being edited.
32
+ */
33
+ export declare function getCurrentEditRoomData(): RoomNode;