ember-ebau-gwr 4.0.7 → 5.0.2
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/CHANGELOG.md +312 -299
- package/README.md +25 -8
- package/addon/components/building-preview.hbs +53 -0
- package/addon/components/housing-stat-link.hbs +8 -0
- package/addon/components/import-modal/building-data.hbs +1 -55
- package/addon/components/import-modal/dwelling-data.hbs +3 -3
- package/addon/components/import-modal/entrance-data.hbs +1 -1
- package/addon/components/import-modal.hbs +1 -4
- package/addon/components/link-building-modal.hbs +38 -24
- package/addon/components/link-building-modal.js +13 -5
- package/addon/components/link-street.hbs +33 -31
- package/addon/components/linked-models.hbs +13 -6
- package/addon/components/linked-projects.hbs +8 -6
- package/addon/components/linked-projects.js +13 -0
- package/addon/components/loading.hbs +3 -0
- package/addon/components/login-modal.hbs +86 -68
- package/addon/components/model-errors/error-indicator.hbs +1 -2
- package/addon/components/model-errors/header.hbs +6 -2
- package/addon/components/model-errors/list.hbs +13 -4
- package/addon/components/model-errors/skeleton-errors.hbs +14 -0
- package/addon/components/model-errors/skeleton.hbs +1 -16
- package/addon/components/model-errors.hbs +14 -16
- package/addon/components/model-form/date.hbs +10 -6
- package/addon/components/model-form/diff.hbs +8 -8
- package/addon/components/model-form/field.hbs +3 -2
- package/addon/components/model-form/field.js +7 -5
- package/addon/components/model-form/header/actions.hbs +25 -22
- package/addon/components/model-form/header/actions.js +6 -3
- package/addon/components/model-form/header/errors.hbs +16 -16
- package/addon/components/model-form/header/status-selector/submit-parameters.hbs +2 -1
- package/addon/components/model-form/header/status-selector.hbs +15 -3
- package/addon/components/model-form/header/status.hbs +2 -1
- package/addon/components/model-form/header.hbs +6 -5
- package/addon/components/model-form/step.hbs +5 -5
- package/addon/components/model-form/submit.hbs +1 -0
- package/addon/components/model-form.hbs +110 -77
- package/addon/components/model-form.js +38 -2
- package/addon/components/model-inview.hbs +2 -7
- package/addon/components/project-landing-page.hbs +26 -0
- package/addon/components/project-nav.hbs +65 -0
- package/addon/components/project-nav.js +27 -0
- package/addon/components/quarterly-closure/card-status.hbs +11 -0
- package/addon/components/quarterly-closure/card-status.js +36 -0
- package/addon/components/quarterly-closure/close-survey-button.hbs +10 -0
- package/addon/components/quarterly-closure/close-survey-button.js +46 -0
- package/addon/components/quarterly-closure/disabled-form-info.hbs +4 -0
- package/addon/components/quarterly-closure/error-list/project-errors.hbs +22 -0
- package/addon/components/quarterly-closure/error-list/project-errors.js +41 -0
- package/addon/components/quarterly-closure/error-list/survey-department-errors.hbs +22 -0
- package/addon/components/quarterly-closure/error-list/survey-department-errors.js +28 -0
- package/addon/components/quarterly-closure/error-list.hbs +4 -0
- package/addon/components/quarterly-closure/status.hbs +8 -0
- package/addon/components/quarterly-closure/status.js +6 -0
- package/addon/components/quarterly-closure/title.hbs +15 -0
- package/addon/components/quarterly-closure/title.js +11 -0
- package/addon/components/quarterly-closure.hbs +9 -0
- package/addon/components/quarterly-closure.js +6 -0
- package/addon/components/search/filters.hbs +128 -106
- package/addon/components/search/filters.js +13 -59
- package/addon/components/search/result-table/head/header.hbs +1 -1
- package/addon/components/search/result-table/head.hbs +1 -1
- package/addon/components/search/result-table/load-more.hbs +5 -0
- package/addon/components/search/result-table/row/field.hbs +1 -1
- package/addon/components/search/result-table/row.hbs +12 -13
- package/addon/components/search/result-table.hbs +3 -2
- package/addon/components/search.hbs +29 -0
- package/addon/components/search.js +96 -0
- package/addon/components/soon-available.hbs +7 -0
- package/addon/components/sub-nav.hbs +5 -8
- package/addon/components/title-card.hbs +28 -0
- package/addon/components/validated-form-error.hbs +4 -0
- package/addon/components/validated-form-error.js +14 -0
- package/addon/controllers/building/edit/dwelling/edit.js +2 -3
- package/addon/controllers/building/edit/entrance/edit/index.js +2 -3
- package/addon/controllers/building/edit/entrance/edit/link-street.js +4 -1
- package/addon/controllers/building/edit/form.js +57 -39
- package/addon/controllers/import.js +8 -64
- package/addon/controllers/project/form.js +3 -4
- package/addon/controllers/project.js +22 -44
- package/addon/controllers/search-building.js +39 -14
- package/addon/controllers/search-project.js +24 -19
- package/addon/helpers/current-quarter.js +8 -0
- package/addon/helpers/current-route-is-not.js +7 -0
- package/addon/helpers/current-route-is.js +15 -0
- package/addon/helpers/is-set.js +9 -0
- package/addon/helpers/is-unset.js +4 -4
- package/addon/helpers/show-model-field.js +4 -4
- package/addon/models/check-construction-project-response.js +20 -0
- package/addon/models/check-survey-department-response.js +20 -0
- package/addon/models/quarterly-closure-status.js +52 -0
- package/addon/modifiers/in-viewport.js +14 -0
- package/addon/modifiers/inverse-background.js +21 -0
- package/addon/resources/import.js +69 -0
- package/addon/routes/building/edit.js +1 -1
- package/addon/routes/building/new.js +1 -1
- package/addon/routes/building.js +7 -2
- package/addon/routes/global-landing-page.js +9 -0
- package/addon/routes/project/errors.js +1 -1
- package/addon/routes/project/form.js +1 -1
- package/addon/routes/project/new.js +1 -1
- package/addon/routes/project.js +1 -1
- package/addon/routes/quarterly-closure.js +3 -0
- package/addon/routes/search-building.js +7 -2
- package/addon/routes.js +7 -3
- package/addon/services/auth-fetch.js +6 -7
- package/addon/services/construction-project.js +10 -0
- package/addon/services/gwr.js +19 -7
- package/addon/services/quarterly-closure.js +147 -0
- package/addon/templates/building/edit/dwelling/edit.hbs +22 -19
- package/addon/templates/building/edit/dwelling/new.hbs +1 -1
- package/addon/templates/building/edit/dwelling.hbs +1 -1
- package/addon/templates/building/edit/dwellings.hbs +3 -4
- package/addon/templates/building/edit/entrance/edit/index.hbs +32 -18
- package/addon/templates/building/edit/entrance/edit/link-street.hbs +79 -75
- package/addon/templates/building/edit/entrance/edit.hbs +1 -1
- package/addon/templates/building/edit/entrance/new.hbs +1 -1
- package/addon/templates/building/edit/entrance.hbs +6 -5
- package/addon/templates/building/edit/entrances.hbs +4 -6
- package/addon/templates/building/edit/form.hbs +127 -112
- package/addon/templates/building/edit/index.hbs +1 -1
- package/addon/templates/building/edit.hbs +33 -23
- package/addon/templates/building.hbs +1 -1
- package/addon/templates/global-landing-page.hbs +34 -0
- package/addon/templates/project/errors.hbs +116 -109
- package/addon/templates/project/form.hbs +96 -63
- package/addon/templates/project/index.hbs +0 -1
- package/addon/templates/project/linked-buildings.hbs +7 -10
- package/addon/templates/project.hbs +12 -73
- package/addon/templates/quarterly-closure.hbs +1 -0
- package/addon/templates/search-building.hbs +202 -134
- package/addon/templates/search-project.hbs +98 -85
- package/addon/validations/building-work.js +106 -97
- package/addon/validations/extended-search-fields.js +27 -0
- package/addon/validations/realestate-identification.js +1 -0
- package/addon/xml/helpers.js +3 -0
- package/addon/xml/templates/building.js +1 -1
- package/addon/xml/templates/construction-project.js +1 -1
- package/app/styles/ember-ebau-gwr.scss +19 -0
- package/config/environment.js +4 -0
- package/config/icons.js +15 -0
- package/package.json +19 -15
- package/translations/de.yaml +29 -26
- package/translations/fr.yaml +11 -19
- package/translations/quarterly-closure/de.yaml +59 -0
- package/translations/validation-errors/de.yaml +37 -0
- package/addon/components/landing-page.hbs +0 -24
- package/addon/components/project-form/checkbox.hbs +0 -11
- package/addon/components/project-form/checkbox.js +0 -9
- package/addon/components/project-form/date.hbs +0 -10
- package/addon/components/project-form/diff.hbs +0 -43
- package/addon/components/project-form/diff.js +0 -18
- package/addon/components/project-form/field.hbs +0 -32
- package/addon/components/project-form/field.js +0 -59
- package/addon/components/project-form/input.hbs +0 -7
- package/addon/components/project-form/label.hbs +0 -17
- package/addon/components/project-form/select.hbs +0 -17
- package/addon/components/project-form/textarea.hbs +0 -7
- package/addon/components/project-form.hbs +0 -19
- package/addon/components/project-form.js +0 -14
- package/addon/components/sub-nav.js +0 -18
- package/addon/services/import-state.js +0 -10
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<UkFlex @horizontal="center">
|
|
2
|
+
{{#let
|
|
3
|
+
(if
|
|
4
|
+
@model
|
|
5
|
+
(component "link-to" route=@route model=@model)
|
|
6
|
+
(component "link-to" route=@route)
|
|
7
|
+
)
|
|
8
|
+
as |Link|
|
|
9
|
+
}}
|
|
10
|
+
<Link
|
|
11
|
+
class="uk-button uk-button-default uk-width-medium uk-height-medium uk-flex uk-flex-middle uk-flex-column ember-ebau-gwr-title-card"
|
|
12
|
+
...attributes
|
|
13
|
+
>
|
|
14
|
+
<div class="title-card-content">
|
|
15
|
+
<FaIcon
|
|
16
|
+
@icon={{or @icon.name @icon}}
|
|
17
|
+
@prefix={{@icon.prefix}}
|
|
18
|
+
@fixedWidth={{true}}
|
|
19
|
+
@size="4x"
|
|
20
|
+
/>
|
|
21
|
+
<div class="title-card-text">{{@title}}</div>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="title-card-footer uk-margin">
|
|
24
|
+
{{yield to="footer"}}
|
|
25
|
+
</div>
|
|
26
|
+
</Link>
|
|
27
|
+
{{/let}}
|
|
28
|
+
</UkFlex>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { inject as service } from "@ember/service";
|
|
2
|
+
import Component from "@glimmer/component";
|
|
3
|
+
|
|
4
|
+
export default class ValidatedFormErrorComponent extends Component {
|
|
5
|
+
@service intl;
|
|
6
|
+
|
|
7
|
+
get errorString() {
|
|
8
|
+
return this.args.errors
|
|
9
|
+
?.map((error) =>
|
|
10
|
+
this.intl.t(`ember-gwr.validation-errors.${error.type}`, error.context)
|
|
11
|
+
)
|
|
12
|
+
.join(", ");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -8,7 +8,6 @@ import Dwelling from "ember-ebau-gwr/models/dwelling";
|
|
|
8
8
|
import DwellingValidations from "ember-ebau-gwr/validations/dwelling";
|
|
9
9
|
|
|
10
10
|
export default class BuildingEditDwellingEditController extends ImportController {
|
|
11
|
-
importModelName = "dwelling";
|
|
12
11
|
Models = Models;
|
|
13
12
|
DwellingValidations = DwellingValidations;
|
|
14
13
|
|
|
@@ -18,6 +17,7 @@ export default class BuildingEditDwellingEditController extends ImportController
|
|
|
18
17
|
@service intl;
|
|
19
18
|
@service notification;
|
|
20
19
|
@service router;
|
|
20
|
+
@service quarterlyClosure;
|
|
21
21
|
|
|
22
22
|
@tracked errors;
|
|
23
23
|
|
|
@@ -36,7 +36,6 @@ export default class BuildingEditDwellingEditController extends ImportController
|
|
|
36
36
|
try {
|
|
37
37
|
this.errors = [];
|
|
38
38
|
|
|
39
|
-
yield this.fetchCalumaData.perform();
|
|
40
39
|
yield this.fetchEntrances.perform();
|
|
41
40
|
if (this.model.dwelling?.isNew) {
|
|
42
41
|
this.model.dwelling.EDID = this.entrances[0].EDID;
|
|
@@ -84,7 +83,7 @@ export default class BuildingEditDwellingEditController extends ImportController
|
|
|
84
83
|
|
|
85
84
|
@action
|
|
86
85
|
cancelMerge() {
|
|
87
|
-
this.
|
|
86
|
+
this.resetImportQueryParams();
|
|
88
87
|
this.fetchDwelling.perform();
|
|
89
88
|
}
|
|
90
89
|
|
|
@@ -7,7 +7,6 @@ import Models from "ember-ebau-gwr/models";
|
|
|
7
7
|
import BuildingEntranceValidations from "ember-ebau-gwr/validations/building-entrance";
|
|
8
8
|
|
|
9
9
|
export default class BuildingEditEntranceEditIndexController extends ImportController {
|
|
10
|
-
importModelName = "buildingEntrance";
|
|
11
10
|
Models = Models;
|
|
12
11
|
BuildingEntranceValidations = BuildingEntranceValidations;
|
|
13
12
|
|
|
@@ -17,6 +16,7 @@ export default class BuildingEditEntranceEditIndexController extends ImportContr
|
|
|
17
16
|
@service notification;
|
|
18
17
|
@service router;
|
|
19
18
|
@service config;
|
|
19
|
+
@service quarterlyClosure;
|
|
20
20
|
|
|
21
21
|
@tracked errors;
|
|
22
22
|
|
|
@@ -25,7 +25,6 @@ export default class BuildingEditEntranceEditIndexController extends ImportContr
|
|
|
25
25
|
*fetchBuildingEntrance() {
|
|
26
26
|
try {
|
|
27
27
|
this.errors = [];
|
|
28
|
-
yield this.fetchCalumaData.perform();
|
|
29
28
|
if (this.model.buildingEntrance?.isNew) {
|
|
30
29
|
return this.model.buildingEntrance;
|
|
31
30
|
}
|
|
@@ -46,7 +45,7 @@ export default class BuildingEditEntranceEditIndexController extends ImportContr
|
|
|
46
45
|
|
|
47
46
|
@action
|
|
48
47
|
cancelMerge() {
|
|
49
|
-
this.
|
|
48
|
+
this.resetImportQueryParams();
|
|
50
49
|
this.fetchBuildingEntrance.perform();
|
|
51
50
|
}
|
|
52
51
|
|
|
@@ -23,7 +23,9 @@ export default class BuildingEditEntranceLinkStreetController extends Controller
|
|
|
23
23
|
|
|
24
24
|
get baseQuery() {
|
|
25
25
|
return {
|
|
26
|
-
description: {
|
|
26
|
+
description: {
|
|
27
|
+
descriptionLong: "",
|
|
28
|
+
},
|
|
27
29
|
locality: {
|
|
28
30
|
swissZipCode: this.PLZ4,
|
|
29
31
|
swissZipCodeAddOn: this.PLZ6,
|
|
@@ -31,6 +33,7 @@ export default class BuildingEditEntranceLinkStreetController extends Controller
|
|
|
31
33
|
nameLong: this.locality,
|
|
32
34
|
},
|
|
33
35
|
},
|
|
36
|
+
language: this.street.language,
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -6,12 +6,11 @@ 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
8
|
import { buildingWorkValidation } from "ember-ebau-gwr/validations/building-work";
|
|
9
|
+
import { trackedFunction } from "ember-resources/util/function";
|
|
9
10
|
|
|
10
11
|
export default class BuildingFormController extends ImportController {
|
|
11
12
|
Models = Models;
|
|
12
13
|
|
|
13
|
-
importModelName = "building";
|
|
14
|
-
|
|
15
14
|
@service constructionProject;
|
|
16
15
|
@service("building") buildingAPI;
|
|
17
16
|
@service dwelling;
|
|
@@ -19,8 +18,15 @@ export default class BuildingFormController extends ImportController {
|
|
|
19
18
|
@service intl;
|
|
20
19
|
@service notification;
|
|
21
20
|
@service router;
|
|
21
|
+
@service quarterlyClosure;
|
|
22
|
+
|
|
23
|
+
@tracked BuildingWorkValidations = trackedFunction(this, () => {
|
|
24
|
+
return buildingWorkValidation({
|
|
25
|
+
isNew: this.model.buildingWork?.isNew,
|
|
26
|
+
validateOnlyBuilding: this.hasNoProject,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
22
29
|
|
|
23
|
-
@tracked BuildingWorkValidations;
|
|
24
30
|
@tracked errors;
|
|
25
31
|
|
|
26
32
|
get buildingStatusOptions() {
|
|
@@ -34,17 +40,25 @@ export default class BuildingFormController extends ImportController {
|
|
|
34
40
|
return states;
|
|
35
41
|
}
|
|
36
42
|
|
|
43
|
+
get hasNoProject() {
|
|
44
|
+
return !this.model.projectId;
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
@lastValue("fetchBuildingWork") buildingWork;
|
|
38
48
|
@task
|
|
39
49
|
*fetchBuildingWork() {
|
|
40
50
|
try {
|
|
41
51
|
this.errors = [];
|
|
42
|
-
|
|
43
|
-
this.BuildingWorkValidations = buildingWorkValidation(
|
|
44
|
-
this.model.buildingWork?.isNew
|
|
45
|
-
);
|
|
52
|
+
|
|
46
53
|
yield this.fetchBuilding.perform();
|
|
47
54
|
|
|
55
|
+
// If the edit view is accessed from the global search,
|
|
56
|
+
// we dont have a buildingWork. In this case we just return
|
|
57
|
+
// a mock building work.
|
|
58
|
+
if (this.hasNoProject) {
|
|
59
|
+
return { building: this.building };
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
if (this.model.buildingWork?.isNew) {
|
|
49
63
|
return this.model.buildingWork;
|
|
50
64
|
}
|
|
@@ -53,8 +67,6 @@ export default class BuildingFormController extends ImportController {
|
|
|
53
67
|
this.model.projectId
|
|
54
68
|
);
|
|
55
69
|
|
|
56
|
-
yield this.fetchBuilding.perform();
|
|
57
|
-
|
|
58
70
|
return project.work?.find(
|
|
59
71
|
(buildingWork) =>
|
|
60
72
|
buildingWork.building.EGID === Number(this.model.buildingId)
|
|
@@ -81,7 +93,7 @@ export default class BuildingFormController extends ImportController {
|
|
|
81
93
|
|
|
82
94
|
@action
|
|
83
95
|
cancelMerge() {
|
|
84
|
-
this.
|
|
96
|
+
this.resetImportQueryParams();
|
|
85
97
|
this.fetchBuildingWork.perform();
|
|
86
98
|
}
|
|
87
99
|
|
|
@@ -89,42 +101,48 @@ export default class BuildingFormController extends ImportController {
|
|
|
89
101
|
*saveBuildingWork() {
|
|
90
102
|
try {
|
|
91
103
|
let EGID = this.buildingWork.building.EGID;
|
|
92
|
-
if (this.
|
|
93
|
-
const building = yield this.buildingAPI.create(
|
|
94
|
-
this.model.projectId,
|
|
95
|
-
this.buildingWork
|
|
96
|
-
);
|
|
97
|
-
EGID = building.EGID;
|
|
98
|
-
} else {
|
|
104
|
+
if (this.hasNoProject) {
|
|
99
105
|
yield this.buildingAPI.update(this.buildingWork.building);
|
|
100
|
-
|
|
101
|
-
if (this.buildingWork.
|
|
102
|
-
yield this.
|
|
106
|
+
} else {
|
|
107
|
+
if (this.buildingWork.isNew) {
|
|
108
|
+
const building = yield this.buildingAPI.create(
|
|
103
109
|
this.model.projectId,
|
|
104
110
|
this.buildingWork
|
|
105
111
|
);
|
|
112
|
+
EGID = building.EGID;
|
|
113
|
+
} else {
|
|
114
|
+
yield this.buildingAPI.update(this.buildingWork.building);
|
|
115
|
+
// Only modify work if of type Umbau (only possible there)
|
|
116
|
+
if (this.buildingWork.kindOfWork === 6002) {
|
|
117
|
+
yield this.constructionProject.modifyWork(
|
|
118
|
+
this.model.projectId,
|
|
119
|
+
this.buildingWork
|
|
120
|
+
);
|
|
121
|
+
}
|
|
106
122
|
}
|
|
107
|
-
}
|
|
108
123
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
// refresh work list
|
|
125
|
+
const project = yield this.constructionProject.get(
|
|
126
|
+
this.model.projectId
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// remove default work
|
|
130
|
+
// Since all works have per default a new building model,
|
|
131
|
+
// we can figure out the default work by filtering `building.isNew`.
|
|
132
|
+
yield Promise.all(
|
|
133
|
+
project.work.map((work) =>
|
|
134
|
+
work.building.isNew
|
|
135
|
+
? this.constructionProject.removeWorkFromProject(
|
|
136
|
+
this.model.projectId,
|
|
137
|
+
work.ARBID
|
|
138
|
+
)
|
|
139
|
+
: work
|
|
140
|
+
)
|
|
141
|
+
);
|
|
125
142
|
|
|
126
|
-
|
|
127
|
-
|
|
143
|
+
// Clear cache so after transition we fetch the project form api
|
|
144
|
+
this.constructionProject.clearCache(this.model.projectId);
|
|
145
|
+
}
|
|
128
146
|
this.buildingAPI.clearCache(this.model.buildingId);
|
|
129
147
|
this.errors = [];
|
|
130
148
|
this.router.transitionTo("building.edit.form", EGID);
|
|
@@ -1,78 +1,22 @@
|
|
|
1
1
|
import Controller from "@ember/controller";
|
|
2
|
-
import { assert } from "@ember/debug";
|
|
3
|
-
import { inject as service } from "@ember/service";
|
|
4
2
|
import { tracked } from "@glimmer/tracking";
|
|
5
|
-
import { task, lastValue } from "ember-concurrency";
|
|
6
|
-
|
|
7
|
-
const IMPORT_MAP = {
|
|
8
|
-
project: "fetchProject",
|
|
9
|
-
building: "fetchBuildings",
|
|
10
|
-
dwelling: "fetchDwellings",
|
|
11
|
-
buildingEntrance: "fetchEntrances",
|
|
12
|
-
};
|
|
13
3
|
|
|
14
4
|
export default class ImportController extends Controller {
|
|
15
|
-
queryParams = [
|
|
16
|
-
{
|
|
17
|
-
showImport: "import",
|
|
18
|
-
importIndex: "index",
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
@service dataImport;
|
|
23
|
-
@service importState;
|
|
5
|
+
queryParams = [{ _showImport: "import" }, { importIndex: "index" }];
|
|
24
6
|
|
|
25
|
-
@tracked
|
|
7
|
+
@tracked _showImport = false;
|
|
26
8
|
@tracked importIndex = undefined;
|
|
27
9
|
|
|
28
|
-
get
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const index = Number(this.importIndex);
|
|
34
|
-
const data =
|
|
35
|
-
Array.isArray(this.importData) && !isNaN(index)
|
|
36
|
-
? this.importData[index]
|
|
37
|
-
: this.importData;
|
|
10
|
+
get showImport() {
|
|
11
|
+
return Boolean(this.model.instanceId && this._showImport);
|
|
12
|
+
}
|
|
38
13
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
index,
|
|
42
|
-
data,
|
|
43
|
-
originalData: this.importData,
|
|
44
|
-
}
|
|
45
|
-
: false;
|
|
14
|
+
get hasInstanceContext() {
|
|
15
|
+
return Boolean(this.model.instanceId);
|
|
46
16
|
}
|
|
47
17
|
|
|
48
|
-
|
|
18
|
+
resetImportQueryParams() {
|
|
49
19
|
this.showImport = false;
|
|
50
20
|
this.importIndex = null;
|
|
51
|
-
this.importState.error = null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@lastValue("fetchCalumaData") importData;
|
|
55
|
-
@task
|
|
56
|
-
*fetchCalumaData(...args) {
|
|
57
|
-
// Reset query params to clear singleton state
|
|
58
|
-
this.resetImport();
|
|
59
|
-
assert(
|
|
60
|
-
"Must set `importModelName` to a string.",
|
|
61
|
-
typeof this.importModelName === "string"
|
|
62
|
-
);
|
|
63
|
-
assert(
|
|
64
|
-
"Must set `instanceId` on model.",
|
|
65
|
-
this.model.instanceId !== null && this.model.instanceId !== undefined
|
|
66
|
-
);
|
|
67
|
-
try {
|
|
68
|
-
return yield this.dataImport[IMPORT_MAP[this.importModelName]](
|
|
69
|
-
this.model.instanceId,
|
|
70
|
-
...args
|
|
71
|
-
);
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error(error);
|
|
74
|
-
this.importState.error = error;
|
|
75
|
-
return error;
|
|
76
|
-
}
|
|
77
21
|
}
|
|
78
22
|
}
|
|
@@ -9,7 +9,6 @@ import Options from "ember-ebau-gwr/models/options";
|
|
|
9
9
|
import ConstructionProjectValidations from "ember-ebau-gwr/validations/construction-project";
|
|
10
10
|
|
|
11
11
|
export default class ProjectFormController extends ImportController {
|
|
12
|
-
importModelName = "project";
|
|
13
12
|
ConstructionProjectValidations = ConstructionProjectValidations;
|
|
14
13
|
kindOfWorkOptions = BuildingWork.kindOfWorkOptions;
|
|
15
14
|
|
|
@@ -22,6 +21,7 @@ export default class ProjectFormController extends ImportController {
|
|
|
22
21
|
@service router;
|
|
23
22
|
@service intl;
|
|
24
23
|
@service notification;
|
|
24
|
+
@service quarterlyClosure;
|
|
25
25
|
|
|
26
26
|
@tracked buildingWork;
|
|
27
27
|
@tracked typeOfConstructionProject;
|
|
@@ -45,7 +45,6 @@ export default class ProjectFormController extends ImportController {
|
|
|
45
45
|
@lastValue("fetchProject") project;
|
|
46
46
|
@task
|
|
47
47
|
*fetchProject() {
|
|
48
|
-
yield this.fetchCalumaData.perform();
|
|
49
48
|
// Add a new default work for new projects so we don't have to
|
|
50
49
|
// validate if the user has attached a work or not.
|
|
51
50
|
if (this.model.project?.isNew && !this.model.project?.work.length) {
|
|
@@ -62,7 +61,7 @@ export default class ProjectFormController extends ImportController {
|
|
|
62
61
|
|
|
63
62
|
@action
|
|
64
63
|
cancelMerge() {
|
|
65
|
-
this.
|
|
64
|
+
this.resetImportQueryParams();
|
|
66
65
|
this.fetchProject.perform();
|
|
67
66
|
}
|
|
68
67
|
|
|
@@ -116,7 +115,7 @@ export default class ProjectFormController extends ImportController {
|
|
|
116
115
|
yield this.constructionProject.update(this.project);
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
this.
|
|
118
|
+
this.resetImportQueryParams();
|
|
120
119
|
this.errors = [];
|
|
121
120
|
this.notification.success(
|
|
122
121
|
this.intl.t("ember-gwr.constructionProject.saveSuccess")
|
|
@@ -1,70 +1,48 @@
|
|
|
1
1
|
import Controller from "@ember/controller";
|
|
2
|
-
import { action } from "@ember/object";
|
|
3
2
|
import { inject as service } from "@ember/service";
|
|
3
|
+
import { tracked } from "@glimmer/tracking";
|
|
4
|
+
import { trackedFunction } from "ember-resources/util/function";
|
|
4
5
|
|
|
5
6
|
export default class ProjectController extends Controller {
|
|
6
7
|
@service router;
|
|
7
|
-
@service store;
|
|
8
8
|
@service config;
|
|
9
|
-
@service constructionProject;
|
|
10
9
|
@service intl;
|
|
10
|
+
@service constructionProject;
|
|
11
|
+
|
|
12
|
+
get activeProjectId() {
|
|
13
|
+
return Number(this.router.externalRouter.currentRoute.params.project_id);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get isLoading() {
|
|
17
|
+
return this.projects.isLoading || this.constructionProject.all.isRunning;
|
|
18
|
+
}
|
|
11
19
|
|
|
12
20
|
get displayLandingPage() {
|
|
13
21
|
return (
|
|
14
|
-
!this.projects.length &&
|
|
22
|
+
!this.projects.value.length &&
|
|
15
23
|
this.router.externalRouter.currentRoute.localName !== "new" &&
|
|
16
24
|
this.router.externalRouter.currentRoute.localName !== "errors"
|
|
17
25
|
);
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return this.intl.t(
|
|
23
|
-
"ember-gwr.linkedBuildings.buildingDisabledForNewProject"
|
|
24
|
-
);
|
|
25
|
-
} else if (
|
|
26
|
-
this.projects.find((project) => project.EPROID === this.activeProject)
|
|
27
|
-
?.typeOfConstructionProject !== 6011
|
|
28
|
-
) {
|
|
29
|
-
return this.intl.t(
|
|
30
|
-
"ember-gwr.linkedBuildings.buildingDisabledForInfrastructure"
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
28
|
+
@tracked projects = trackedFunction(this, async () => {
|
|
29
|
+
await Promise.resolve();
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return this.constructionProject.projects;
|
|
43
|
-
}
|
|
31
|
+
if (!this.model) {
|
|
32
|
+
return [
|
|
33
|
+
await this.constructionProject.getFromCacheOrApi(this.activeProjectId),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
44
36
|
|
|
45
|
-
@action
|
|
46
|
-
async onLoad() {
|
|
47
37
|
// We then use `gwr.projects` in the template to reference this.
|
|
48
38
|
// This is so we can update the table if we add a new project in the subroute /new
|
|
49
39
|
const projects = await this.constructionProject.all.perform(this.model);
|
|
50
40
|
|
|
51
41
|
// Load the first project in the list if none is selected so we always display a project.
|
|
52
|
-
if (
|
|
53
|
-
!["form", "new", "linked-buildings", "errors"].includes(
|
|
54
|
-
this.router.externalRouter.currentRoute.localName
|
|
55
|
-
) &&
|
|
56
|
-
projects.length
|
|
57
|
-
) {
|
|
42
|
+
if (projects.length && this.router.currentRouteName === "project.index") {
|
|
58
43
|
this.router.transitionTo("project.form", projects[0].EPROID);
|
|
59
44
|
}
|
|
60
|
-
}
|
|
61
45
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const link = this.store
|
|
65
|
-
.peekAll("gwr-link")
|
|
66
|
-
.find(({ eproid }) => Number(eproid) === this.activeProject);
|
|
67
|
-
await link.destroyRecord();
|
|
68
|
-
await this.constructionProject.all.perform(this.model);
|
|
69
|
-
}
|
|
46
|
+
return this.constructionProject.projects;
|
|
47
|
+
});
|
|
70
48
|
}
|
|
@@ -6,8 +6,8 @@ import { task, dropTask, lastValue } from "ember-concurrency";
|
|
|
6
6
|
import { periodOfConstructionOptions } from "ember-ebau-gwr/models/options";
|
|
7
7
|
|
|
8
8
|
export default class SearchBuildingController extends Controller {
|
|
9
|
-
@service building;
|
|
10
9
|
@service constructionProject;
|
|
10
|
+
@service building;
|
|
11
11
|
@service street;
|
|
12
12
|
@service intl;
|
|
13
13
|
@service notification;
|
|
@@ -16,20 +16,20 @@ export default class SearchBuildingController extends Controller {
|
|
|
16
16
|
@tracked activeBuilding;
|
|
17
17
|
@tracked errors;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
get baseQuery() {
|
|
20
|
+
return {
|
|
21
|
+
streetLang: this.street?.language,
|
|
22
|
+
municipality: this.building?.municipality,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
console.error(error);
|
|
29
|
-
this.notification.danger(
|
|
30
|
-
this.intl.t("ember-gwr.generalErrors.searchError")
|
|
31
|
-
);
|
|
32
|
-
}
|
|
26
|
+
get periodOfConstructionOptions() {
|
|
27
|
+
return periodOfConstructionOptions.map((option) => ({
|
|
28
|
+
value: option,
|
|
29
|
+
label: this.intl.t(
|
|
30
|
+
`ember-gwr.building.dateOfConstruction.periodOfConstructionOptions.${option}`
|
|
31
|
+
),
|
|
32
|
+
}));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
@dropTask *linkBuilding(EGID, buildingWork) {
|
|
@@ -72,4 +72,29 @@ export default class SearchBuildingController extends Controller {
|
|
|
72
72
|
setActiveBuilding(EGID) {
|
|
73
73
|
this.activeBuilding = EGID;
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
@action
|
|
77
|
+
redirectToBuilding(EGID) {
|
|
78
|
+
this.router.transitionTo("building.edit.form", EGID);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@action
|
|
82
|
+
isCurrentlySelectedBuilding(building) {
|
|
83
|
+
return building.EGID === this.loadBuildingPreview.lastRunning.args[0]?.EGID;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@lastValue("loadBuildingPreview") previewBuilding;
|
|
87
|
+
@task
|
|
88
|
+
*loadBuildingPreview(building, event) {
|
|
89
|
+
try {
|
|
90
|
+
// Stop jump to top of page because of empty href tag
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
return yield this.building.get(building.EGID);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
this.errors = error;
|
|
95
|
+
this.notification.danger(
|
|
96
|
+
this.intl.t("ember-gwr.searchBuilding.previewBuildingError")
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
75
100
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
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";
|
|
5
|
-
import { task, lastValue } from "ember-concurrency";
|
|
6
4
|
import { projectStatusOptions } from "ember-ebau-gwr/models/options";
|
|
7
5
|
|
|
8
6
|
export default class SearchProjectController extends Controller {
|
|
@@ -11,26 +9,33 @@ export default class SearchProjectController extends Controller {
|
|
|
11
9
|
@service store;
|
|
12
10
|
@service router;
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
get baseQuery() {
|
|
13
|
+
return {
|
|
14
|
+
constructionSurveyDeptNumber:
|
|
15
|
+
this.constructionProject.constructionSurveyDeptNumber,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
get projectStatusOptions() {
|
|
20
|
+
return projectStatusOptions.map((option) => ({
|
|
21
|
+
value: option,
|
|
22
|
+
label: this.intl.t(
|
|
23
|
+
`ember-gwr.searchProject.projectStatusOptions.${option}`
|
|
24
|
+
),
|
|
25
|
+
}));
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
@action
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
selectProject(eproid) {
|
|
30
|
+
if (this.model?.id) {
|
|
31
|
+
const link = this.store.createRecord("gwr-link", {
|
|
32
|
+
eproid,
|
|
33
|
+
localId: this.model.id,
|
|
34
|
+
});
|
|
35
|
+
link.save();
|
|
36
|
+
this.router.transitionTo("project.index");
|
|
37
|
+
}
|
|
38
|
+
// If accessed from global view, redirect to the edit view
|
|
39
|
+
this.router.transitionTo("project.form", eproid);
|
|
35
40
|
}
|
|
36
41
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Helper from "@ember/component/helper";
|
|
2
|
+
import { inject as service } from "@ember/service";
|
|
3
|
+
|
|
4
|
+
export default class extends Helper {
|
|
5
|
+
@service router;
|
|
6
|
+
|
|
7
|
+
compute(routes) {
|
|
8
|
+
return routes
|
|
9
|
+
.flat()
|
|
10
|
+
.map((route) => {
|
|
11
|
+
return this.router.currentRouteName.split(".").includes(route);
|
|
12
|
+
})
|
|
13
|
+
.some(Boolean);
|
|
14
|
+
}
|
|
15
|
+
}
|