ember-ebau-gwr 2.7.1 → 3.2.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/release.yml +2 -0
- package/CHANGELOG.md +95 -0
- package/addon/components/back-route.hbs +10 -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 +1 -1
- package/addon/components/link-building-modal.js +2 -0
- package/addon/components/link-street.hbs +105 -0
- package/addon/components/link-street.js +24 -0
- package/addon/components/linked-models.hbs +12 -6
- package/addon/components/linked-models.js +6 -0
- package/addon/components/linked-projects.hbs +1 -1
- package/addon/components/linked-projects.js +6 -0
- package/addon/components/model-errors/error-indicator.hbs +3 -1
- package/addon/components/model-errors/header.hbs +4 -2
- package/addon/components/model-errors.hbs +1 -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 +36 -9
- package/addon/components/model-form/header/actions.hbs +70 -36
- package/addon/components/model-form/header/actions.js +6 -0
- package/addon/components/model-form/header/status-selector/submit-parameters.hbs +1 -1
- package/addon/components/model-form/header/status-selector.hbs +1 -1
- package/addon/components/model-form/header.hbs +4 -2
- package/addon/components/model-form/submit-errors.hbs +41 -23
- package/addon/components/model-form.hbs +6 -5
- package/addon/components/model-form.js +25 -5
- package/addon/components/model-inview.hbs +8 -0
- package/addon/components/model-inview.js +12 -0
- 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 +5 -1
- package/addon/components/search/filters.hbs +0 -5
- package/addon/components/search/filters.js +1 -3
- package/addon/components/sub-nav.hbs +5 -10
- package/addon/controllers/building/edit/dwelling/edit.js +27 -32
- package/addon/controllers/building/edit/dwellings.js +1 -1
- package/addon/controllers/building/edit/entrance/edit/index.js +26 -13
- package/addon/controllers/building/edit/entrance/edit/link-street.js +45 -20
- package/addon/controllers/building/edit/entrances.js +18 -2
- package/addon/controllers/building/edit/form.js +29 -44
- package/addon/controllers/import.js +70 -0
- package/addon/controllers/project/errors.js +25 -29
- package/addon/controllers/project/form.js +35 -48
- package/addon/controllers/project.js +2 -1
- package/addon/helpers/housing-stat-link.js +13 -0
- package/addon/helpers/is-unset.js +7 -0
- package/addon/helpers/show-model-field.js +13 -0
- package/addon/models/address.js +39 -9
- package/addon/models/building-entrance.js +17 -7
- package/addon/models/building.js +74 -75
- package/addon/models/client.js +1 -1
- package/addon/models/construction-project.js +18 -16
- package/addon/models/date-partially-known.js +1 -1
- package/addon/models/dwelling.js +28 -1
- package/addon/models/heating.js +1 -1
- package/addon/models/identification.js +2 -1
- package/addon/models/options.js +251 -1
- package/addon/models/organisation-identification.js +6 -3
- package/addon/models/realestate-identification.js +0 -6
- package/addon/models/street.js +2 -0
- package/addon/models/xml-model.js +18 -7
- package/addon/models.js +2 -1
- package/addon/routes/building/edit/entrance/edit/index.js +0 -2
- package/addon/routes/building/edit/entrance/edit/link-street.js +10 -1
- package/addon/routes/building/edit/entrance/new.js +9 -16
- package/addon/routes/building/edit/index.js +8 -1
- package/addon/routes/building/new.js +10 -1
- package/addon/routes/project/form.js +5 -0
- package/addon/routes/project/new.js +3 -2
- package/addon/services/building-entrance.js +13 -9
- package/addon/services/building.js +195 -193
- package/addon/services/construction-project.js +140 -152
- package/addon/services/gwr.js +47 -2
- package/addon/services/street.js +10 -0
- package/addon/templates/building/edit/dwelling/edit.hbs +29 -6
- package/addon/templates/building/edit/dwellings.hbs +7 -4
- package/addon/templates/building/edit/entrance/edit/index.hbs +49 -84
- package/addon/templates/building/edit/entrance/edit/link-street.hbs +41 -12
- package/addon/templates/building/edit/entrances.hbs +6 -3
- package/addon/templates/building/edit/form.hbs +75 -21
- package/addon/templates/project/errors.hbs +121 -132
- package/addon/templates/project/form.hbs +126 -97
- package/addon/templates/project/linked-buildings.hbs +13 -20
- package/addon/templates/project.hbs +29 -19
- package/addon/templates/search-building.hbs +6 -0
- package/addon/templates/search-project.hbs +6 -0
- package/addon/utils.js +8 -0
- package/addon/validations/building-entrance.js +6 -4
- package/addon/validations/building-work.js +131 -11
- package/addon/validations/construction-project.js +154 -6
- package/addon/validations/coordinates.js +2 -2
- package/addon/validations/dwelling.js +61 -6
- package/addon/validations/realestate-identification.js +9 -9
- package/addon/validations/status/status-project-change.js +1 -1
- package/addon/validations/status/status-project-correction.js +1 -1
- package/addon/validators/range-state.js +27 -0
- package/addon/xml/helpers.js +4 -0
- package/addon/xml/templates/building-entrance.js +0 -14
- package/addon/xml/templates/building.js +0 -6
- package/addon/xml/templates/construction-project.js +2 -9
- package/addon/xml/templates/street.js +1 -7
- package/app/styles/ember-ebau-gwr.scss +32 -5
- package/config/environment.js +3 -0
- package/package.json +2 -2
- package/translations/building/de.yaml +13 -8
- package/translations/building-entrance/de.yaml +4 -10
- package/translations/construction-project/de.yaml +270 -15
- package/translations/de.yaml +46 -13
- package/translations/dwelling/de.yaml +14 -0
- package/translations/locality/de.yaml +2 -0
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
{{#unless this.isHidden}}
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
>
|
|
8
|
-
<span uk-icon="icon: arrow-left"></span>
|
|
9
|
-
{{@backText}}
|
|
10
|
-
</LinkTo>
|
|
11
|
-
{{/if}}
|
|
2
|
+
<BackRoute
|
|
3
|
+
@backRoute={{@backRoute}}
|
|
4
|
+
@backModel={{@backModel}}
|
|
5
|
+
@backText={{@backText}}
|
|
6
|
+
/>
|
|
12
7
|
<UkTab ...attributes as |Tab|>
|
|
13
8
|
{{#each @links as |link|}}
|
|
14
9
|
<Tab.link-item @route={{link.route}} @models={{link.models}}>
|
|
@@ -1,18 +1,20 @@
|
|
|
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
7
|
import Dwelling from "ember-ebau-gwr/models/dwelling";
|
|
8
8
|
import DwellingValidations from "ember-ebau-gwr/validations/dwelling";
|
|
9
9
|
|
|
10
|
-
export default class BuildingEditDwellingEditController extends
|
|
10
|
+
export default class BuildingEditDwellingEditController extends ImportController {
|
|
11
|
+
importModelName = "dwelling";
|
|
11
12
|
Models = Models;
|
|
12
13
|
DwellingValidations = DwellingValidations;
|
|
13
14
|
|
|
14
15
|
@service("dwelling") dwellingAPI;
|
|
15
16
|
@service building;
|
|
17
|
+
@service gwr;
|
|
16
18
|
@service intl;
|
|
17
19
|
@service notification;
|
|
18
20
|
@service router;
|
|
@@ -34,6 +36,7 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
34
36
|
try {
|
|
35
37
|
this.errors = [];
|
|
36
38
|
|
|
39
|
+
yield this.fetchCalumaData.perform();
|
|
37
40
|
yield this.fetchEntrances.perform();
|
|
38
41
|
if (this.model.dwelling?.isNew) {
|
|
39
42
|
this.model.dwelling.EDID = this.entrances[0].EDID;
|
|
@@ -46,6 +49,7 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
46
49
|
);
|
|
47
50
|
dwelling.oldEDID = EDID;
|
|
48
51
|
|
|
52
|
+
this.errors = [];
|
|
49
53
|
return dwelling;
|
|
50
54
|
} catch (error) {
|
|
51
55
|
console.error(error);
|
|
@@ -53,6 +57,15 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
|
|
60
|
+
get entranceOptions() {
|
|
61
|
+
return this.entrances.map((entrance) => ({
|
|
62
|
+
EDID: entrance.EDID,
|
|
63
|
+
label: `${this.intl.t("ember-gwr.buildingEntrance.title", {
|
|
64
|
+
address: entrance.EDID,
|
|
65
|
+
})} - ${entrance.fullAddressText}`,
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
@lastValue("fetchEntrances") entrances;
|
|
57
70
|
@task
|
|
58
71
|
*fetchEntrances() {
|
|
@@ -69,9 +82,16 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
69
82
|
}
|
|
70
83
|
}
|
|
71
84
|
|
|
85
|
+
@action
|
|
86
|
+
cancelMerge() {
|
|
87
|
+
this.resetImport();
|
|
88
|
+
this.fetchDwelling.perform();
|
|
89
|
+
}
|
|
90
|
+
|
|
72
91
|
@dropTask
|
|
73
92
|
*saveDwelling() {
|
|
74
93
|
try {
|
|
94
|
+
this.dwelling.floor = this.dwelling.floorComplete;
|
|
75
95
|
if (this.dwelling.isNew) {
|
|
76
96
|
const dwelling = yield this.dwellingAPI.create(
|
|
77
97
|
this.dwelling,
|
|
@@ -87,6 +107,8 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
87
107
|
);
|
|
88
108
|
}
|
|
89
109
|
}
|
|
110
|
+
// Ensure dwelling list is refreshed
|
|
111
|
+
this.building.clearCache(this.model.buildingId);
|
|
90
112
|
this.errors = [];
|
|
91
113
|
this.notification.success(this.intl.t("ember-gwr.dwelling.saveSuccess"));
|
|
92
114
|
} catch (error) {
|
|
@@ -95,18 +117,6 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
95
117
|
}
|
|
96
118
|
}
|
|
97
119
|
|
|
98
|
-
concatStates(states) {
|
|
99
|
-
if (states.length === 1) {
|
|
100
|
-
return this.intl.t(`ember-gwr.lifeCycles.states.${states[0]}`);
|
|
101
|
-
}
|
|
102
|
-
const tail = states.pop();
|
|
103
|
-
return `${states
|
|
104
|
-
.map((state) => this.intl.t(`ember-gwr.lifeCycles.states.${state}`))
|
|
105
|
-
.join(", ")} ${this.intl.t("ember-gwr.general.or")} ${this.intl.t(
|
|
106
|
-
`ember-gwr.lifeCycles.states.${tail}`
|
|
107
|
-
)}`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
120
|
@task
|
|
111
121
|
*transitionState(currentStatus, newStatus) {
|
|
112
122
|
try {
|
|
@@ -141,24 +151,9 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
141
151
|
console.error(error);
|
|
142
152
|
this.notification.danger(this.intl.t("ember-gwr.dwelling.saveError"));
|
|
143
153
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
: "statusErrorBuilding";
|
|
148
|
-
throw [
|
|
149
|
-
this.intl.t(`ember-gwr.lifeCycles.${errorType}`, {
|
|
150
|
-
dwellingId: error.dwellingId,
|
|
151
|
-
buildingId: error.buildingId,
|
|
152
|
-
states: this.concatStates(error.states),
|
|
153
|
-
href: error.dwellingId
|
|
154
|
-
? `/${this.model.instanceId}/${this.model.projectId}/building/${error.buildingId}/dwelling/${error.dwellingId}`
|
|
155
|
-
: `/${this.model.instanceId}/${this.model.projectId}/building/${error.buildingId}/form`,
|
|
156
|
-
htmlSafe: true,
|
|
157
|
-
}),
|
|
158
|
-
];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
throw error;
|
|
154
|
+
throw error.isLifeCycleError
|
|
155
|
+
? this.gwr.buildLifeCycleError(error, this.model)
|
|
156
|
+
: error;
|
|
162
157
|
}
|
|
163
158
|
}
|
|
164
159
|
|
|
@@ -15,7 +15,7 @@ export default class BuildingEditDwellingsController extends Controller {
|
|
|
15
15
|
const building = yield this.building.getFromCacheOrApi(this.model);
|
|
16
16
|
return building.buildingEntrance.flatMap((entrance) =>
|
|
17
17
|
entrance.dwelling.map((dwelling) => {
|
|
18
|
-
dwelling.
|
|
18
|
+
dwelling.buildingEntrance = entrance;
|
|
19
19
|
return dwelling;
|
|
20
20
|
})
|
|
21
21
|
);
|
|
@@ -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
|
|
|
@@ -14,6 +16,7 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
14
16
|
@service intl;
|
|
15
17
|
@service notification;
|
|
16
18
|
@service router;
|
|
19
|
+
@service config;
|
|
17
20
|
|
|
18
21
|
@tracked errors;
|
|
19
22
|
|
|
@@ -22,18 +25,16 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
22
25
|
*fetchBuildingEntrance() {
|
|
23
26
|
try {
|
|
24
27
|
this.errors = [];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
buildingEntrance = this.buildingEntranceAPI.newRecord;
|
|
29
|
-
} else {
|
|
30
|
-
buildingEntrance = yield this.buildingEntranceAPI.getFromCacheOrApi(
|
|
31
|
-
this.model.entranceId,
|
|
32
|
-
this.model.buildingId
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
buildingEntrance.EGID = this.model.buildingId;
|
|
28
|
+
yield this.fetchCalumaData.perform();
|
|
29
|
+
if (this.model.buildingEntrance?.isNew) {
|
|
30
|
+
return this.model.buildingEntrance;
|
|
36
31
|
}
|
|
32
|
+
const buildingEntrance = yield this.buildingEntranceAPI.getFromCacheOrApi(
|
|
33
|
+
this.model.entranceId,
|
|
34
|
+
this.model.buildingId
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
buildingEntrance.EGID = this.model.buildingId;
|
|
37
38
|
return buildingEntrance;
|
|
38
39
|
} catch (error) {
|
|
39
40
|
console.error(error);
|
|
@@ -43,6 +44,12 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
@action
|
|
48
|
+
cancelMerge() {
|
|
49
|
+
this.resetImport();
|
|
50
|
+
this.fetchBuildingEntrance.perform();
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
@dropTask
|
|
47
54
|
*saveBuildingEntrance() {
|
|
48
55
|
try {
|
|
@@ -61,6 +68,8 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
61
68
|
this.model.buildingId
|
|
62
69
|
);
|
|
63
70
|
}
|
|
71
|
+
// Ensure building entrance list is refreshed
|
|
72
|
+
this.building.clearCache(this.model.buildingId);
|
|
64
73
|
this.errors = [];
|
|
65
74
|
this.notification.success(
|
|
66
75
|
this.intl.t("ember-gwr.buildingEntrance.saveSuccess")
|
|
@@ -72,4 +81,8 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
72
81
|
);
|
|
73
82
|
}
|
|
74
83
|
}
|
|
84
|
+
|
|
85
|
+
get hasNoStreet() {
|
|
86
|
+
return !this.buildingEntrance?.isNew && this.buildingEntrance?.street.isNew;
|
|
87
|
+
}
|
|
75
88
|
}
|
|
@@ -1,28 +1,56 @@
|
|
|
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", "PLZ4", "PLZ6"];
|
|
10
|
+
|
|
8
11
|
@service street;
|
|
9
12
|
@service buildingEntrance;
|
|
13
|
+
@service building;
|
|
10
14
|
@service notification;
|
|
11
15
|
@service intl;
|
|
12
16
|
|
|
17
|
+
// A locality is uniquely described by either
|
|
18
|
+
// locality name + PLZ4 or PLZ4 + PLZ6
|
|
19
|
+
@tracked locality = null;
|
|
20
|
+
@tracked PLZ4 = null;
|
|
21
|
+
@tracked PLZ6 = null;
|
|
22
|
+
|
|
13
23
|
get baseQuery() {
|
|
14
24
|
return {
|
|
15
25
|
description: {},
|
|
16
|
-
locality: {
|
|
26
|
+
locality: {
|
|
27
|
+
swissZipCode: this.PLZ4,
|
|
28
|
+
swissZipCodeAddOn: this.PLZ6,
|
|
29
|
+
name: {
|
|
30
|
+
nameLong: this.locality,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
17
33
|
};
|
|
18
34
|
}
|
|
19
35
|
|
|
20
36
|
get backRoute() {
|
|
37
|
+
if (this.model.buildingId === "new") {
|
|
38
|
+
return "building.new";
|
|
39
|
+
}
|
|
40
|
+
|
|
21
41
|
return `building.edit.entrance.${
|
|
22
|
-
this.buildingEntrance.
|
|
42
|
+
this.buildingEntrance.isNew ? "new" : "edit.index"
|
|
23
43
|
}`;
|
|
24
44
|
}
|
|
25
45
|
|
|
46
|
+
get backRouteLabel() {
|
|
47
|
+
return this.intl.t(
|
|
48
|
+
`ember-gwr.buildingEntrance.${
|
|
49
|
+
this.model.buildingId === "new" ? "backToBuilding" : "backToEntrance"
|
|
50
|
+
}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
26
54
|
@lastValue("search") searchResults;
|
|
27
55
|
@task
|
|
28
56
|
*search(query) {
|
|
@@ -40,29 +68,26 @@ export default class BuildingEditEntranceLinkStreetController extends Controller
|
|
|
40
68
|
@action
|
|
41
69
|
async setStreet(street) {
|
|
42
70
|
try {
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
57
|
-
this.transitionToRoute("building.edit.entrance.edit.index");
|
|
58
|
-
}
|
|
71
|
+
const entrance = await this.buildingEntrance.getFromCacheOrApi(
|
|
72
|
+
this.model.entranceId,
|
|
73
|
+
this.model.buildingId
|
|
74
|
+
);
|
|
75
|
+
entrance.street = street;
|
|
76
|
+
await this.buildingEntrance.setStreet(
|
|
77
|
+
this.model.entranceId,
|
|
78
|
+
this.model.buildingId,
|
|
79
|
+
entrance
|
|
80
|
+
);
|
|
81
|
+
// Ensure building entrance list is updated
|
|
82
|
+
this.building.clearCache(this.model.buildingId);
|
|
83
|
+
this.transitionToRoute(this.backRoute);
|
|
59
84
|
this.notification.success(
|
|
60
|
-
this.intl.t("ember-gwr.
|
|
85
|
+
this.intl.t("ember-gwr.components.linkStreet.linkSuccess")
|
|
61
86
|
);
|
|
62
87
|
} catch (error) {
|
|
63
88
|
console.error(error);
|
|
64
89
|
this.notification.danger(
|
|
65
|
-
this.intl.t("ember-gwr.
|
|
90
|
+
this.intl.t("ember-gwr.components.linkStreet.linkError")
|
|
66
91
|
);
|
|
67
92
|
}
|
|
68
93
|
}
|
|
@@ -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,22 +1,25 @@
|
|
|
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
7
|
import Building from "ember-ebau-gwr/models/building";
|
|
8
|
-
import
|
|
8
|
+
import { buildingWorkValidation } from "ember-ebau-gwr/validations/building-work";
|
|
9
9
|
|
|
10
|
-
export default class BuildingFormController extends
|
|
10
|
+
export default class BuildingFormController extends ImportController {
|
|
11
11
|
Models = Models;
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
importModelName = "building";
|
|
13
14
|
|
|
14
15
|
@service constructionProject;
|
|
15
16
|
@service("building") buildingAPI;
|
|
16
17
|
@service dwelling;
|
|
18
|
+
@service gwr;
|
|
17
19
|
@service intl;
|
|
18
20
|
@service notification;
|
|
19
21
|
|
|
22
|
+
@tracked BuildingWorkValidations;
|
|
20
23
|
@tracked errors;
|
|
21
24
|
|
|
22
25
|
get buildingStatusOptions() {
|
|
@@ -35,6 +38,10 @@ export default class BuildingFormController extends Controller {
|
|
|
35
38
|
*fetchBuildingWork() {
|
|
36
39
|
try {
|
|
37
40
|
this.errors = [];
|
|
41
|
+
this.fetchCalumaData.perform();
|
|
42
|
+
this.BuildingWorkValidations = buildingWorkValidation(
|
|
43
|
+
this.model.buildingWork?.isNew
|
|
44
|
+
);
|
|
38
45
|
yield this.fetchBuilding.perform();
|
|
39
46
|
|
|
40
47
|
if (this.model.buildingWork?.isNew) {
|
|
@@ -45,6 +52,8 @@ export default class BuildingFormController extends Controller {
|
|
|
45
52
|
this.model.projectId
|
|
46
53
|
);
|
|
47
54
|
|
|
55
|
+
yield this.fetchBuilding.perform();
|
|
56
|
+
|
|
48
57
|
return project.work?.find(
|
|
49
58
|
(buildingWork) =>
|
|
50
59
|
buildingWork.building.EGID === Number(this.model.buildingId)
|
|
@@ -69,6 +78,12 @@ export default class BuildingFormController extends Controller {
|
|
|
69
78
|
return building;
|
|
70
79
|
}
|
|
71
80
|
|
|
81
|
+
@action
|
|
82
|
+
cancelMerge() {
|
|
83
|
+
this.resetImport();
|
|
84
|
+
this.fetchBuildingWork.perform();
|
|
85
|
+
}
|
|
86
|
+
|
|
72
87
|
@dropTask
|
|
73
88
|
*saveBuildingWork() {
|
|
74
89
|
try {
|
|
@@ -81,12 +96,14 @@ export default class BuildingFormController extends Controller {
|
|
|
81
96
|
EGID = building.EGID;
|
|
82
97
|
} else {
|
|
83
98
|
yield this.buildingAPI.update(this.buildingWork.building);
|
|
99
|
+
// Only modify work if of type Umbau (only possible there)
|
|
100
|
+
if (this.buildingWork.kindOfWork === 6002) {
|
|
101
|
+
yield this.constructionProject.modifyWork(
|
|
102
|
+
this.model.projectId,
|
|
103
|
+
this.buildingWork
|
|
104
|
+
);
|
|
105
|
+
}
|
|
84
106
|
}
|
|
85
|
-
yield this.buildingAPI.bindBuildingToConstructionProject(
|
|
86
|
-
this.model.projectId,
|
|
87
|
-
EGID,
|
|
88
|
-
this.buildingWork
|
|
89
|
-
);
|
|
90
107
|
|
|
91
108
|
// refresh work list
|
|
92
109
|
const project = yield this.constructionProject.get(this.model.projectId);
|
|
@@ -117,18 +134,6 @@ export default class BuildingFormController extends Controller {
|
|
|
117
134
|
}
|
|
118
135
|
}
|
|
119
136
|
|
|
120
|
-
concatStates(states) {
|
|
121
|
-
if (states.length === 1) {
|
|
122
|
-
return this.intl.t(`ember-gwr.lifeCycles.states.${states[0]}`);
|
|
123
|
-
}
|
|
124
|
-
const tail = states.pop();
|
|
125
|
-
return `${states
|
|
126
|
-
.map((state) => this.intl.t(`ember-gwr.lifeCycles.states.${state}`))
|
|
127
|
-
.join(", ")} ${this.intl.t("ember-gwr.general.or")} ${this.intl.t(
|
|
128
|
-
`ember-gwr.lifeCycles.states.${tail}`
|
|
129
|
-
)}`;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
137
|
@task
|
|
133
138
|
*transitionState(currentStatus, newStatus, isCascading) {
|
|
134
139
|
try {
|
|
@@ -168,24 +173,9 @@ export default class BuildingFormController extends Controller {
|
|
|
168
173
|
console.error(error);
|
|
169
174
|
this.notification.danger(this.intl.t("ember-gwr.building.saveError"));
|
|
170
175
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
: "statusErrorBuilding";
|
|
175
|
-
throw [
|
|
176
|
-
this.intl.t(`ember-gwr.lifeCycles.${errorType}`, {
|
|
177
|
-
dwellingId: error.dwellingId,
|
|
178
|
-
buildingId: error.buildingId,
|
|
179
|
-
states: this.concatStates(error.states),
|
|
180
|
-
href: error.dwellingId
|
|
181
|
-
? `/${this.model.instanceId}/${this.model.projectId}/building/${error.buildingId}/dwelling/${error.dwellingId}`
|
|
182
|
-
: `/${this.model.instanceId}/${this.model.projectId}/building/${error.buildingId}/form`,
|
|
183
|
-
htmlSafe: true,
|
|
184
|
-
}),
|
|
185
|
-
];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
throw error;
|
|
176
|
+
throw error.isLifeCycleError
|
|
177
|
+
? this.gwr.buildLifeCycleError(error, this.model)
|
|
178
|
+
: error;
|
|
189
179
|
}
|
|
190
180
|
}
|
|
191
181
|
|
|
@@ -212,9 +202,4 @@ export default class BuildingFormController extends Controller {
|
|
|
212
202
|
getCorrectionParameters(newStatus) {
|
|
213
203
|
return this.buildingAPI.getCorrectionParameters(newStatus);
|
|
214
204
|
}
|
|
215
|
-
|
|
216
|
-
@action
|
|
217
|
-
getChangeHint(currentStatus, newStatus) {
|
|
218
|
-
return this.buildingAPI.getChangeHint(currentStatus, newStatus);
|
|
219
|
-
}
|
|
220
205
|
}
|
|
@@ -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
|
+
}
|
|
@@ -16,11 +16,6 @@ export default class ProjectErrorsController extends Controller {
|
|
|
16
16
|
@service notification;
|
|
17
17
|
|
|
18
18
|
@tracked projectErrorCount = 0;
|
|
19
|
-
@tracked buildingErrorCount = {};
|
|
20
|
-
@tracked entranceErrorCount = {};
|
|
21
|
-
@tracked dwellingErrorCount = {};
|
|
22
|
-
|
|
23
|
-
@tracked buildings = {};
|
|
24
19
|
|
|
25
20
|
@lastValue("fetchProject") project;
|
|
26
21
|
@restartableTask
|
|
@@ -34,34 +29,36 @@ export default class ProjectErrorsController extends Controller {
|
|
|
34
29
|
return project;
|
|
35
30
|
}
|
|
36
31
|
|
|
32
|
+
get workBuildings() {
|
|
33
|
+
return this.project.work
|
|
34
|
+
.filter((w) => !w.building.isNew)
|
|
35
|
+
.map((w) => w.building);
|
|
36
|
+
}
|
|
37
|
+
|
|
37
38
|
@enqueueTask
|
|
38
39
|
*fetchModel(buildingId) {
|
|
39
40
|
// building response only contains entrances
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
41
|
+
const buildingWithErrors = yield this.building.getFromCacheOrApi(
|
|
42
|
+
buildingId
|
|
43
|
+
);
|
|
44
|
+
const buildingErrorCount = buildingWithErrors.errorList?.length ?? 0;
|
|
45
45
|
|
|
46
46
|
// response contains both entrances and dwellings
|
|
47
47
|
const projectBuilding = this.project.work.find(
|
|
48
48
|
(buildingWork) => buildingWork.building.EGID === buildingId
|
|
49
49
|
).building;
|
|
50
50
|
|
|
51
|
-
const
|
|
51
|
+
const entrancesWithErrors = yield Promise.all(
|
|
52
52
|
projectBuilding.buildingEntrance.map((entrance) =>
|
|
53
53
|
this.buildingEntrance.getFromCacheOrApi(entrance.EDID, buildingId)
|
|
54
54
|
)
|
|
55
55
|
);
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.map((entrance) => entrance.errorList?.length ?? 0)
|
|
61
|
-
.reduce((a, b) => a + b, 0),
|
|
62
|
-
};
|
|
57
|
+
const entranceErrorCount = entrancesWithErrors
|
|
58
|
+
.map((entrance) => entrance.errorList?.length ?? 0)
|
|
59
|
+
.reduce((a, b) => a + b, 0);
|
|
63
60
|
|
|
64
|
-
const
|
|
61
|
+
const dwellingsWithErrors = (yield Promise.all(
|
|
65
62
|
projectBuilding.buildingEntrance.map((entrance) => {
|
|
66
63
|
return Promise.all(
|
|
67
64
|
entrance.dwelling.map((dwelling) =>
|
|
@@ -71,18 +68,17 @@ export default class ProjectErrorsController extends Controller {
|
|
|
71
68
|
})
|
|
72
69
|
)).flat();
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.map((dwelling) => dwelling.errorList?.length ?? 0)
|
|
78
|
-
.reduce((a, b) => a + b, 0),
|
|
79
|
-
};
|
|
71
|
+
const dwellingErrorCount = dwellingsWithErrors
|
|
72
|
+
.map((dwelling) => dwelling.dwelling.errorList?.length ?? 0)
|
|
73
|
+
.reduce((a, b) => a + b, 0);
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
return {
|
|
76
|
+
buildingWithErrors,
|
|
77
|
+
buildingErrorCount,
|
|
78
|
+
entrancesWithErrors,
|
|
79
|
+
entranceErrorCount,
|
|
80
|
+
dwellingsWithErrors,
|
|
81
|
+
dwellingErrorCount,
|
|
84
82
|
};
|
|
85
|
-
|
|
86
|
-
return building;
|
|
87
83
|
}
|
|
88
84
|
}
|