ember-ebau-gwr 2.5.1 → 3.0.0
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.
- package/.github/workflows/test.yml +3 -3
- package/CHANGELOG.md +101 -0
- package/addon/components/import-modal/building-data.hbs +64 -0
- package/addon/components/import-modal/dwelling-data.hbs +30 -0
- package/addon/components/import-modal/entrance-data.hbs +14 -0
- package/addon/components/import-modal.hbs +54 -0
- package/addon/components/import-modal.js +6 -0
- package/addon/components/link-building-modal.hbs +17 -14
- package/addon/components/link-building-modal.js +11 -1
- package/addon/components/link-street.hbs +83 -0
- package/addon/components/link-street.js +6 -0
- package/addon/components/linked-models.hbs +16 -2
- package/addon/components/linked-models.js +6 -0
- package/addon/components/linked-projects.hbs +2 -1
- package/addon/components/linked-projects.js +6 -0
- package/addon/components/model-form/date.hbs +1 -0
- package/addon/components/model-form/date.js +6 -6
- package/addon/components/model-form/diff.hbs +40 -27
- package/addon/components/model-form/field.hbs +13 -8
- package/addon/components/model-form/field.js +22 -6
- package/addon/components/model-form/header/actions.hbs +67 -35
- package/addon/components/model-form/header/actions.js +6 -0
- package/addon/components/model-form/header/status-selector.hbs +22 -5
- package/addon/components/model-form/header/status-selector.js +19 -4
- package/addon/components/model-form/header.hbs +10 -4
- package/addon/components/model-form.hbs +14 -9
- package/addon/components/model-form.js +20 -6
- package/addon/components/project-form/date.hbs +1 -1
- package/addon/components/project-form/field.hbs +1 -1
- package/addon/components/project-form/field.js +1 -1
- package/addon/components/search/filters.hbs +1 -1
- package/addon/components/search/filters.js +3 -3
- package/addon/controllers/building/edit/dwelling/edit.js +61 -5
- package/addon/controllers/building/edit/dwellings.js +3 -0
- package/addon/controllers/building/edit/entrance/edit/index.js +22 -8
- package/addon/controllers/building/edit/entrance/edit/link-street.js +30 -6
- package/addon/controllers/building/edit/entrances.js +18 -2
- package/addon/controllers/building/edit/form.js +109 -27
- package/addon/controllers/import.js +70 -0
- package/addon/controllers/project/form.js +221 -20
- package/addon/controllers/project/linked-buildings.js +20 -1
- package/addon/controllers/project.js +19 -0
- package/addon/controllers/search-building.js +17 -0
- package/addon/helpers/is-unset.js +7 -0
- package/addon/models/building-entrance.js +4 -5
- package/addon/models/building-work.js +11 -9
- package/addon/models/building.js +171 -114
- package/addon/models/client.js +1 -1
- package/addon/models/construction-project.js +148 -66
- package/addon/models/construction-projects-list.js +1 -1
- package/addon/models/dwelling.js +60 -66
- package/addon/models/identification.js +4 -17
- package/addon/models/options.js +1 -0
- package/addon/models/realestate-identification.js +8 -14
- package/addon/models.js +1 -2
- package/addon/routes/building/edit/dwelling/new.js +3 -0
- package/addon/routes/building/edit/entrance/edit/index.js +7 -0
- package/addon/routes/building/edit/entrance/edit/link-street.js +8 -1
- package/addon/routes/building/edit/entrance/new.js +12 -2
- package/addon/routes/building/edit/index.js +13 -1
- package/addon/routes/building/edit.js +5 -1
- package/addon/routes/building/new.js +25 -0
- package/addon/routes/project/form.js +5 -0
- package/addon/routes/project/new.js +3 -2
- package/addon/services/building-entrance.js +1 -1
- package/addon/services/building.js +412 -55
- package/addon/services/construction-project.js +637 -5
- package/addon/services/dwelling.js +238 -5
- package/addon/services/gwr.js +4 -2
- package/addon/templates/building/edit/dwelling/edit.hbs +20 -13
- package/addon/templates/building/edit/entrance/edit/index.hbs +16 -60
- package/addon/templates/building/edit/entrance/edit/link-street.hbs +9 -4
- package/addon/templates/building/edit/entrances.hbs +6 -3
- package/addon/templates/building/edit/form.hbs +130 -77
- package/addon/templates/project/errors.hbs +128 -126
- package/addon/templates/project/form.hbs +179 -71
- package/addon/templates/project/linked-buildings.hbs +20 -4
- package/addon/templates/project.hbs +40 -5
- package/addon/templates/search-building.hbs +9 -0
- package/addon/templates/search-project.hbs +4 -0
- package/addon/validations/building-entrance.js +5 -0
- package/addon/validations/building-work.js +30 -10
- package/addon/validations/construction-project.js +12 -0
- package/addon/validations/coordinates.js +7 -5
- package/addon/validations/dwelling.js +10 -0
- package/addon/validations/realestate-identification.js +39 -0
- package/addon/validations/status/status-building-change.js +10 -1
- package/addon/validations/status/status-building-correction.js +13 -3
- package/addon/validations/status/status-dwelling-change.js +20 -12
- package/addon/validations/status/status-dwelling-correction.js +19 -11
- package/addon/validations/status/status-project-change.js +24 -4
- package/addon/validations/status/status-project-correction.js +31 -10
- package/addon/xml/helpers.js +4 -0
- package/addon/xml/templates/building.js +35 -21
- package/addon/xml/templates/construction-project.js +3 -4
- package/addon/xml/templates/dwelling.js +7 -0
- package/app/styles/ember-ebau-gwr.scss +36 -6
- package/package.json +9 -5
- package/translations/building/de.yaml +42 -6
- package/translations/building-entrance/de.yaml +6 -11
- package/translations/construction-project/de.yaml +13 -5
- package/translations/de.yaml +72 -5
- package/translations/dwelling/de.yaml +7 -4
- package/addon/validators/presence-nested.js +0 -47
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import Controller from "@ember/controller";
|
|
2
1
|
import { action } from "@ember/object";
|
|
3
2
|
import { inject as service } from "@ember/service";
|
|
4
3
|
import { tracked } from "@glimmer/tracking";
|
|
5
4
|
import { task, dropTask, lastValue } from "ember-concurrency-decorators";
|
|
5
|
+
import ImportController from "ember-ebau-gwr/controllers/import";
|
|
6
6
|
import Models from "ember-ebau-gwr/models";
|
|
7
|
+
import Dwelling from "ember-ebau-gwr/models/dwelling";
|
|
7
8
|
import DwellingValidations from "ember-ebau-gwr/validations/dwelling";
|
|
8
9
|
|
|
9
|
-
export default class BuildingEditDwellingEditController extends
|
|
10
|
+
export default class BuildingEditDwellingEditController extends ImportController {
|
|
11
|
+
importModelName = "dwelling";
|
|
10
12
|
Models = Models;
|
|
11
13
|
DwellingValidations = DwellingValidations;
|
|
12
14
|
|
|
@@ -33,6 +35,7 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
33
35
|
try {
|
|
34
36
|
this.errors = [];
|
|
35
37
|
|
|
38
|
+
yield this.fetchCalumaData.perform();
|
|
36
39
|
yield this.fetchEntrances.perform();
|
|
37
40
|
if (this.model.dwelling?.isNew) {
|
|
38
41
|
this.model.dwelling.EDID = this.entrances[0].EDID;
|
|
@@ -45,6 +48,7 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
45
48
|
);
|
|
46
49
|
dwelling.oldEDID = EDID;
|
|
47
50
|
|
|
51
|
+
this.errors = [];
|
|
48
52
|
return dwelling;
|
|
49
53
|
} catch (error) {
|
|
50
54
|
console.error(error);
|
|
@@ -68,6 +72,12 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
@action
|
|
76
|
+
cancelMerge() {
|
|
77
|
+
this.resetImport();
|
|
78
|
+
this.fetchDwelling.perform();
|
|
79
|
+
}
|
|
80
|
+
|
|
71
81
|
@dropTask
|
|
72
82
|
*saveDwelling() {
|
|
73
83
|
try {
|
|
@@ -94,13 +104,41 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
94
104
|
}
|
|
95
105
|
}
|
|
96
106
|
|
|
107
|
+
concatStates(states) {
|
|
108
|
+
if (states.length === 1) {
|
|
109
|
+
return this.intl.t(`ember-gwr.lifeCycles.states.${states[0]}`);
|
|
110
|
+
}
|
|
111
|
+
const tail = states.pop();
|
|
112
|
+
return `${states
|
|
113
|
+
.map((state) => this.intl.t(`ember-gwr.lifeCycles.states.${state}`))
|
|
114
|
+
.join(", ")} ${this.intl.t("ember-gwr.general.or")} ${this.intl.t(
|
|
115
|
+
`ember-gwr.lifeCycles.states.${tail}`
|
|
116
|
+
)}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
97
119
|
@task
|
|
98
120
|
*transitionState(currentStatus, newStatus) {
|
|
99
121
|
try {
|
|
100
|
-
|
|
122
|
+
const transition =
|
|
123
|
+
Dwelling.dwellingTransitionMapping[currentStatus][newStatus];
|
|
124
|
+
|
|
125
|
+
// execute dry-run, throws error if requirements don't hold
|
|
126
|
+
yield this.dwellingAPI[transition](
|
|
127
|
+
transition,
|
|
128
|
+
1,
|
|
129
|
+
true,
|
|
130
|
+
this.dwelling,
|
|
131
|
+
this.model.buildingId
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// execute transition(s)
|
|
135
|
+
// cascade level:
|
|
136
|
+
// 1: only perform transition on dwelling
|
|
137
|
+
yield this.dwellingAPI[transition](
|
|
138
|
+
transition,
|
|
139
|
+
1,
|
|
140
|
+
false,
|
|
101
141
|
this.dwelling,
|
|
102
|
-
currentStatus,
|
|
103
|
-
newStatus,
|
|
104
142
|
this.model.buildingId
|
|
105
143
|
);
|
|
106
144
|
yield this.dwellingAPI.clearCache(
|
|
@@ -111,6 +149,24 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
111
149
|
} catch (error) {
|
|
112
150
|
console.error(error);
|
|
113
151
|
this.notification.danger(this.intl.t("ember-gwr.dwelling.saveError"));
|
|
152
|
+
|
|
153
|
+
if (error.isLifeCycleError) {
|
|
154
|
+
const errorType = error.dwellingId
|
|
155
|
+
? "statusErrorDwelling"
|
|
156
|
+
: "statusErrorBuilding";
|
|
157
|
+
throw [
|
|
158
|
+
this.intl.t(`ember-gwr.lifeCycles.${errorType}`, {
|
|
159
|
+
dwellingId: error.dwellingId,
|
|
160
|
+
buildingId: error.buildingId,
|
|
161
|
+
states: this.concatStates(error.states),
|
|
162
|
+
href: error.dwellingId
|
|
163
|
+
? `/${this.model.instanceId}/${this.model.projectId}/building/${error.buildingId}/dwelling/${error.dwellingId}`
|
|
164
|
+
: `/${this.model.instanceId}/${this.model.projectId}/building/${error.buildingId}/form`,
|
|
165
|
+
htmlSafe: true,
|
|
166
|
+
}),
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
|
|
114
170
|
throw error;
|
|
115
171
|
}
|
|
116
172
|
}
|
|
@@ -32,6 +32,9 @@ export default class BuildingEditDwellingsController extends Controller {
|
|
|
32
32
|
try {
|
|
33
33
|
await this.dwelling.deactivate(this.model, dwelling.EWID);
|
|
34
34
|
await this.fetchDwellings.perform();
|
|
35
|
+
this.notification.success(
|
|
36
|
+
this.intl.t("ember-gwr.building.dwellings.removeLinkSuccess")
|
|
37
|
+
);
|
|
35
38
|
} catch (error) {
|
|
36
39
|
console.error(error);
|
|
37
40
|
this.notification.danger(
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { action } from "@ember/object";
|
|
2
2
|
import { inject as service } from "@ember/service";
|
|
3
3
|
import { tracked } from "@glimmer/tracking";
|
|
4
4
|
import { task, dropTask, lastValue } from "ember-concurrency-decorators";
|
|
5
|
+
import ImportController from "ember-ebau-gwr/controllers/import";
|
|
5
6
|
import Models from "ember-ebau-gwr/models";
|
|
6
7
|
import BuildingEntranceValidations from "ember-ebau-gwr/validations/building-entrance";
|
|
7
8
|
|
|
8
|
-
export default class BuildingEditEntranceEditIndexController extends
|
|
9
|
+
export default class BuildingEditEntranceEditIndexController extends ImportController {
|
|
10
|
+
importModelName = "buildingEntrance";
|
|
9
11
|
Models = Models;
|
|
10
12
|
BuildingEntranceValidations = BuildingEntranceValidations;
|
|
11
13
|
|
|
@@ -22,15 +24,21 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
22
24
|
*fetchBuildingEntrance() {
|
|
23
25
|
try {
|
|
24
26
|
this.errors = [];
|
|
27
|
+
let buildingEntrance;
|
|
25
28
|
|
|
29
|
+
yield this.fetchCalumaData.perform();
|
|
26
30
|
if (this.buildingEntranceAPI.newRecord) {
|
|
27
|
-
|
|
28
|
-
}
|
|
31
|
+
buildingEntrance = this.buildingEntranceAPI.newRecord;
|
|
32
|
+
} else {
|
|
33
|
+
buildingEntrance = yield this.buildingEntranceAPI.getFromCacheOrApi(
|
|
34
|
+
this.model.entranceId,
|
|
35
|
+
this.model.buildingId
|
|
36
|
+
);
|
|
29
37
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
buildingEntrance.EGID = this.model.buildingId;
|
|
39
|
+
}
|
|
40
|
+
this.errors = [];
|
|
41
|
+
return buildingEntrance;
|
|
34
42
|
} catch (error) {
|
|
35
43
|
console.error(error);
|
|
36
44
|
this.notification.danger(
|
|
@@ -39,6 +47,12 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
39
47
|
}
|
|
40
48
|
}
|
|
41
49
|
|
|
50
|
+
@action
|
|
51
|
+
cancelMerge() {
|
|
52
|
+
this.resetImport();
|
|
53
|
+
this.fetchBuildingEntrance.perform();
|
|
54
|
+
}
|
|
55
|
+
|
|
42
56
|
@dropTask
|
|
43
57
|
*saveBuildingEntrance() {
|
|
44
58
|
try {
|
|
@@ -1,28 +1,50 @@
|
|
|
1
1
|
import Controller from "@ember/controller";
|
|
2
2
|
import { action } from "@ember/object";
|
|
3
3
|
import { inject as service } from "@ember/service";
|
|
4
|
+
import { tracked } from "@glimmer/tracking";
|
|
4
5
|
import { task, lastValue } from "ember-concurrency-decorators";
|
|
5
6
|
import { languageOptions } from "ember-ebau-gwr/models/options";
|
|
6
7
|
|
|
7
8
|
export default class BuildingEditEntranceLinkStreetController extends Controller {
|
|
9
|
+
queryParams = ["locality"];
|
|
10
|
+
|
|
8
11
|
@service street;
|
|
9
12
|
@service buildingEntrance;
|
|
13
|
+
@service building;
|
|
10
14
|
@service notification;
|
|
11
15
|
@service intl;
|
|
12
16
|
|
|
17
|
+
@tracked locality = null;
|
|
18
|
+
|
|
13
19
|
get baseQuery() {
|
|
14
20
|
return {
|
|
15
21
|
description: {},
|
|
16
|
-
locality: {
|
|
22
|
+
locality: {
|
|
23
|
+
name: {
|
|
24
|
+
nameLong: this.locality,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
17
27
|
};
|
|
18
28
|
}
|
|
19
29
|
|
|
20
30
|
get backRoute() {
|
|
31
|
+
if (this.model.buildingId === "new") {
|
|
32
|
+
return "building.new";
|
|
33
|
+
}
|
|
34
|
+
|
|
21
35
|
return `building.edit.entrance.${
|
|
22
36
|
this.buildingEntrance.newRecord ? "new" : "edit.index"
|
|
23
37
|
}`;
|
|
24
38
|
}
|
|
25
39
|
|
|
40
|
+
get backRouteLabel() {
|
|
41
|
+
return this.intl.t(
|
|
42
|
+
`ember-gwr.buildingEntrance.${
|
|
43
|
+
this.model.buildingId === "new" ? "backToBuilding" : "backToEntrance"
|
|
44
|
+
}`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
26
48
|
@lastValue("search") searchResults;
|
|
27
49
|
@task
|
|
28
50
|
*search(query) {
|
|
@@ -40,9 +62,11 @@ export default class BuildingEditEntranceLinkStreetController extends Controller
|
|
|
40
62
|
@action
|
|
41
63
|
async setStreet(street) {
|
|
42
64
|
try {
|
|
43
|
-
|
|
65
|
+
// check whether street is being set from new entrance form or new building form
|
|
66
|
+
if (this.buildingEntrance.newRecord && this.model.buildingId !== "new") {
|
|
44
67
|
this.buildingEntrance.newRecord.street = street;
|
|
45
|
-
|
|
68
|
+
} else if (this.building.newRecord) {
|
|
69
|
+
this.building.newRecord.building.buildingEntrance.street = street;
|
|
46
70
|
} else {
|
|
47
71
|
const entrance = await this.buildingEntrance.getFromCacheOrApi(
|
|
48
72
|
this.model.entranceId,
|
|
@@ -54,15 +78,15 @@ export default class BuildingEditEntranceLinkStreetController extends Controller
|
|
|
54
78
|
entrance.EGAID,
|
|
55
79
|
street
|
|
56
80
|
);
|
|
57
|
-
this.transitionToRoute("building.edit.entrance.edit.index");
|
|
58
81
|
}
|
|
82
|
+
this.transitionToRoute(this.backRoute);
|
|
59
83
|
this.notification.success(
|
|
60
|
-
this.intl.t("ember-gwr.
|
|
84
|
+
this.intl.t("ember-gwr.components.linkStreet.linkSuccess")
|
|
61
85
|
);
|
|
62
86
|
} catch (error) {
|
|
63
87
|
console.error(error);
|
|
64
88
|
this.notification.danger(
|
|
65
|
-
this.intl.t("ember-gwr.
|
|
89
|
+
this.intl.t("ember-gwr.components.linkStreet.linkError")
|
|
66
90
|
);
|
|
67
91
|
}
|
|
68
92
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import Controller from "@ember/controller";
|
|
2
2
|
import { action } from "@ember/object";
|
|
3
3
|
import { inject as service } from "@ember/service";
|
|
4
|
-
import { task } from "ember-concurrency-decorators";
|
|
4
|
+
import { lastValue, task } from "ember-concurrency-decorators";
|
|
5
|
+
import BuildingEntrance from "ember-ebau-gwr/models/building-entrance";
|
|
5
6
|
|
|
6
7
|
export default class BuildingEntrancesIndexController extends Controller {
|
|
8
|
+
BuildingEntrance = BuildingEntrance;
|
|
9
|
+
|
|
7
10
|
@service building;
|
|
8
11
|
@service buildingEntrance;
|
|
9
12
|
@service intl;
|
|
10
13
|
@service notification;
|
|
11
14
|
|
|
15
|
+
@lastValue("fetchEntrances") entrances;
|
|
12
16
|
@task
|
|
13
17
|
*fetchEntrances() {
|
|
14
18
|
try {
|
|
@@ -27,10 +31,22 @@ export default class BuildingEntrancesIndexController extends Controller {
|
|
|
27
31
|
try {
|
|
28
32
|
await this.buildingEntrance.deactivate(EDID, this.model);
|
|
29
33
|
await this.fetchEntrances.perform();
|
|
34
|
+
this.notification.success(
|
|
35
|
+
this.intl.t("ember-gwr.building.entrances.removeLinkSuccess")
|
|
36
|
+
);
|
|
30
37
|
} catch (error) {
|
|
31
38
|
console.error(error);
|
|
39
|
+
// Check if error occurred due to active dwellings attached to the
|
|
40
|
+
// building entrance. TODO: find a way to check for active dwellings
|
|
41
|
+
// before executing the request
|
|
32
42
|
this.notification.danger(
|
|
33
|
-
this.intl.t(
|
|
43
|
+
this.intl.t(
|
|
44
|
+
`ember-gwr.${
|
|
45
|
+
error[0] === this.BuildingEntrance.DEACTIVATION_ERROR
|
|
46
|
+
? "building.entrances.attachedDwellingsError"
|
|
47
|
+
: "linkedBuildings.removeLinkError"
|
|
48
|
+
}`
|
|
49
|
+
)
|
|
34
50
|
);
|
|
35
51
|
}
|
|
36
52
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import Controller from "@ember/controller";
|
|
2
1
|
import { action } from "@ember/object";
|
|
3
2
|
import { inject as service } from "@ember/service";
|
|
4
3
|
import { tracked } from "@glimmer/tracking";
|
|
5
4
|
import { task, dropTask, lastValue } from "ember-concurrency-decorators";
|
|
5
|
+
import ImportController from "ember-ebau-gwr/controllers/import";
|
|
6
6
|
import Models from "ember-ebau-gwr/models";
|
|
7
|
-
import
|
|
7
|
+
import Building from "ember-ebau-gwr/models/building";
|
|
8
|
+
import { buildingWorkValidation } from "ember-ebau-gwr/validations/building-work";
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
NOT_USABLE = 1005;
|
|
11
|
-
|
|
12
|
-
export default class BuildingFormController extends Controller {
|
|
10
|
+
export default class BuildingFormController extends ImportController {
|
|
13
11
|
Models = Models;
|
|
14
|
-
BuildingWorkValidations =
|
|
12
|
+
BuildingWorkValidations = buildingWorkValidation(false);
|
|
13
|
+
|
|
14
|
+
importModelName = "building";
|
|
15
15
|
|
|
16
16
|
@service constructionProject;
|
|
17
17
|
@service("building") buildingAPI;
|
|
18
|
+
@service dwelling;
|
|
18
19
|
@service intl;
|
|
19
20
|
@service notification;
|
|
20
21
|
|
|
@@ -36,16 +37,18 @@ export default class BuildingFormController extends Controller {
|
|
|
36
37
|
*fetchBuildingWork() {
|
|
37
38
|
try {
|
|
38
39
|
this.errors = [];
|
|
39
|
-
|
|
40
|
+
this.fetchCalumaData.perform();
|
|
40
41
|
|
|
41
42
|
if (this.model.buildingWork?.isNew) {
|
|
42
|
-
return this.model.buildingWork;
|
|
43
|
+
return this.buildingAPI.newRecord ?? this.model.buildingWork;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
const project = yield this.constructionProject.getFromCacheOrApi(
|
|
46
47
|
this.model.projectId
|
|
47
48
|
);
|
|
48
49
|
|
|
50
|
+
yield this.fetchBuilding.perform();
|
|
51
|
+
|
|
49
52
|
return project.work?.find(
|
|
50
53
|
(buildingWork) =>
|
|
51
54
|
buildingWork.building.EGID === Number(this.model.buildingId)
|
|
@@ -70,30 +73,50 @@ export default class BuildingFormController extends Controller {
|
|
|
70
73
|
return building;
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
@action
|
|
77
|
+
cancelMerge() {
|
|
78
|
+
this.resetImport();
|
|
79
|
+
this.fetchBuildingWork.perform();
|
|
80
|
+
}
|
|
81
|
+
|
|
73
82
|
@dropTask
|
|
74
83
|
*saveBuildingWork() {
|
|
75
84
|
try {
|
|
76
85
|
let EGID = this.buildingWork.building.EGID;
|
|
77
86
|
if (this.buildingWork.isNew) {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
const building = yield this.buildingAPI.create(
|
|
88
|
+
this.model.projectId,
|
|
89
|
+
this.buildingWork
|
|
90
|
+
);
|
|
91
|
+
EGID = building.EGID;
|
|
92
|
+
} else {
|
|
93
|
+
yield this.buildingAPI.update(this.buildingWork.building);
|
|
94
|
+
// Only modify work if of type Umbau (only possible there)
|
|
95
|
+
if (this.buildingWork.kindOfWork === 6002) {
|
|
96
|
+
yield this.constructionProject.modifyWork(
|
|
82
97
|
this.model.projectId,
|
|
83
98
|
this.buildingWork
|
|
84
99
|
);
|
|
85
|
-
} else {
|
|
86
|
-
building = yield this.buildingAPI.create(this.buildingWork.building);
|
|
87
100
|
}
|
|
88
|
-
EGID = building.EGID;
|
|
89
|
-
} else {
|
|
90
|
-
yield this.buildingAPI.update(this.buildingWork.building);
|
|
91
101
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
|
|
103
|
+
// refresh work list
|
|
104
|
+
const project = yield this.constructionProject.get(this.model.projectId);
|
|
105
|
+
|
|
106
|
+
// remove default work
|
|
107
|
+
// Since all works have per default a new building model,
|
|
108
|
+
// we can figure out the default work by filtering `building.isNew`.
|
|
109
|
+
yield Promise.all(
|
|
110
|
+
project.work.map((work) =>
|
|
111
|
+
work.building.isNew
|
|
112
|
+
? this.constructionProject.removeWorkFromProject(
|
|
113
|
+
this.model.projectId,
|
|
114
|
+
work.ARBID
|
|
115
|
+
)
|
|
116
|
+
: work
|
|
117
|
+
)
|
|
96
118
|
);
|
|
119
|
+
|
|
97
120
|
// Clear cache so after transition we fetch the project form api
|
|
98
121
|
this.constructionProject.clearCache(this.model.projectId);
|
|
99
122
|
this.buildingAPI.clearCache(this.model.buildingId);
|
|
@@ -106,20 +129,74 @@ export default class BuildingFormController extends Controller {
|
|
|
106
129
|
}
|
|
107
130
|
}
|
|
108
131
|
|
|
132
|
+
concatStates(states) {
|
|
133
|
+
if (states.length === 1) {
|
|
134
|
+
return this.intl.t(`ember-gwr.lifeCycles.states.${states[0]}`);
|
|
135
|
+
}
|
|
136
|
+
const tail = states.pop();
|
|
137
|
+
return `${states
|
|
138
|
+
.map((state) => this.intl.t(`ember-gwr.lifeCycles.states.${state}`))
|
|
139
|
+
.join(", ")} ${this.intl.t("ember-gwr.general.or")} ${this.intl.t(
|
|
140
|
+
`ember-gwr.lifeCycles.states.${tail}`
|
|
141
|
+
)}`;
|
|
142
|
+
}
|
|
143
|
+
|
|
109
144
|
@task
|
|
110
|
-
*transitionState(currentStatus, newStatus) {
|
|
145
|
+
*transitionState(currentStatus, newStatus, isCascading) {
|
|
111
146
|
try {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
147
|
+
const transition =
|
|
148
|
+
Building.buildingTransitionMapping[currentStatus][newStatus];
|
|
149
|
+
|
|
150
|
+
// reload in case linked objects have been updated
|
|
151
|
+
const building = yield this.buildingAPI.get(this.model.buildingId);
|
|
152
|
+
this.building.buildingEntrance = building.buildingEntrance;
|
|
153
|
+
|
|
154
|
+
// update buildingWork with building modified by changeset
|
|
155
|
+
this.buildingWork.building = this.building;
|
|
156
|
+
|
|
157
|
+
// execute dry-run, throws error if requirements don't hold
|
|
158
|
+
yield this.buildingAPI[transition](
|
|
159
|
+
transition,
|
|
160
|
+
2,
|
|
161
|
+
true,
|
|
162
|
+
this.buildingWork
|
|
116
163
|
);
|
|
164
|
+
|
|
165
|
+
// execute transition(s)
|
|
166
|
+
// cascade level:
|
|
167
|
+
// 2: execute transition on linked dwellings
|
|
168
|
+
// 1: only perform transition on building
|
|
169
|
+
yield this.buildingAPI[transition](
|
|
170
|
+
transition,
|
|
171
|
+
isCascading ? 2 : 1,
|
|
172
|
+
false,
|
|
173
|
+
this.buildingWork
|
|
174
|
+
);
|
|
175
|
+
|
|
117
176
|
yield this.buildingAPI.clearCache(this.model.buildingId);
|
|
118
177
|
this.fetchBuilding.perform(); // reload for errors;
|
|
119
178
|
this.notification.success(this.intl.t("ember-gwr.building.saveSuccess"));
|
|
120
179
|
} catch (error) {
|
|
121
180
|
console.error(error);
|
|
122
181
|
this.notification.danger(this.intl.t("ember-gwr.building.saveError"));
|
|
182
|
+
|
|
183
|
+
if (error.isLifeCycleError) {
|
|
184
|
+
const errorType = error.dwellingId
|
|
185
|
+
? "statusErrorDwelling"
|
|
186
|
+
: "statusErrorBuilding";
|
|
187
|
+
throw [
|
|
188
|
+
this.intl.t(`ember-gwr.lifeCycles.${errorType}`, {
|
|
189
|
+
dwellingId: error.dwellingId,
|
|
190
|
+
buildingId: error.buildingId,
|
|
191
|
+
states: this.concatStates(error.states),
|
|
192
|
+
href: error.dwellingId
|
|
193
|
+
? `/${this.model.instanceId}/${this.model.projectId}/building/${error.buildingId}/dwelling/${error.dwellingId}`
|
|
194
|
+
: `/${this.model.instanceId}/${this.model.projectId}/building/${error.buildingId}/form`,
|
|
195
|
+
htmlSafe: true,
|
|
196
|
+
}),
|
|
197
|
+
];
|
|
198
|
+
}
|
|
199
|
+
|
|
123
200
|
throw error;
|
|
124
201
|
}
|
|
125
202
|
}
|
|
@@ -147,4 +224,9 @@ export default class BuildingFormController extends Controller {
|
|
|
147
224
|
getCorrectionParameters(newStatus) {
|
|
148
225
|
return this.buildingAPI.getCorrectionParameters(newStatus);
|
|
149
226
|
}
|
|
227
|
+
|
|
228
|
+
@action
|
|
229
|
+
getChangeHint(currentStatus, newStatus) {
|
|
230
|
+
return this.buildingAPI.getChangeHint(currentStatus, newStatus);
|
|
231
|
+
}
|
|
150
232
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import Controller from "@ember/controller";
|
|
2
|
+
import { assert } from "@ember/debug";
|
|
3
|
+
import { inject as service } from "@ember/service";
|
|
4
|
+
import { tracked } from "@glimmer/tracking";
|
|
5
|
+
import { task, lastValue } from "ember-concurrency-decorators";
|
|
6
|
+
|
|
7
|
+
const IMPORT_MAP = {
|
|
8
|
+
project: "fetchProject",
|
|
9
|
+
building: "fetchBuildings",
|
|
10
|
+
dwelling: "fetchDwellings",
|
|
11
|
+
buildingEntrance: "fetchEntrances",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default class ImportController extends Controller {
|
|
15
|
+
queryParams = [
|
|
16
|
+
{
|
|
17
|
+
showImport: "import",
|
|
18
|
+
importIndex: "index",
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
@service dataImport;
|
|
23
|
+
|
|
24
|
+
@tracked showImport = false;
|
|
25
|
+
@tracked importIndex = undefined;
|
|
26
|
+
|
|
27
|
+
get import() {
|
|
28
|
+
if (this.showImport) {
|
|
29
|
+
assert("`fetchCalumaData` was never called.", this.importData);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const index = Number(this.importIndex);
|
|
33
|
+
const data =
|
|
34
|
+
Array.isArray(this.importData) && !isNaN(index)
|
|
35
|
+
? this.importData[index]
|
|
36
|
+
: this.importData;
|
|
37
|
+
|
|
38
|
+
return this.showImport
|
|
39
|
+
? {
|
|
40
|
+
index,
|
|
41
|
+
data,
|
|
42
|
+
originalData: this.importData,
|
|
43
|
+
}
|
|
44
|
+
: false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
resetImport() {
|
|
48
|
+
this.showImport = false;
|
|
49
|
+
this.importIndex = null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@lastValue("fetchCalumaData") importData;
|
|
53
|
+
@task
|
|
54
|
+
*fetchCalumaData(...args) {
|
|
55
|
+
// Reset query params to clear singleton state
|
|
56
|
+
this.resetImport();
|
|
57
|
+
assert(
|
|
58
|
+
"Must set `importModelName` to a string.",
|
|
59
|
+
typeof this.importModelName === "string"
|
|
60
|
+
);
|
|
61
|
+
assert(
|
|
62
|
+
"Must set `instanceId` on model.",
|
|
63
|
+
this.model.instanceId !== null && this.model.instanceId !== undefined
|
|
64
|
+
);
|
|
65
|
+
return yield this.dataImport[IMPORT_MAP[this.importModelName]](
|
|
66
|
+
this.model.instanceId,
|
|
67
|
+
...args
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|