architwin 1.14.8 → 1.14.9

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.
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import i18n from '../i18n';
11
11
  import { SPACE_EVENTS } from "../../../../types";
12
12
  import { batchAddEventListenerByClassName } from "../../../events";
13
- import { startDraw, cancelDraw, disposeModel, _3DXObjects, getCurrentPolygon, dispatchSpaceEvent, enableVerticeControls, setCurrentPolygon, setMeshChildrenMaterialProperty, get3DXObjects, getChildrenOfModel, clearSelectedObject, renderPolygon, addUndoDrawActions, setWallBaseHeight, clearWallBaseHeight } from '../../../../architwin';
13
+ import { startDraw, cancelDraw, disposeModel, _3DXObjects, getCurrentPolygon, dispatchSpaceEvent, enableVerticeControls, setCurrentPolygon, setMeshChildrenMaterialProperty, get3DXObjects, getChildrenOfModel, clearSelectedObject, renderPolygon, addUndoDrawActions, setWallBaseHeight, clearWallBaseHeight, setDrawingConfig, resetDrawingConfig, goToPosition } from '../../../../architwin';
14
14
  import { generateUUID, extractUUID } from '../../../../utils';
15
15
  import { getCurrentEditRoomData } from './roomTreePane';
16
16
  import { toggleModal, setModalAction } from "../modal";
@@ -24,7 +24,7 @@ let currentPolygonData = null;
24
24
  let currentPartitionData = null;
25
25
  let currentPartitionDataArray = [];
26
26
  let savedPartitionDataArray = [];
27
- let currentEditPartitionData = null;
27
+ let isEditPartition = false;
28
28
  let currentDeletePartitionData = null;
29
29
  let currentEditRoomData = null;
30
30
  let notify = new Notyf({ position: { x: 'left', y: 'bottom' } });
@@ -33,6 +33,14 @@ let deletedSavedPartitionArray = [];
33
33
  let currentHighlightedFace = null;
34
34
  let previousPartitionData = null;
35
35
  let tempCurrentPolygon = undefined;
