Skip to content

Commit 0fb5910

Browse files
committed
fix(condo): DOMA-4578 fixed editMode change
1 parent 8107aff commit 0fb5910

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

apps/condo/domains/property/components/panels/Builder/MapConstructor.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,10 @@ class MapEdit extends MapView {
714714

715715
public removePreviewSection (): void {
716716
if (this.previewSectionId) {
717-
this.removeSection(this.previewSectionId)
717+
const sectionPreviewIndex = this.map.sections.findIndex(mapSection => mapSection.id === this.previewSectionId)
718+
this.map.sections.splice(sectionPreviewIndex, 1)
718719
this.previewSectionId = null
720+
this.notifyUpdater()
719721
}
720722
}
721723

@@ -751,8 +753,12 @@ class MapEdit extends MapView {
751753
public addSection (section: Partial<BuildingSectionArg>, unitType: BuildingUnitSubType = BuildingUnitSubType.Flat): void {
752754
const newSection = this.generateSection(section, unitType)
753755
this.map.sections.push(newSection)
756+
this.removePreviewUnit()
757+
this.viewMode = MapViewMode.section
758+
this.selectedUnit = null
759+
this.selectedSection = null
760+
this.mode = null
754761
this.notifyUpdater()
755-
this.editMode = 'addSection'
756762
}
757763

758764
public addPreviewSectionFloor (floor: BuildingFloorArg): void {
@@ -881,7 +887,8 @@ class MapEdit extends MapView {
881887

882888
public removePreviewParking (): void {
883889
if (this.previewParkingId) {
884-
this.removeParking(this.previewParkingId, false)
890+
const previewParkingIndex = this.map.parking.findIndex(mapParking => mapParking.id === this.previewParkingId)
891+
this.map.parking.splice(previewParkingIndex, 1)
885892
this.previewParkingId = null
886893
}
887894
}
@@ -901,8 +908,13 @@ class MapEdit extends MapView {
901908
public addParking (parking: Partial<BuildingSectionArg>): void {
902909
const newParking = this.generateSingleParking(parking)
903910
this.map.parking.push(newParking)
911+
this.viewMode = MapViewMode.parking
912+
this.removePreviewUnit()
913+
this.removePreviewSection()
914+
this.selectedUnit = null
915+
this.selectedSection = null
916+
this.mode = null
904917
this.notifyUpdater()
905-
this.editMode = 'addParking'
906918
}
907919

908920
public addPreviewCopyParking (parkingId: string): void {
@@ -1031,7 +1043,10 @@ class MapEdit extends MapView {
10311043

10321044
if (renameNextUnits) this.updateParkingUnitNumbers(newUnit)
10331045

1034-
this.editMode = 'addParkingUnit'
1046+
this.removePreviewParkingUnit()
1047+
this.removePreviewParking()
1048+
this.selectedParkingUnit = null
1049+
this.mode = null
10351050
this.notifyUpdater()
10361051
}
10371052

@@ -1060,7 +1075,11 @@ class MapEdit extends MapView {
10601075

10611076
if (renameNextUnits) this.updateUnitNumbers(newUnit)
10621077

1063-
this.editMode = 'addUnit'
1078+
this.removePreviewSection()
1079+
this.viewMode = MapViewMode.section
1080+
this.selectedSection = null
1081+
this.selectedUnit = null
1082+
this.mode = null
10641083
this.notifyUpdater()
10651084
}
10661085

@@ -1085,9 +1104,6 @@ class MapEdit extends MapView {
10851104
this.removeSection(this.map.sections[unitIndex.section].id, renameNextUnits)
10861105
}
10871106

1088-
this.selectedUnit = null
1089-
this.selectedSection = null
1090-
this.mode = null
10911107
this.notifyUpdater()
10921108
}
10931109

@@ -1111,8 +1127,6 @@ class MapEdit extends MapView {
11111127
this.removeParking(this.map.parking[unitIndex.parking].id, renameNextUnits)
11121128
}
11131129

1114-
this.selectedParkingUnit = null
1115-
this.editMode = null
11161130
this.notifyUpdater()
11171131
}
11181132

0 commit comments

Comments
 (0)