36
+ let drawingMode = null;
37
+ let drawingConfig = null;
38
+ let currentWall = null;
39
+ let currentObject = null;
40
+ let inputFloorMaterial;
41
+ let floorMaterial = '';
42
+ let inputWallMaterial;
43
+ let wallMaterial = '';
36
44
  export function renderRoomFormPane() {
37
45
  log.info("__@ renderRoomFormPane: ", roomFormMode);
38
46
  const element = document.createElement('div');
@@ -70,32 +78,52 @@ export function renderRoomFormPane() {
70
78
  </label>
71
79
  <input class="at_field_input at_w-full" type="text" name="floor_level" id="at-room-floor-level-input" data-cy="at-room-floor-level-input">
72
80
  </div>
73
- <div class="at_partition_list_container at_h-min-40" id="at-partition-list-container" data-cy="at-partition-list-container">
74
- <div class="at_face_title" id="at-face-title" style="display: none;">
75
- <span class="mdi mdi-chevron-left" id="at-back-partition"></span>
81
+ <div class="at_section at_h-min-40" id="at-partition-list-container" data-cy="at-partition-list-container">
82
+
83
+ <!-- Partition Title-->
84
+ <div class="at_title" id="at-partition-title">
85
+ <div> </div>
76
86
  <label for="">
77
- <span class="mdi mdi-vector-polygon"></span>
78
- ${i18n.t('Floor')}
87
+ <span class="mdi mdi-cube-unfolded"></span>
88
+ ${i18n.t('Partitions')}
79
89
  </label>
80
90
  <div> </div>
81
91
  </div>
82
92
 
83
- <div class="at_partition_title" id="at-partition-title">
93
+ <!-- Floor Title-->
94
+ <div class="at_title" id="at-face-title" style="display: none;">
95
+ <span class="mdi mdi-chevron-left at_back_btn" id="at-back-partition"></span>
96
+ <label for="">
97
+ <span class="mdi mdi-vector-polygon"></span>
98
+ ${i18n.t('FloorsAndWalls')}
99
+ </label>
84
100
  <div> </div>
101
+ </div>
102
+
103
+ <!-- Windows and Doors Title-->
104
+ <div class="at_title" id="at-window-door-title" style="display: none;">
105
+ <span class="mdi mdi-chevron-left at_back_btn" id="at-back-floors"></span>
85
106
  <label for="">
86
- <span class="mdi mdi-cube-unfolded"></span>
87
- ${i18n.t('Partitions')}
107
+ <span class="mdi mdi-vector-polygon"></span>
108
+ ${i18n.t('WindowsDoors')}
88
109
  </label>
89
110
  <div> </div>
90
111
  </div>
91
- <div class="at_edit_name_input" id="at-edit-partition-name">
92
- <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">
112
+
113
+ <div class="at_edit_name" id="at-edit-wall-material" style="display: none;">
114
+ <input class="at_edit_name_input" type="text" id="at-edit-wall-input" data-cy="at-edit-wall-material-input" placeholder="${i18n.t('EnterWallMaterial')}" disabled>
115
+ <span class="mdi mdi-pencil" style="display: none; cursor: pointer;" id="at-wall-edit-material-btn"></span>
116
+ <span class="mdi mdi-check" id="at-confirm-edit-wall-btn" style="display: none;"></span>
117
+ </div>
118
+
119
+ <div class="at_edit_name" id="at-edit-partition-name">
120
+ <input class="at_edit_name_input" type="text" name="edit_partition_name" id="at-edit-partition-name-input" data-cy="at-edit-partition-name-input">
93
121
  <span class="mdi mdi-check" id="at-confirm-edit-partition-name"></span>
94
122
  </div>
95
123
 
96
124
  <!-- Partition Add Mode -->
97
125
 
98
- <div class="at_partition_item_container at_scrollable_container" id="at-partition-item-container" data-cy="at-partition-item-container">
126
+ <div class="at_body at_scrollable_container" id="at-partition-item-container" data-cy="at-partition-item-container">
99
127
 
100
128
  <!-- Insert Partition Items Here -->
101
129
 
@@ -103,7 +131,7 @@ export function renderRoomFormPane() {
103
131
 
104
132
  <!-- Partition Edit Mode -->
105
133
 
106
- <div class="at_face_vertex_container at_scrollable_container" id="at-face-vertex-container" data-cy="at-face-vertex-container">
134
+ <div class="at_body at_scrollable_container" id="at-face-vertex-container" data-cy="at-face-vertex-container">
107
135
 
108
136
  <!-- Insert Face & Vertex Items Here -->
109
137
 
@@ -111,7 +139,7 @@ export function renderRoomFormPane() {
111
139
 
112
140
  <!-- No Partition Display -->
113
141
 
114
- <div class="at_empty-display" id="at-no-partition-display" data-cy="at-no-partition-display">
142
+ <div class="at_empty_display" id="at-no-partition-display" data-cy="at-no-partition-display">
115
143
  <label for="">
116
144
  ${i18n.t('NoPartitionDisplay')}
117
145
  </label>
@@ -123,9 +151,16 @@ export function renderRoomFormPane() {
123
151
  ${i18n.t('AddPartition')}
124
152
  <span class="mdi mdi-draw"></span>
125
153
  </div>
154
+
155
+ <div class="at_button at_add_window_door_btn at_draw_partition_btn_jp_font_size"
156
+ id="at-add-window-door-btn" data-cy="at-add-window-door-btn" style="display:none;">
157
+ ${i18n.t('AddWindowDoor')}
158
+ <span class="mdi mdi-window-closed-variant"></span>
159
+ </div>
160
+
126
161
  <div class="at_button at_draw_partition_btn at_w-full at_hidden" id="at-modify-partition-form-btn" data-cy="at-modify-partition-form-btn">
127
162
  ${i18n.t('ModifyPartition')}
128
- <span class="mdi mdi-cube-outline"></span>
163
+ <span class="mdi mdi-cube-outline" style="margine-left: 2px"></span>
129
164
  </div>
130
165
  <!-- Undo & Redo Buttons -->
131
166
  <div class="at_button at_undo_btn at_disabled" id="at-draw-undo-btn" data-cy="at-draw-undo-btn">
@@ -184,10 +219,51 @@ export function toggleDrawPartitionButton() {
184
219
  }
185
220
  currentPolygonData = null;
186
221
  currentPartitionData = null;
187
- currentEditPartitionData = null;
222
+ isEditPartition = false;
188
223
  previousPartitionData = null;
189
224
  }
190
225
  }
226
+ export function toggleDrawWindowButton() {
227
+ var _a;
228
+ log.info("toggleDrawWindowButton()", getCurrentPolygon());
229
+ setCurrentPolygon(undefined);
230
+ const addDoorButton = document.getElementById('at-add-window-door-btn');
231
+ if (!isDrawing) {
232
+ isDrawing = true;
233
+ drawingMode = 'window';
234
+ // clearSelectedObject()
235
+ addDoorButton.classList.remove('at_add_window_door_btn');
236
+ addDoorButton.classList.add('at_add_window_door_btn_active');
237
+ addDoorButton.innerHTML = `
238
+ ${i18n.t('DoneDrawing')}
239
+ <span class="mdi mdi-check-bold"></span>
240
+ `;
241
+ drawingConfig = {
242
+ lineTypeComponentConfig: {
243
+ renderPolygonOnAdd: false,
244
+ drawingMode: drawingMode,
245
+ targetIndex: ((_a = currentWall.windows) === null || _a === void 0 ? void 0 : _a.length) || 0,
246
+ polygonData: currentPolygonData,
247
+ targetUUID: currentWall.uuid
248
+ }
249
+ };
250
+ setDrawingConfig(drawingConfig);
251
+ startDraw();
252
+ }
253
+ else {
254
+ isDrawing = false;
255
+ drawingMode = null;
256
+ currentPartitionData.polygon_json = JSON.stringify(currentPolygonData);
257
+ addDoorButton.classList.remove('at_add_window_door_btn_active');
258
+ addDoorButton.classList.add('at_add_window_door_btn');
259
+ addDoorButton.innerHTML = `
260
+ ${i18n.t('AddWindowDoor')}
261
+ <span class="mdi mdi-window-closed-variant"></span>
262
+ `;
263
+ cancelDraw();
264
+ resetDrawingConfig();
265
+ }
266
+ }
191
267
  /**
192
268
  * Displays the partition form based on the current form mode.
193
269
  * Handles different UI behaviors for edit and add modes.
@@ -309,35 +385,7 @@ function displayPartitions(partitions) {
309
385
  // Set up event listener for the partition edit button
310
386
  batchAddEventListenerByClassName('at_edit_partition_btn', (event) => {
311
387
  console.log('Event', event);
312
- const partitionTitle = document.getElementById('at-partition-title');
313
- const faceTitle = document.getElementById('at-face-title');
314
- const partitionLists = document.getElementById('at-partition-item-container');
315
- const faceLists = document.getElementById('at-face-vertex-container');
316
- const editPartitionName = document.getElementById('at-edit-partition-name');
317
- const editPartitionNameInput = document.getElementById('at-edit-partition-name-input');
318
- // Toggle visibility of relevant elements
319
- partitionTitle.style.display = 'none';
320
- faceTitle.style.display = 'flex';
321
- partitionLists.style.display = 'none';
322
- faceLists.style.display = 'flex';
323
- editPartitionName.style.display = 'flex';
324
- // Get the partition ID and load the corresponding partition data
325
- const targetElement = event.target;
326
- const partitionId = extractUUID(targetElement.id);
327
- currentEditPartitionData = partitions.find(partition => partition.uuid === partitionId);
328
- const targetObject = _3DXObjects.find(obj => obj.object.object_data.uuid === partitionId);
329
- if (currentEditPartitionData) {
330
- displayFaces(JSON.parse(currentEditPartitionData.polygon_json));
331
- editPartitionNameInput.value = currentEditPartitionData.name;
332
- const currentPolygon = {
333
- node: targetObject.node,
334
- component: targetObject.component,
335
- object: targetObject.object,
336
- type: 'POLYGON'
337
- };
338
- setCurrentPolygon(currentPolygon);
339
- handleModifyPartition(targetObject);
340
- }
388
+ handlePartitionRowEditBtnClickEvent(partitions, event.target);
341
389
  });
342
390
  // Set up event listener for confirming partition name change
343
391
  addEventListenerById('at-confirm-edit-partition-name', () => {
@@ -345,9 +393,9 @@ function displayPartitions(partitions) {
345
393
  const newPartitionName = editPartitionNameInput === null || editPartitionNameInput === void 0 ? void 0 : editPartitionNameInput.value;
346
394
  const confirmEditPartitionName = document.getElementById('at-confirm-edit-partition-name');
347
395
  confirmEditPartitionName.style.display = 'none';
348
- if (newPartitionName && currentEditPartitionData) {
396
+ if (newPartitionName) {
349
397
  // Update the name of the partition in the array
350
- const partitionIndex = currentPartitionDataArray.findIndex(partition => partition.uuid === currentEditPartitionData.uuid);
398
+ const partitionIndex = currentPartitionDataArray.findIndex(partition => partition.uuid === currentPartitionData.uuid);
351
399
  if (partitionIndex !== -1) {
352
400
  currentPartitionDataArray[partitionIndex].name = newPartitionName;
353
401
  }
@@ -392,6 +440,51 @@ function displayPartitions(partitions) {
392
440
  }
393
441
  }));
394
442
  }
443
+ /**
444
+ * Handles the click event for partition row edit buttons. Updates the UI to show
445
+ * face editing mode, loads the selected partition data, and sets up the partition
446
+ * for modification.
447
+ *
448
+ * This function:
449
+ * - Toggles UI visibility (hides partition list, shows face list and edit controls)
450
+ * - Extracts partition ID from the clicked element
451
+ * - Loads and displays the partition's face data
452
+ * - Sets up the partition name input field
453
+ * - Initializes the partition for modification mode
454
+ *
455
+ * @param partitions - The list of partitions to search through for the selected partition
456
+ * @param event - The click event from the edit button, used to identify which partition to edit
457
+ */
458
+ export function handlePartitionRowEditBtnClickEvent(partitions, targetElement) {
459
+ isEditPartition = true;
460
+ const partitionTitle = document.getElementById('at-partition-title');
461
+ const faceTitle = document.getElementById('at-face-title');
462
+ const partitionLists = document.getElementById('at-partition-item-container');
463
+ const faceLists = document.getElementById('at-face-vertex-container');
464
+ const editPartitionName = document.getElementById('at-edit-partition-name');
465
+ const editPartitionNameInput = document.getElementById('at-edit-partition-name-input');
466
+ const editWallMaterialInput = document.getElementById('at-edit-wall-material');
467
+ // Toggle visibility of relevant elements
468
+ partitionTitle.style.display = 'none';
469
+ faceTitle.style.display = 'flex';
470
+ partitionLists.style.display = 'none';
471
+ faceLists.style.display = 'flex';
472
+ editPartitionName.style.display = 'flex';
473
+ editWallMaterialInput.style.display = 'none';
474
+ // Get the partition ID and load the corresponding partition data
475
+ const partitionId = extractUUID(targetElement.id);
476
+ currentPartitionData = partitions.find(partition => partition.uuid === partitionId);
477
+ currentObject = _3DXObjects.find(obj => obj.object.object_data.uuid === partitionId);
478
+ log.info("currentPartitionData", currentPartitionData);
479
+ log.info("polygonJson", JSON.parse(currentPartitionData.polygon_json));
480
+ log.info("targetObject", currentObject);
481
+ if (isEditPartition) {
482
+ displayFaces(JSON.parse(currentPartitionData.polygon_json));
483
+ editPartitionNameInput.value = currentPartitionData.name;
484
+ setCurrentPolygon(currentObject);
485
+ handleModifyPartition(currentObject);
486
+ }
487
+ }
395
488
  function displayFaceLists() {
396
489
  displayElement('at-face-title');
397
490
  displayElement('at-face-vertex-container');
@@ -399,9 +492,10 @@ function displayFaceLists() {
399
492
  hideElement('at-partition-item-container');
400
493
  hideElement('at-partition-title');
401
494
  hideElement('at-no-partition-display');
495
+ hideElement('at-edit-wall-material');
402
496
  }
403
497
  function handleModifyPartition(object) {
404
- const isDrawingEnabled = getDrawingMode();
498
+ const isDrawingEnabled = getIsDrawing();
405
499
  console.log("isDrawingEnabled", isDrawingEnabled);
406
500
  if (isDrawingEnabled) {
407
501
  toggleDrawPartitionButton();
@@ -425,20 +519,20 @@ function displayPartitionRow(partition) {
425
519
  console.log("displayPartitionRow()", partition);
426
520
  // Create the partition row element
427
521
  const element = document.createElement('div');
428
- element.classList.add('at_partition_item');
522
+ element.classList.add('at_item');
429
523
  // Set the inner HTML of the partition row
430
524
  element.innerHTML = `
431
- <div class="at_icon_left">
525
+ <div class="at_subitem_left">
432
526
  <span class="mdi mdi-cube-outline"></span>
433
527
  </div>
434
- <div class="at_partition_name">
528
+ <div class="at_name">
435
529
  <div></div>
436
530
  <label for="">
437
531
  ${i18n.t(`${partition.name}`)}
438
532
  </label>
439
- <span class="mdi mdi-pencil at_icon_right at_edit_partition_btn" id="at-edit-partition-${partition.uuid}"></span>
533
+ <span class="mdi mdi-pencil at_subitem_right at_edit_partition_btn" id="at-edit-partition-${partition.uuid}"></span>
440
534
  </div>
441
- <div class="at_icon_right">
535
+ <div class="at_subitem_right">
442
536
  <span class="mdi mdi-delete-outline at_delete_partition_btn" id="at-delete-partition-${partition.uuid}"></span>
443
537
  </div>
444
538
  `;
@@ -456,9 +550,6 @@ function displayFaces(polygon) {
456
550
  faceVertexContainer.innerHTML = '';
457
551
  const objectData = get3DXObjects();
458
552
  let object;
459
- if (currentEditPartitionData) {
460
- object = objectData.find(obj => obj.object.object_data.uuid === currentEditPartitionData.uuid);
461
- }
462
553
  if (currentPartitionData) {
463
554
  object = objectData.find(obj => obj.object.object_data.uuid === currentPartitionData.uuid);
464
555
  }
@@ -478,6 +569,7 @@ function displayFaces(polygon) {
478
569
  */
479
570
  // Back button event listener for displaying partition list
480
571
  addEventListenerById('at-back-partition', goBackToPartitionList);
572
+ addEventListenerById('at-back-floors', goBackToFloorWallList);
481
573
  // Toggle visibility of face details when clicked
482
574
  batchAddEventListenerByClassName('at_face_name', (event) => {
483
575
  const targetElement = event.target;
@@ -514,9 +606,6 @@ function displayFaces(polygon) {
514
606
  });
515
607
  }
516
608
  let targetObject;
517
- if (currentEditPartitionData) {
518
- targetObject = _3DXObjects.find(obj => obj.object.object_data.uuid === currentEditPartitionData.uuid);
519
- }
520
609
  if (currentPartitionData) {
521
610
  targetObject = _3DXObjects.find(obj => obj.object.object_data.uuid === currentPartitionData.uuid);
522
611
  }
@@ -558,16 +647,7 @@ function displayFaces(polygon) {
558
647
  return wall;
559
648
  });
560
649
  let payload;
561
- if (currentEditPartitionData) {
562
- payload = {
563
- uuid: currentEditPartitionData.uuid,
564
- space_uuid: currentEditPartitionData.space_uuid,
565
- name: currentEditPartitionData.name,
566
- parent_uuid: currentEditPartitionData.parent_uuid,
567
- polygon_json: currentPolygonData
568
- };
569
- }
570
- else if (currentPartitionData) {
650
+ if (currentPartitionData) {
571
651
  payload = {
572
652
  uuid: currentPartitionData.uuid,
573
653
  space_uuid: currentPartitionData.space_uuid,
@@ -576,7 +656,7 @@ function displayFaces(polygon) {
576
656
  polygon_json: currentPolygonData
577
657
  };
578
658
  }
579
- console.log("renderPolygon:", payload);
659
+ console.log("renderPolygon:", payload, getCurrentPolygon());
580
660
  // Re-render polygon
581
661
  renderPolygon(payload);
582
662
  const undoPaylaod = {
@@ -591,27 +671,387 @@ function displayFaces(polygon) {
591
671
  notify.success(`${i18n.t('SuccessWallDelete')}`);
592
672
  }));
593
673
  });
674
+ batchAddEventListenerByClassName('at_edit_wall_btn', (event) => {
675
+ const targetElement = event.target;
676
+ const wallUuid = extractUUID(targetElement.getAttribute('id'));
677
+ handlePartitionWallEditBtn(wallUuid);
678
+ });
679
+ // input detect for floor material
680
+ inputFloorMaterial = document.getElementById('at-edit-floor-material-input');
681
+ inputFloorMaterial.addEventListener('input', onModeDetectFloorInput);
682
+ // input detect for wall material
683
+ inputWallMaterial = document.getElementById('at-edit-wall-input');
684
+ inputWallMaterial.addEventListener('input', onModeDetectWallInput);
685
+ //sets floor material value and icon
686
+ const floorJSON = JSON.parse(currentPartitionData.polygon_json);
687
+ setFloorMaterial(floorJSON.floor.material);
688
+ setFloorMaterialIcon(floorJSON.floor.material);
689
+ addEventListenerById('at-confirm-edit-floor-name', (event) => __awaiter(this, void 0, void 0, function* () {
690
+ console.log('@caroline this is clicked', currentPartitionData);
691
+ const targetEvent = event.target;
692
+ const floor = polygon.floor;
693
+ const floorMaterialConfirm = document.getElementById('at-confirm-edit-floor-name');
694
+ const floorMaterialEdit = document.getElementById('at-floor-edit-material-btn');
695
+ const floorMaterialField = document.getElementById('at-edit-floor-material-input');
696
+ const partitionData = JSON.parse(currentPartitionData.polygon_json);
697
+ const currentPartition = _3DXObjects.find(obj => obj.object.object_data.uuid === currentPartitionData.uuid);
698
+ if (partitionData) {
699
+ partitionData.floor.material = floorMaterial;
700
+ currentPartitionData.polygon_json = JSON.stringify(partitionData);
701
+ }
702
+ if (currentPartition) {
703
+ currentPartition.object.object_data.json_data.floor = {
704
+ material: floorMaterial
705
+ };
706
+ currentPolygonData.floor.material = floorMaterial;
707
+ }
708
+ const findPartition = currentPartitionDataArray.find(partition => {
709
+ const parsed = JSON.parse(partition.polygon_json);
710
+ return parsed.floor.uuid == floor.uuid;
711
+ });
712
+ if (findPartition != undefined) {
713
+ const parsePartition = JSON.parse(findPartition.polygon_json);
714
+ parsePartition.floor.material = floorMaterial;
715
+ }
716
+ //rerender to display material value in space
717
+ const polyData = {
718
+ uuid: currentPartition.object.object_data.uuid,
719
+ polygon_json: partitionData
720
+ };
721
+ renderPolygon(polyData);
722
+ dispatchSpaceEvent(SPACE_EVENTS.PARTITION_EDITED, { data: currentPartitionData });
723
+ // sets icon and input field back
724
+ floorMaterialField.disabled = true;
725
+ floorMaterialEdit.style.display = "block";
726
+ floorMaterialConfirm.style.display = "none";
727
+ }));
728
+ addEventListenerById('at-floor-edit-material-btn', (event) => __awaiter(this, void 0, void 0, function* () {
729
+ const floorMaterialConfirm = document.getElementById('at-confirm-edit-floor-name');
730
+ const floorMaterialEdit = document.getElementById('at-floor-edit-material-btn');
731
+ const floorMaterialField = document.getElementById('at-edit-floor-material-input');
732
+ floorMaterialField.disabled = false;
733
+ floorMaterialEdit.style.display = "none";
734
+ floorMaterialConfirm.style.display = "block";
735
+ }));
736
+ addEventListenerById('at-confirm-edit-wall-btn', (event) => __awaiter(this, void 0, void 0, function* () {
737
+ console.log('@caroline wall check', wallMaterial, currentWall.material, currentWall);
738
+ const wallEditMaterial = document.getElementById('at-wall-edit-material-btn');
739
+ const wallConfirmMaterial = document.getElementById('at-confirm-edit-wall-btn');
740
+ const wallMaterialInput = document.getElementById('at-edit-wall-input');
741
+ const partitionData = JSON.parse(currentPartitionData.polygon_json);
742
+ const currentPartition = _3DXObjects.find(obj => obj.object.object_data.uuid === currentPartitionData.uuid);
743
+ if (partitionData) {
744
+ const wallIndex = partitionData.walls.findIndex(wall => wall.uuid == currentWall.uuid);
745
+ if (wallIndex != undefined) {
746
+ partitionData.walls[wallIndex].material = wallMaterial;
747
+ }
748
+ currentPartitionData.polygon_json = JSON.stringify(partitionData);
749
+ console.log('@caroline partition data: ', currentPartitionData);
750
+ }
751
+ currentPartitionDataArray.some(partition => {
752
+ const parsed = JSON.parse(partition.polygon_json);
753
+ parsed.walls.find(wall => {
754
+ if (wall.uuid == currentWall.uuid) {
755
+ wall.material = wallMaterial;
756
+ }
757
+ });
758
+ });
759
+ console.log('[wall] currentPartition: ', currentPartition);
760
+ if (currentPartition) {
761
+ const wall = currentPartition.object.object_data.json_data.walls.find(wall => wall.uuid == currentWall.uuid);
762
+ wall.material = wallMaterial;
763
+ }
764
+ currentWall.material = wallMaterial;
765
+ //rerender to display material value in space
766
+ const polyData = {
767
+ uuid: currentPartition.object.object_data.uuid,
768
+ polygon_json: partitionData
769
+ };
770
+ // renderPolygon(polyData)
771
+ console.log('[wall] Partition to be saved: ', currentPartitionData, JSON.parse(currentPartitionData.polygon_json));
772
+ dispatchSpaceEvent(SPACE_EVENTS.PARTITION_EDITED, { data: currentPartitionData });
773
+ wallMaterialInput.disabled = true;
774
+ wallEditMaterial.style.display = "block";
775
+ wallConfirmMaterial.style.display = "none";
776
+ }));
777
+ addEventListenerById('at-wall-edit-material-btn', () => {
778
+ console.log('@caroline wall check in pencil', wallMaterial, currentWall.material);
779
+ const wallEditMaterial = document.getElementById('at-wall-edit-material-btn');
780
+ const wallConfirmMaterial = document.getElementById('at-confirm-edit-wall-btn');
781
+ const wallMaterialInput = document.getElementById('at-edit-wall-input');
782
+ wallMaterialInput.disabled = false;
783
+ wallEditMaterial.style.display = "none";
784
+ wallConfirmMaterial.style.display = "block";
785
+ });
786
+ }
787
+ function displayWall(wall) {
788
+ log.info("displayWall()", wall);
789
+ // Extract the wall name from the format "_wall-{number}" using regex
790
+ const match = wall.name.match(/wall-(\d+)$/);
791
+ let wallName = '';
792
+ if (match) {
793
+ const wallNumber = parseInt(match[1]) + 1;
794
+ wallName = `${i18n.t('Wall')} ${wallNumber}`;
795
+ }
796
+ const element = document.createElement('div');
797
+ element.classList.add('at_container');
798
+ const windowsHTML = wall.windows ?
799
+ `<div class="at_dropdown_item_container" id="at-window-list-${wall.uuid}" data-cy="at-vertex-list-${wall.uuid}" style="display: flex;"></div>` :
800
+ ``;
801
+ log.info("windowsHTML", wall.windows, windowsHTML);
802
+ element.innerHTML = `
803
+ <div class="at_item at_face_item selected">
804
+ <div class="at_subitem_left">
805
+ <span class="mdi mdi-vector-line"></span>
806
+ </div>
807
+ <div class="at_subitem_center" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}">
808
+ ${wallName}
809
+ <span class="mdi mdi-chevron-up" id="at-chevron-${wall.uuid}"></span>
810
+ </div>
811
+ <div class="at_subitem_right at_invisible">
812
+ <span class="mdi mdi-delete-outline"></span>
813
+ </div>
814
+ </div>
815
+ ${windowsHTML}
816
+ `;
817
+ if (windowsHTML) {
818
+ const windowItemsContainer = element.querySelector(`#at-window-list-${wall.uuid}`);
819
+ wall.windows.forEach((window) => {
820
+ const row = displayWindows(window);
821
+ windowItemsContainer.appendChild(row);
822
+ });
823
+ }
824
+ setupWallWindowToggle(element, wall);
825
+ return element;
826
+ }
827
+ function setupWallWindowToggle(element, wall) {
828
+ const wallNameBtn = element.querySelector(`#at-expand-btn-${wall.uuid}`);
829
+ const windowList = element.querySelector(`#at-window-list-${wall.uuid}`);
830
+ const chevronIcon = element.querySelector(`#at-chevron-${wall.uuid}`);
831
+ if (!wallNameBtn || !windowList || !chevronIcon)
832
+ return;
833
+ wallNameBtn.addEventListener("click", () => {
834
+ const isHidden = windowList.style.display === "none";
835
+ windowList.style.display = isHidden ? "flex" : "none";
836
+ // Toggle chevron direction
837
+ chevronIcon.classList.toggle("mdi-chevron-up", isHidden);
838
+ chevronIcon.classList.toggle("mdi-chevron-down", !isHidden);
839
+ });
840
+ }
841
+ function displayWindows(window) {
842
+ var _a;
843
+ log.info("displayWindows()", window);
844
+ const element = document.createElement('div');
845
+ element.classList.add('at_dropdown_item');
846
+ // Extract the wall name from the format "_wall-{number}" using regex
847
+ const match = window.name.match(/window-(\d+)$/);
848
+ let windowName = '';
849
+ if (match) {
850
+ const wallNumber = parseInt(match[1]);
851
+ windowName = `${i18n.t('Window')} ${wallNumber}`;
852
+ }
853
+ else {
854
+ windowName = window.name;
855
+ }
856
+ if (currentWall && currentWall.material) {
857
+ wallMaterial = currentWall.material;
858
+ inputWallMaterial.value = currentWall.material;
859
+ }
860
+ element.innerHTML = `
861
+ <div class="at_dropdown_subitem_container">
862
+ <div class="at_subitem_left">
863
+ <span class="mdi mdi-window-closed-variant"></span>
864
+ </div>
865
+ <div class="at_subitem_center">
866
+ <div class="at_name" id="at-window-name-${window.index}" data-index="${window.index}">${windowName}</div>
867
+ <div class="at_tooltip" id="at-window-name-tooltip-${window.index}">${windowName}</div>
868
+ <div class="at_distance">${window.area.toFixed(2)} m²</div>
869
+ </div>
870
+ <div class="at_subitem_right">
871
+ <span class="mdi mdi-pencil" id="at-edit-window-btn-${window.index}"></span>
872
+ <span class="mdi mdi-check" id="at-confirm-edit-window-${window.index}" data-cy="at-confirm-edit-window-${window.index}" style="display: none;"></span>
873
+ <span class="mdi mdi-delete-outline" id="at-delete-window-btn-${window.index}"></span>
874
+ </div>
875
+ </div>
876
+ <div class="at_edit_name" id="at-edit-window-name-${window.index}" data-index="${window.index}" style="display: none;">
877
+ <input class="at_edit_name_input" type="text" id="at-edit-window-name-input-${window.index}" data-cy="at-edit-window-name-input-${window.index}" value="${windowName}" placeholder="${i18n.t('EnterNameHere')}">
878
+ </div>
879
+ <div class="at_edit_material" id="at-edit-window-material-${window.index}" data-index="${window.index}" style="display: none;">
880
+ <input class="at_edit_material_input" type="text" id="at-edit-window-material-input-${window.index}" data-cy="at-edit-window-material-input-${window.index}" value="${(_a = window.material) !== null && _a !== void 0 ? _a : ''}" placeholder="${i18n.t('EnterMaterialHere')}">
881
+ </div>
882
+ `;
883
+ const nameElement = element.querySelector(`#at-window-name-${window.index}`);
884
+ const tooltipElement = element.querySelector(".at_tooltip");
885
+ setupTooltip(nameElement, tooltipElement);
886
+ setupEditWindow(element, window);
887
+ setupDeleteWindow(element, window);
888
+ return element;
889
+ }
890
+ function setupTooltip(nameElement, tooltipElement) {
891
+ nameElement.addEventListener("mouseenter", () => {
892
+ const isEllipsis = nameElement.offsetWidth < nameElement.scrollWidth;
893
+ tooltipElement.style.display = isEllipsis ? "block" : "none";
894
+ });
895
+ nameElement.addEventListener("mouseleave", () => {
896
+ tooltipElement.style.display = "none";
897
+ });
898
+ }
899
+ function setupEditWindow(element, window) {
900
+ const editBtn = element.querySelector(`#at-edit-window-btn-${window.index}`);
901
+ // Edit name elements
902
+ const editNameContainer = element.querySelector(`.at_edit_name#at-edit-window-name-${window.index}`);
903
+ const inputName = element.querySelector(`#at-edit-window-name-input-${window.index}`);
904
+ const nameLabel = element.querySelector(`#at-window-name-${window.index}`);
905
+ // Edit material elements
906
+ const editMaterialContainer = element.querySelector(`.at_edit_material#at-edit-window-material-${window.index}`);
907
+ const inputMaterial = element.querySelector(`#at-edit-window-material-input-${window.index}`);
908
+ const confirmBtn = element.querySelector(`#at-confirm-edit-window-${window.index}`);
909
+ if (!editBtn || !editNameContainer || !inputName || !nameLabel || !editMaterialContainer || !inputMaterial)
910
+ return;
911
+ // Show inputs when edit icon is clicked
912
+ editBtn.addEventListener("click", () => {
913
+ editNameContainer.style.display = "flex";
914
+ editMaterialContainer.style.display = "flex";
915
+ editBtn.style.display = "none";
916
+ confirmBtn.style.display = "flex";
917
+ inputName.focus();
918
+ log.info("3DXOBJECT", get3DXObjects());
919
+ // enableVerticeControls(window.component)
920
+ });
921
+ // // Confirm edit name and material
922
+ confirmBtn.addEventListener("click", () => {
923
+ // Update window name
924
+ const newName = inputName.value.trim();
925
+ window.name = newName || window.name;
926
+ nameLabel.textContent = window.name;
927
+ editNameContainer.style.display = "none";
928
+ const newMaterial = inputMaterial.value.trim();
929
+ window.material = newMaterial || window.material;
930
+ editMaterialContainer.style.display = "none";
931
+ editBtn.style.display = "flex";
932
+ confirmBtn.style.display = "none";
933
+ const windowTooltip = document.getElementById(`at-window-name-tooltip-${window.index}`);
934
+ windowTooltip.innerText = `${window.name}`;
935
+ saveWindowChanges();
936
+ });
937
+ }
938
+ function saveWindowChanges() {
939
+ updateWallInPolygon(currentWall);
940
+ updatePartitionData();
941
+ setCurrentPolygon(currentObject);
942
+ renderCurrentPartition();
943
+ // dispatchSpaceEvent(SPACE_EVENTS.PARTITION_EDITED, { data: currentPartitionData });
944
+ }
945
+ // --- helpers ---
946
+ function updateWallInPolygon(updatedWall) {
947
+ const wallIndex = currentPolygonData.walls.findIndex(w => w.uuid === updatedWall.uuid);
948
+ if (wallIndex !== -1)
949
+ currentPolygonData.walls[wallIndex] = updatedWall;
950
+ }
951
+ function updatePartitionData() {
952
+ const currentPartitionIndex = currentPartitionDataArray.findIndex(p => p.uuid === currentPartitionData.uuid);
953
+ if (currentPartitionIndex === -1)
954
+ return;
955
+ currentPartitionDataArray[currentPartitionIndex].polygon_json = JSON.stringify(currentPolygonData);
956
+ currentPartitionData = currentPartitionDataArray[currentPartitionIndex];
957
+ }
958
+ function renderCurrentPartition() {
959
+ if (!currentPartitionData)
960
+ return;
961
+ const payload = {
962
+ uuid: currentPartitionData.uuid,
963
+ space_uuid: currentPartitionData.space_uuid,
964
+ name: currentPartitionData.name,
965
+ parent_uuid: currentPartitionData.parent_uuid,
966
+ polygon_json: currentPolygonData
967
+ };
968
+ renderPolygon(payload);
969
+ }
970
+ function setupDeleteWindow(element, window) {
971
+ const deleteBtn = element.querySelector(`#at-delete-window-btn-${window.index}`);
972
+ if (!deleteBtn)
973
+ return;
974
+ deleteBtn.addEventListener("click", () => {
975
+ toggleModal();
976
+ setModalAction({
977
+ title: i18n.t("DeleteWindow"),
978
+ description: i18n.t("ConfirmDeleteWindow"),
979
+ buttonLabel: i18n.t("YesDelete"),
980
+ }, () => __awaiter(this, void 0, void 0, function* () {
981
+ element.remove();
982
+ log.info("Deleted window:", window.index);
983
+ toggleModal(false);
984
+ // Update wall windows
985
+ currentPolygonData.walls = currentPolygonData.walls.map(wall => {
986
+ if (wall.uuid !== currentWall.uuid)
987
+ return wall;
988
+ if (wall.windows.length === 1) {
989
+ const windowLists = document.getElementById(`at-window-list-${wall.uuid}`);
990
+ if (windowLists)
991
+ windowLists.style.display = "none";
992
+ }
993
+ currentWall = Object.assign(Object.assign({}, wall), { windows: wall.windows.filter((w) => w.index !== window.index) });
994
+ return currentWall;
995
+ });
996
+ // Save + rerender window
997
+ currentObject.object.object_data.json_data = currentPolygonData;
998
+ saveWindowChanges();
999
+ notify.success(`${i18n.t('SuccessWindowDelete')}`);
1000
+ log.info("currentPartition polygonJson", JSON.parse(currentPartitionData.polygon_json));
1001
+ log.info("currentObject", currentObject);
1002
+ log.info("currentWall", currentWall);
1003
+ log.info("currentPolygonData", currentPolygonData);
1004
+ }));
1005
+ });
594
1006
  }
595
1007
  /**
596
1008
  * Handles the transition back to the partition list view by updating the visibility of relevant UI elements.
597
1009
  * Resets the edit partition data and displays the current partitions.
598
1010
  */
599
1011
  function goBackToPartitionList() {
600
- console.log('goBackToPartitionList()');
601
- // Show the partition title and list, hide the face title and vertex container
602
- document.getElementById('at-partition-title').style.display = 'flex';
603
- document.getElementById('at-face-title').style.display = 'none';
604
- document.getElementById('at-partition-item-container').style.display = 'flex';
605
- document.getElementById('at-face-vertex-container').style.display = 'none';
606
- document.getElementById('at-edit-partition-name').style.display = 'none';
607
- // Display the list of partitions
1012
+ log.info("goBackToPartitionList()");
1013
+ const elements = {
1014
+ 'at-partition-title': 'flex',
1015
+ 'at-face-title': 'none',
1016
+ 'at-partition-item-container': 'flex',
1017
+ 'at-face-vertex-container': 'none',
1018
+ 'at-edit-partition-name': 'none'
1019
+ };
1020
+ Object.entries(elements).forEach(([id, value]) => {
1021
+ const el = document.getElementById(id);
1022
+ if (el)
1023
+ el.style.display = value;
1024
+ });
1025
+ log.info("currentPartitionDataArray", currentPartitionDataArray);
608
1026
  displayPartitions(currentPartitionDataArray);
609
- // Clear the current edit partition data
610
- currentEditPartitionData = null;
1027
+ isEditPartition = false;
611
1028
  currentPartitionData = null;
1029
+ setCurrentPolygon(undefined);
612
1030
  cancelDrawing();
613
1031
  setDrawingMode(false);
614
1032
  }
1033
+ function goBackToFloorWallList() {
1034
+ log.info("goBackToFloorWallList()");
1035
+ const elements = {
1036
+ 'at-face-title': 'flex',
1037
+ 'at-window-door-title': 'none',
1038
+ 'at-edit-partition-name': 'flex',
1039
+ 'at-add-window-door-btn': 'none',
1040
+ 'at-draw-partition-form-btn': 'block',
1041
+ 'at-edit-wall-material': 'none'
1042
+ };
1043
+ Object.entries(elements).forEach(([id, value]) => {
1044
+ document.getElementById(id).style.display = value;
1045
+ });
1046
+ log.info("currentPartitionData", currentPartitionData);
1047
+ if (currentPartitionData) {
1048
+ displayFaces(JSON.parse(currentPartitionData.polygon_json));
1049
+ if (currentObject) {
1050
+ setCurrentPolygon(currentObject);
1051
+ handleModifyPartition(currentObject);
1052
+ }
1053
+ }
1054
+ }
615
1055
  /**
616
1056
  * Displays the floor information in the UI, including the floor name, edit options, and associated vertices.
617
1057
  * @param floor - The floor data to display.
@@ -620,102 +1060,40 @@ function goBackToPartitionList() {
620
1060
  function displayFloor(floor, walls, floorModel) {
621
1061
  const floorModelUUID = floorModel ? floorModel.name : null;
622
1062
  const element = document.createElement('div');
623
- element.classList.add('at_face_vertex_item');
1063
+ element.classList.add('at_container');
624
1064
  element.innerHTML = `
625
- <div class="at_face_item">
626
- <div class="at_icon_left">
1065
+ <div class="at_item at_face_item selected">
1066
+ <div class="at_subitem_left">
627
1067
  <span class="mdi mdi-perspective-less"></span>
628
1068
  </div>
629
- <div class="at_face_name" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}" model-id="${floorModelUUID}">
1069
+ <div class="at_subitem_center at_face_name" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}" model-id="${floorModelUUID}">
630
1070
  ${i18n.t(`Floor`)}
631
- <span class="mdi mdi-chevron-down" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}" model-id="${floorModelUUID}"></span>
1071
+ <span class="mdi mdi-chevron-up" id="at-expand-btn-${floor.uuid}" data-cy="at-expand-btn-${floor.uuid}" model-id="${floorModelUUID}"></span>
632
1072
  </div>
633
- <div class="at_icon_right">
1073
+ <div class="at_subitem_right">
634
1074
  <span class="mdi mdi-delete-outline"></span>
635
1075
  </div>
636
1076
  </div>
637
- <div class="at_edit_name" id="at-edit-name-${floor.uuid}" data-cy="at-edit-name-${floor.uuid}">
638
- <div class="at_edit_name_text" id="at-edit-name-text-${floor.uuid}" data-cy="at-edit-name-text-${floor.uuid}">
639
- ${i18n.t('ClickEditName')}
640
- <span class="mdi mdi-pencil at_icon_right" id="at-edit-name-text-${floor.uuid}"></span>
641
- </div>
642
- <div class="at_edit_name_input" id="at-edit-name-input-${floor.uuid}" data-cy="at-edit-name-input-${floor.uuid}">
643
- <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">
644
- <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>
645
- </div>
1077
+
1078
+ <div class="at_edit_name" id="at-edit-floor-material">
1079
+ <input class="at_edit_name_input at_ml_1" type="text" id="at-edit-floor-material-input" data-cy="at-edit-floor-material-input" value="${floor.material ? floor.material : ''}" placeholder="${i18n.t('EnterFloorMaterial')}">
1080
+ <span class="mdi mdi-pencil at_mr-1" style="display: none; cursor: pointer;" id="at-floor-edit-material-btn"></span>
1081
+ <span class="mdi mdi-check at_mr-1" id="at-confirm-edit-floor-name" style="display: none;"></span>
646
1082
  </div>
647
- <div class="at_vertex_list" id="at-vertex-list-${floor.uuid}" data-cy="at-vertex-list-${floor.uuid}"></div>
1083
+
1084
+ <div class="at_dropdown_item_container" id="at-vertex-list-${floor.uuid}" data-cy="at-vertex-list-${floor.uuid}" style="display: flex;"></div>
648
1085
  `;
649
- // Get the at_vertex_list container for this floor
1086
+ // Get the at_dropdown_item_container container for this floor
650
1087
  const vertexListContainer = element.querySelector(`#at-vertex-list-${floor.uuid}`);
651
- // Append lines to the at_vertex_list container
1088
+ // Append lines to the at_dropdown_item_container container
652
1089
  floor.edges.forEach((vertex, index) => {
653
1090
  if (!walls[index].options.is_deleted) {
654
- const row = displayWalls(vertex, walls[index], index + 1, 'floor');
1091
+ const row = displayWalls(vertex, walls[index], index, 'floor');
655
1092
  vertexListContainer.appendChild(row); // Append to the correct container
656
1093
  }
657
1094
  });
658
1095
  return element;
659
1096
  }
660
- /**
661
- * Displays the wall information in the UI, including the wall name, edit options, and associated vertices.
662
- * @param wall - The wall data to display.
663
- * @returns The created HTML element representing the wall and its associated data.
664
- *\/
665
- function displayWalls(wall: WallPolyData, wallModel): HTMLElement {
666
- const wallModelUUID = wallModel ? wallModel.name : null;
667
-
668
- // Extract the wall name from the format "_wall-{number}" using regex
669
- const match = wall.name.match(/wall-(\d+)$/);
670
- let wallName = '';
671
-
672
- if (match) {
673
- const wallNumber = parseInt(match[1]) + 1;
674
- wallName = `${i18n.t('Wall')} ${wallNumber}`;
675
- }
676
-
677
- const element = document.createElement('div');
678
- element.classList.add('at_face_vertex_item');
679
-
680
- element.innerHTML = `
681
- <div class="at_face_item">
682
- <div class="at_icon_left">
683
- <span class="mdi mdi-perspective-less at_face_icon_rotate_270"></span>
684
- </div>
685
- <div class="at_face_name" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}" model-id="${wallModelUUID}">
686
- ${wallName}
687
- <span class="mdi mdi-chevron-down" id="at-expand-btn-${wall.uuid}" data-cy="at-expand-btn-${wall.uuid}" model-id="${wallModelUUID}"></span>
688
- </div>
689
- <div class="at_icon_right at_invisible">
690
- <span class="mdi mdi-delete-outline"></span>
691
- </div>
692
- </div>
693
- <div class="at_edit_name" id="at-edit-name-${wall.uuid}" data-cy="at-edit-name-${wall.uuid}">
694
- <div class="at_edit_name_text" id="at-edit-name-text-${wall.uuid}" data-cy="at-edit-name-text-${wall.uuid}">
695
- ${i18n.t('ClickEditName')}
696
- <span class="mdi mdi-pencil at_icon_right" id="at-edit-name-text-${wall.uuid}"></span>
697
- </div>
698
- <div class="at_edit_name_input" id="at-edit-name-input-${wall.uuid}" data-cy="at-edit-name-input-${wall.uuid}">
699
- <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">
700
- <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>
701
- </div>
702
- </div>
703
- <div class="at_vertex_list" id="at-vertex-list-${wall.uuid}" data-cy="at-vertex-list-${wall.uuid}">
704
- </div>
705
- `;
706
-
707
- // Get the at_vertex_list container for this wall
708
- const vertexListContainer = element.querySelector(`#at-vertex-list-${wall.uuid}`);
709
-
710
- // Append lines to the at_vertex_list container
711
- wall.edges.forEach((vertex, index) => {
712
- const row = displayWalls(vertex, index + 1, 'wall');
713
- vertexListContainer.appendChild(row); // Append to the correct container
714
- });
715
-
716
- return element;
717
- }
718
- */
719
1097
  /**
720
1098
  * Displays the line information for a given vertex, including its name, distance, and delete icon.
721
1099
  * The delete icon visibility depends on whether the face type is 'floor'.
@@ -734,28 +1112,28 @@ function displayWalls(vertex, wall, index, faceType) {
734
1112
  wallName = `${i18n.t('Wall')} ${wallNumber}`;
735
1113
  }
736
1114
  const element = document.createElement('div');
737
- element.classList.add('at_vertex_item');
1115
+ element.classList.add('at_dropdown_item');
738
1116
  // Determine whether to display the delete icon based on faceType ('floor' only)
739
1117
  const deleteIconHtml = faceType === 'floor' ?
740
- `<div class="at_vertex_icon_right at_delete_wall_btn" id="at-delete-wall-btn_${wall.uuid}">
741
- <span class="mdi mdi-delete-outline" id="at-delete-wall-btn_${wall.uuid}"></span>
1118
+ `<div class="at_subitem_right">
1119
+ <span class="mdi mdi-pencil at_edit_wall_btn" id="at-edit-wall-btn-${wall.uuid}" index=${index}></span>
1120
+ <span class="mdi mdi-delete-outline at_delete_wall_btn" id="at-delete-wall-btn-${wall.uuid}"></span>
742
1121
  </div>` :
743
- `<div class="at_vertex_icon_right at_invisible">
744
- <span class="mdi mdi-delete-outline"></span>
1122
+ `<div class="at_subitem_right">
1123
+ <span class="mdi mdi-pencil at_edit_wall_btn" id="at-edit-wall-btn-${wall.uuid}" index=${index}></span>
1124
+ <span class="mdi mdi-delete-outline at_invisible"></span>
745
1125
  </div>`;
746
1126
  element.innerHTML = `
747
- <div class="at_vertex_icon_left">
748
- <span class="mdi mdi-vector-line"></span>
749
- </div>
750
- <div class="at_vertex_center">
751
- <div class="at_vertex_name">
752
- ${wallName}
1127
+ <div class="at_dropdown_subitem_container">
1128
+ <div class="at_subitem_left">
1129
+ <span class="mdi mdi-vector-line"></span>
753
1130
  </div>
754
- <div class="at_vertex_distance">
755
- ${vertex.length + " m"}
1131
+ <div class="at_subitem_center">
1132
+ <div class="at_name">${wallName}</div>
1133
+ <div class="at_distance">${wall.area.toFixed(2) + " m²"}</div>
756
1134
  </div>
1135
+ ${deleteIconHtml}
757
1136
  </div>
758
- ${deleteIconHtml}
759
1137
  `;
760
1138
  return element;
761
1139
  }
@@ -783,13 +1161,25 @@ function addEventListenerById(id, callback) {
783
1161
  export function clearPartitionForm() {
784
1162
  console.log('clearPartitionForm()');
785
1163
  goBackToPartitionList();
1164
+ hideElement('at-window-door-title');
1165
+ displayElement('at-draw-partition-form-btn', 'block');
1166
+ hideElement('at-add-window-door-btn');
1167
+ hideElement('at-edit-wall-material');
1168
+ resetDrawingConfig();
786
1169
  cancelDrawing();
787
1170
  const partitionContainer = document.getElementById('at-partition-item-container');
788
1171
  partitionContainer.style.display = 'none';
1172
+ const addDoorButton = document.getElementById('at-add-window-door-btn');
1173
+ addDoorButton.classList.remove('at_add_window_door_btn_active');
1174
+ addDoorButton.classList.add('at_add_window_door_btn');
1175
+ addDoorButton.innerHTML = `
1176
+ ${i18n.t('AddWindowDoor')}
1177
+ <span class="mdi mdi-window-closed-variant"></span>
1178
+ `;
789
1179
  document.getElementById('at-room-form').reset();
790
1180
  currentPartitionDataArray = [];
791
1181
  currentEditRoomData = null;
792
- currentEditPartitionData = null;
1182
+ isEditPartition = false;
793
1183
  currentPolygonData = null;
794
1184
  currentPartitionData = null;
795
1185
  currentDeletePartitionData = null;
@@ -798,6 +1188,8 @@ export function clearPartitionForm() {
798
1188
  savedPartitionDataArray = [];
799
1189
  currentHighlightedFace = null;
800
1190
  previousPartitionData = null;
1191
+ isDrawing = false;
1192
+ drawingMode = null;
801
1193
  }
802
1194
  /**
803
1195
  * Cancels the drawing action for a partition.
@@ -826,6 +1218,7 @@ function cancelDrawing() {
826
1218
  }
827
1219
  cancelDraw();
828
1220
  isDrawing = false;
1221
+ drawingMode = null;
829
1222
  const drawRoomBtn = document.getElementById('at-draw-partition-form-btn');
830
1223
  drawRoomBtn.classList.remove('at_draw_partition_btn_active');
831
1224
  drawRoomBtn.classList.add('at_draw_partition_btn');
@@ -851,6 +1244,7 @@ function startDrawing() {
851
1244
  }
852
1245
  startDraw();
853
1246
  isDrawing = true;
1247
+ drawingMode = 'partition';
854
1248
  const drawRoomBtn = document.getElementById('at-draw-partition-form-btn');
855
1249
  drawRoomBtn.classList.remove('at_draw_partition_btn');
856
1250
  drawRoomBtn.classList.add('at_draw_partition_btn_active');
@@ -963,12 +1357,12 @@ export function clearTempCurrentPolygon() {
963
1357
  */
964
1358
  export function setPolygonData(payload) {
965
1359
  console.log('setPolygonData()', payload);
966
- // let currentPolygon = getCurrentPolygon()
967
- // console.log('currentPolygon ', currentPolygon);
968
- // if (currentPolygon) {
969
- // currentPolygon.object.object_data.json_data = payload
1360
+ // let currentObjectData = getCurrentPolygon()
1361
+ // console.log('currentObjectData ', currentObjectData);
1362
+ // if (currentObjectData) {
1363
+ // currentObjectData.object.object_data.json_data = payload
970
1364
  // }
971
- // setCurrentPolygon(currentPolygon)
1365
+ // setCurrentPolygon(currentObjectData)
972
1366
  // Helper function to round numbers to 2 decimals
973
1367
  function roundToFourDecimals(value) {
974
1368
  if (typeof value === "number") {
@@ -1020,22 +1414,24 @@ export function setCurrentPartitionData() {
1020
1414
  const floorLevel = ((_a = document.getElementById('at-room-floor-level-input')) === null || _a === void 0 ? void 0 : _a.value) || null;
1021
1415
  const currentUrl = window.location.href;
1022
1416
  const spaceUUID = extractUUID(currentUrl);
1023
- let currentPolygon = null;
1417
+ let currentObjectData = null;
1024
1418
  yield new Promise(resolve => {
1025
1419
  const interval = setInterval(() => {
1026
1420
  var _a, _b;
1027
- currentPolygon = getCurrentPolygon();
1028
- console.log("currentPolygon", currentPolygon);
1029
- if (((_b = (_a = currentPolygon === null || currentPolygon === void 0 ? void 0 : currentPolygon.object) === null || _a === void 0 ? void 0 : _a.object_data) === null || _b === void 0 ? void 0 : _b.uuid) !== undefined) {
1421
+ currentObjectData = getCurrentPolygon();
1422
+ console.log("currentObjectData", currentObjectData);
1423
+ if (((_b = (_a = currentObjectData === null || currentObjectData === void 0 ? void 0 : currentObjectData.object) === null || _a === void 0 ? void 0 : _a.object_data) === null || _b === void 0 ? void 0 : _b.uuid) !== undefined) {
1030
1424
  clearInterval(interval);
1031
1425
  resolve();
1032
1426
  }
1033
- if (currentPolygon == undefined) {
1427
+ if (currentObjectData == undefined) {
1034
1428
  currentPolygonData = null;
1035
1429
  clearInterval(interval);
1036
1430
  resolve();
1037
1431
  }
1038
- displayFaceLists();
1432
+ if (drawingMode === 'partition') {
1433
+ displayFaceLists();
1434
+ }
1039
1435
  }, 50); // Check every 50ms
1040
1436
  });
1041
1437
  if (currentPolygonData) {
@@ -1043,7 +1439,7 @@ export function setCurrentPartitionData() {
1043
1439
  polygonData.floor.floor_level = Number(floorLevel); // Set the floor level from the input
1044
1440
  // Create a new partition data payload
1045
1441
  const newPayload = {
1046
- uuid: currentPolygon.object.object_data.uuid,
1442
+ uuid: currentObjectData.object.object_data.uuid,
1047
1443
  space_uuid: spaceUUID,
1048
1444
  name: null,
1049
1445
  parent_uuid: null,
@@ -1052,24 +1448,25 @@ export function setCurrentPartitionData() {
1052
1448
  if (currentEditRoomData) {
1053
1449
  newPayload.parent_uuid = currentEditRoomData.uuid; // Set the parent UUID if editing an existing room
1054
1450
  }
1055
- if (currentEditPartitionData) {
1056
- newPayload.name = currentEditPartitionData.name;
1451
+ if (isEditPartition) {
1452
+ newPayload.name = currentPartitionData.name;
1057
1453
  console.log("newPayload.name", newPayload.name);
1058
- // currentPartitionDataArray = currentPartitionDataArray.map(partition =>
1059
- // partition.uuid === currentEditPartitionData.uuid
1060
- // ? { ...partition, uuid: newPayload.uuid }
1061
- // : partition
1062
- // );
1063
- // dispatchSpaceEvent(SPACE_EVENTS.PARTITION_DISPOSED, currentEditPartitionData);
1064
- // currentEditPartitionData.uuid = newPayload.uuid
1065
1454
  }
1066
1455
  if (currentHighlightedFace) {
1067
1456
  setMeshChildrenMaterialProperty(currentHighlightedFace.component, currentHighlightedFace.name, currentHighlightedFace.type, currentHighlightedFace.value);
1068
1457
  }
1069
- //if (!currentEditPartitionData){
1070
1458
  updatePartitionDataArray(newPayload, currentPartitionDataArray);
1071
- //}
1072
- displayFaces(currentPolygonData);
1459
+ if (drawingMode === 'partition') {
1460
+ displayFaces(currentPolygonData);
1461
+ }
1462
+ else if (drawingMode === 'window') {
1463
+ log.info("current wall", currentWall);
1464
+ // Update current edit wall display
1465
+ currentWall = currentPolygonData.walls.find(wall => wall.uuid == currentWall.uuid);
1466
+ const faceVertexContainer = document.getElementById('at-face-vertex-container');
1467
+ faceVertexContainer.innerHTML = '';
1468
+ faceVertexContainer.append(displayWall(currentWall));
1469
+ }
1073
1470
  }
1074
1471
  else {
1075
1472
  const faceVertexContainer = document.getElementById('at-face-vertex-container');
@@ -1085,22 +1482,124 @@ export function setCurrentPartitionData() {
1085
1482
  });
1086
1483
  }
1087
1484
  function updatePartitionDataArray(payload, currentPartitionDataArray) {
1088
- // Find the index of the partition with the same uuid
1089
- const existingIndex = currentPartitionDataArray.findIndex((partition) => partition.uuid === payload.uuid);
1090
- if (existingIndex !== -1) {
1091
- // Remove the existing partition
1092
- currentPartitionDataArray.splice(existingIndex, 1);
1485
+ log.info("updatePartitionDataArray", payload, currentPartitionDataArray);
1486
+ if (drawingMode === 'partition') {
1487
+ // Find the index of the partition with the same uuid
1488
+ const existingIndex = currentPartitionDataArray.findIndex((partition) => partition.uuid === payload.uuid);
1489
+ const partitionName = document.getElementById('at-edit-partition-name-input');
1490
+ if (existingIndex !== -1) {
1491
+ if (payload.name == null)
1492
+ payload.name = partitionName.value || `${i18n.t('Partition')} ${currentPartitionDataArray.length}`;
1493
+ currentPartitionDataArray[existingIndex] = Object.assign(Object.assign({}, currentPartitionDataArray[existingIndex]), payload);
1494
+ }
1495
+ if (existingIndex === -1) {
1496
+ if (payload.name == null)
1497
+ payload.name = partitionName.value || `${i18n.t('Partition')} ${currentPartitionDataArray.length + 1}`;
1498
+ log.info("@@ payload", payload.name);
1499
+ // Add the new partition
1500
+ currentPartitionDataArray.push(payload);
1501
+ newlyAddedPartition.push(payload);
1502
+ console.log("newlyAddedPartition", payload);
1503
+ }
1504
+ currentPartitionData = payload;
1093
1505
  }
1094
- payload.name = `${i18n.t('Partition')} ${currentPartitionDataArray.length + 1}`;
1095
- currentPartitionDataArray.push(payload);
1096
- currentPartitionData = payload;
1097
- if (existingIndex === -1) {
1098
- // Add the new partition
1099
- newlyAddedPartition.push(payload);
1100
- console.log("newlyAddedPartition", payload);
1506
+ else if (drawingMode === 'window') {
1507
+ // Update current partition data
1508
+ currentPartitionData.polygon_json = JSON.stringify(currentPolygonData);
1509
+ // Update current partition data array
1510
+ const currentPartitionDataIndex = currentPartitionDataArray.findIndex(partitionData => partitionData.uuid = currentPartitionData.uuid);
1511
+ currentPartitionDataArray[currentPartitionDataIndex] = currentPartitionData;
1101
1512
  }
1102
1513
  dispatchSpaceEvent(SPACE_EVENTS.PARTITION_EDITED, { data: currentPartitionData });
1103
1514
  }
1515
+ function onModeDetectFloorInput(event) {
1516
+ //@ts-expect-error
1517
+ console.log('@caroline onModeDetectFloorInput()', event.target.value);
1518
+ const target = event.target;
1519
+ const floorMaterialValue = target.value;
1520
+ setFloorMaterial(floorMaterialValue);
1521
+ //@ts-expect-error
1522
+ const floorID = event.target.id.split("input-")[1];
1523
+ console.log('@caroline User type material: ', floorMaterialValue, floorID);
1524
+ const floorEditMaterial = document.getElementById('at-floor-edit-material-btn');
1525
+ const floorConfirmMaterial = document.getElementById('at-confirm-edit-floor-name');
1526
+ if (floorMaterialValue) {
1527
+ floorEditMaterial.style.display = "none";
1528
+ floorConfirmMaterial.style.display = "block";
1529
+ }
1530
+ else {
1531
+ floorEditMaterial.style.display = "block";
1532
+ floorConfirmMaterial.style.display = "none";
1533
+ }
1534
+ }
1535
+ function setFloorMaterial(material) {
1536
+ console.log('setFloorMaterial()', material);
1537
+ floorMaterial = material;
1538
+ }
1539
+ function onModeDetectWallInput(event) {
1540
+ console.log('onModeDetectWallInput()', event);
1541
+ const target = event.target;
1542
+ const wallMaterialValue = target.value;
1543
+ const wallEditMaterial = document.getElementById('at-wall-edit-material-btn');
1544
+ const wallConfirmMaterial = document.getElementById('at-confirm-edit-wall-btn');
1545
+ setWallMaterial(wallMaterialValue);
1546
+ if (wallMaterialValue) {
1547
+ wallEditMaterial.style.display = "none";
1548
+ wallConfirmMaterial.style.display = "block";
1549
+ }
1550
+ else {
1551
+ wallEditMaterial.style.display = "block";
1552
+ wallConfirmMaterial.style.display = "none";
1553
+ }
1554
+ }
1555
+ function setWallMaterial(material) {
1556
+ console.log('setWallMaterial()');
1557
+ wallMaterial = material;
1558
+ }
1559
+ function setFloorMaterialIcon(material) {
1560
+ console.log('setFloorMaterialIcon', material);
1561
+ const floorEditMaterial = document.getElementById('at-floor-edit-material-btn');
1562
+ const floorConfirmMaterial = document.getElementById('at-confirm-edit-floor-name');
1563
+ const floorMaterialContainer = document.getElementById('at-edit-floor-material');
1564
+ const floorMaterialInput = document.getElementById('at-edit-floor-material-input');
1565
+ if (floorMaterialContainer && floorMaterialInput) {
1566
+ console.log('setFloorMaterialIcon inside first if', material);
1567
+ if (!material) {
1568
+ console.log('setFloorMaterialIcon no material', material);
1569
+ floorEditMaterial.style.display = 'none';
1570
+ floorConfirmMaterial.style.display = 'none';
1571
+ floorMaterialInput.disabled = false;
1572
+ }
1573
+ else {
1574
+ console.log('setFloorMaterialIcon have material', material);
1575
+ floorEditMaterial.style.display = 'block';
1576
+ floorConfirmMaterial.style.display = 'none';
1577
+ floorMaterialInput.disabled = true;
1578
+ }
1579
+ }
1580
+ }
1581
+ // sets the icon for wall material
1582
+ function setWallMaterialIcon(material) {
1583
+ console.log('setFloorMaterialIcon()');
1584
+ const wallEditMaterial = document.getElementById('at-wall-edit-material-btn');
1585
+ const wallConfirmMaterial = document.getElementById('at-confirm-edit-wall-btn');
1586
+ const wallInputValue = document.getElementById('at-edit-wall-input');
1587
+ const wallContainer = document.getElementById('at-edit-wall-material');
1588
+ if (wallContainer) {
1589
+ if (!material) {
1590
+ wallEditMaterial.style.display = 'none';
1591
+ wallConfirmMaterial.style.display = 'none';
1592
+ wallInputValue.disabled = false;
1593
+ wallInputValue.value = '';
1594
+ }
1595
+ else {
1596
+ wallConfirmMaterial.style.display = 'none';
1597
+ wallEditMaterial.style.display = 'block';
1598
+ wallInputValue.disabled = true;
1599
+ wallInputValue.value = material;
1600
+ }
1601
+ }
1602
+ }
1104
1603
  export function getCurrentPartitionData() {
1105
1604
  return currentPartitionData;
1106
1605
  }
@@ -1110,9 +1609,12 @@ export function getNewlyAddedPartition() {
1110
1609
  export function getDeletedSavedPartitionArray() {
1111
1610
  return deletedSavedPartitionArray;
1112
1611
  }
1113
- export function getDrawingMode() {
1612
+ export function getIsDrawing() {
1114
1613
  return isDrawing;
1115
1614
  }
1615
+ export function getDrawingMode() {
1616
+ return drawingMode;
1617
+ }
1116
1618
  export function setDrawingMode(state) {
1117
1619
  if (typeof state !== 'boolean') {
1118
1620
  log.error("Invalid parameter value");
@@ -1129,3 +1631,44 @@ export function getPreviousPartitionData() {
1129
1631
  export function setPreviousPartitionData(payload) {
1130
1632
  previousPartitionData = payload;
1131
1633
  }
1634
+ /**
1635
+ * Handles the partition wall edit button click by switching to wall editing mode and updating the UI.
1636
+ * @param wallUuid - The unique identifier of the wall to edit
1637
+ */
1638
+ export function handlePartitionWallEditBtn(wallUuid) {
1639
+ return __awaiter(this, void 0, void 0, function* () {
1640
+ log.info("currentPartitionData", currentPartitionData);
1641
+ log.info("polygonJson", JSON.parse(currentPartitionData.polygon_json));
1642
+ log.info("getCurrentPolygon()", getCurrentPolygon());
1643
+ setDrawingMode(false);
1644
+ const elements = {
1645
+ 'at-face-title': 'none',
1646
+ 'at-window-door-title': 'flex',
1647
+ 'at-edit-partition-name': 'none',
1648
+ 'at-add-window-door-btn': 'block',
1649
+ 'at-draw-partition-form-btn': 'none',
1650
+ 'at-edit-wall-material': 'flex'
1651
+ };
1652
+ Object.entries(elements).forEach(([id, value]) => {
1653
+ document.getElementById(id).style.display = value;
1654
+ });
1655
+ const faceVertexContainer = document.getElementById('at-face-vertex-container');
1656
+ faceVertexContainer.innerHTML = '';
1657
+ currentWall = JSON.parse(currentPartitionData.polygon_json).walls.find((wall) => wall.uuid == wallUuid);
1658
+ log.info("currenWall", currentWall);
1659
+ const wallBottomMidPoint = {
1660
+ // @ts-ignore
1661
+ x: ((currentWall.edges[0].start.x + currentWall.edges[1].start.x + currentWall.edges[2].start.x + currentWall.edges[3].start.x) / 4),
1662
+ // @ts-ignore
1663
+ y: ((currentWall.edges[0].start.y + currentWall.edges[1].start.y + currentWall.edges[2].start.y + currentWall.edges[3].start.y) / 4),
1664
+ // @ts-ignore
1665
+ z: ((currentWall.edges[0].start.z + currentWall.edges[1].start.z + currentWall.edges[2].start.z + currentWall.edges[3].start.z) / 4),
1666
+ };
1667
+ yield goToPosition(wallBottomMidPoint);
1668
+ faceVertexContainer.append(displayWall(currentWall));
1669
+ //sets material and icon
1670
+ setWallMaterial(currentWall.material);
1671
+ setWallMaterialIcon(currentWall.material);
1672
+ cancelDrawing();
1673
+ });
1674
+ }