ember-ebau-gwr 2.7.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/CHANGELOG.md +39 -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 +83 -0
- package/addon/components/link-street.js +6 -0
- package/addon/components/linked-models.hbs +1 -1
- 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-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 +27 -8
- package/addon/components/model-form/header/actions.hbs +65 -33
- package/addon/components/model-form/header/actions.js +6 -0
- package/addon/components/model-form/header.hbs +4 -2
- package/addon/components/model-form.hbs +6 -5
- package/addon/components/model-form.js +17 -5
- 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/controllers/building/edit/dwelling/edit.js +11 -2
- package/addon/controllers/building/edit/entrance/edit/index.js +12 -2
- 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 +23 -11
- package/addon/controllers/import.js +70 -0
- package/addon/controllers/project/form.js +6 -13
- package/addon/controllers/project.js +1 -0
- package/addon/helpers/is-unset.js +7 -0
- package/addon/models/building-entrance.js +4 -3
- package/addon/models/building.js +73 -74
- package/addon/models/client.js +1 -1
- package/addon/models/construction-project.js +8 -8
- package/addon/models/identification.js +2 -1
- package/addon/routes/building/edit/entrance/edit/index.js +3 -1
- package/addon/routes/building/edit/entrance/edit/link-street.js +8 -1
- package/addon/routes/building/edit/index.js +13 -1
- package/addon/routes/building/new.js +19 -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 +6 -0
- package/addon/services/construction-project.js +0 -6
- package/addon/services/gwr.js +4 -2
- package/addon/templates/building/edit/dwelling/edit.hbs +1 -0
- package/addon/templates/building/edit/entrance/edit/index.hbs +7 -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 +40 -3
- package/addon/templates/project/form.hbs +20 -20
- package/addon/templates/project.hbs +3 -3
- package/addon/validations/building-entrance.js +5 -0
- package/addon/validations/building-work.js +30 -10
- package/addon/validations/realestate-identification.js +1 -1
- package/addon/validations/status/status-project-change.js +1 -1
- package/addon/validations/status/status-project-correction.js +1 -1
- package/addon/xml/templates/construction-project.js +1 -2
- package/app/styles/ember-ebau-gwr.scss +24 -5
- package/package.json +1 -1
- package/translations/building/de.yaml +7 -0
- package/translations/building-entrance/de.yaml +2 -10
- package/translations/construction-project/de.yaml +1 -1
- package/translations/de.yaml +18 -3
- package/translations/dwelling/de.yaml +3 -0
|
@@ -1,16 +1,59 @@
|
|
|
1
1
|
<div class="uk-flex uk-flex-column uk-flex-right">
|
|
2
|
+
<ImportModal
|
|
3
|
+
@visible={{and this.showImportModal @import.originalData.length}}
|
|
4
|
+
@close={{fn (mut this.showImportModal) false}}
|
|
5
|
+
@import={{@import}}
|
|
6
|
+
@modelName={{@modelName}}
|
|
7
|
+
/>
|
|
2
8
|
<div class="uk-flex-inline uk-flex-right uk-flex-middle">
|
|
3
|
-
{{#if (and @
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
{{#if (and @modelHasImport @import)}}
|
|
10
|
+
{{#if (and @import.originalData.length (is-unset @import.index))}}
|
|
11
|
+
<button
|
|
12
|
+
class="uk-button uk-button-default uk-margin-small-right uk-flex-none"
|
|
13
|
+
type="button"
|
|
14
|
+
{{on "click" (fn (mut this.showImportModal) true)}}
|
|
15
|
+
>
|
|
16
|
+
{{t "ember-gwr.components.importModal.selectImportData"}}
|
|
17
|
+
</button>
|
|
18
|
+
{{else}}
|
|
19
|
+
<button
|
|
20
|
+
class="uk-button uk-button-default uk-flex-none
|
|
21
|
+
{{if (is-unset @import.index) "uk-margin-small-right"}}"
|
|
22
|
+
type="button"
|
|
23
|
+
{{on "click" @importAllData}}
|
|
24
|
+
>
|
|
25
|
+
{{t "ember-gwr.components.modelForm.applyAll"}}
|
|
26
|
+
</button>
|
|
27
|
+
{{#if (and @import @import.originalData.length)}}
|
|
28
|
+
<button
|
|
29
|
+
class="uk-button uk-button-default uk-flex-none uk-padding-small uk-padding-remove-vertical uk-margin-small-right"
|
|
30
|
+
type="button"
|
|
31
|
+
>
|
|
32
|
+
<span class="uk-icon" uk-icon="more-vertical"></span>
|
|
33
|
+
</button>
|
|
34
|
+
<div
|
|
35
|
+
uk-dropdown="mode: click; pos: bottom-right; offset: 20"
|
|
36
|
+
class="uk-padding-small"
|
|
37
|
+
>
|
|
38
|
+
<ul
|
|
39
|
+
class="uk-nav uk-dropdown-nav uk-list uk-list-divider uk-list-collapse"
|
|
40
|
+
>
|
|
41
|
+
<li>
|
|
42
|
+
<button
|
|
43
|
+
class="uk-button uk-text-left uk-highlight-hover uk-text-secondary uk-width-1-1 uk-background-default uk-padding-remove"
|
|
44
|
+
type="button"
|
|
45
|
+
{{on "click" (fn (mut this.showImportModal) true)}}
|
|
46
|
+
>
|
|
47
|
+
{{t "ember-gwr.components.importModal.selectImportData"}}
|
|
48
|
+
</button>
|
|
49
|
+
</li>
|
|
50
|
+
</ul>
|
|
51
|
+
</div>
|
|
52
|
+
{{/if}}
|
|
53
|
+
{{/if}}
|
|
11
54
|
<LinkTo
|
|
12
|
-
@query={{hash import=false}}
|
|
13
|
-
class="uk-button uk-button-default uk-margin-small-right"
|
|
55
|
+
@query={{hash import=false index=undefined}}
|
|
56
|
+
class="uk-button uk-button-default uk-flex-none uk-margin-small-right"
|
|
14
57
|
>
|
|
15
58
|
{{t "ember-gwr.components.modelForm.cancelImport"}}
|
|
16
59
|
</LinkTo>
|
|
@@ -18,9 +61,9 @@
|
|
|
18
61
|
{{#let @submit as |Submit|}}
|
|
19
62
|
<Submit />
|
|
20
63
|
{{/let}}
|
|
21
|
-
{{#if (or @
|
|
64
|
+
{{#if (or @modelHasImport @hasStatus)}}
|
|
22
65
|
<button
|
|
23
|
-
class="uk-button uk-button-default uk-padding-small uk-padding-remove-vertical"
|
|
66
|
+
class="uk-button uk-button-default uk-flex-none uk-padding-small uk-padding-remove-vertical"
|
|
24
67
|
type="button"
|
|
25
68
|
>
|
|
26
69
|
<span class="uk-icon" uk-icon="more-vertical"></span>
|
|
@@ -32,28 +75,17 @@
|
|
|
32
75
|
<ul
|
|
33
76
|
class="uk-nav uk-dropdown-nav uk-list uk-list-divider uk-list-collapse"
|
|
34
77
|
>
|
|
35
|
-
{{#if @
|
|
78
|
+
{{#if @modelHasImport}}
|
|
36
79
|
<li>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{{else}}
|
|
47
|
-
<LinkTo
|
|
48
|
-
@disabled={{@import}}
|
|
49
|
-
@query={{hash import=true}}
|
|
50
|
-
class="uk-button uk-text-left uk-highlight-hover
|
|
51
|
-
{{if @import "uk-text-muted" "uk-text-secondary"}}
|
|
52
|
-
uk-width-1-1 uk-background-default uk-padding-remove"
|
|
53
|
-
>
|
|
54
|
-
{{t "ember-gwr.components.modelForm.importFromCaluma"}}
|
|
55
|
-
</LinkTo>
|
|
56
|
-
{{/if}}
|
|
80
|
+
<LinkTo
|
|
81
|
+
@disabled={{@import}}
|
|
82
|
+
@query={{hash import=true}}
|
|
83
|
+
class="uk-button uk-text-left uk-highlight-hover
|
|
84
|
+
{{if @import "uk-text-muted" "uk-text-secondary"}}
|
|
85
|
+
uk-width-1-1 uk-background-default uk-padding-remove"
|
|
86
|
+
>
|
|
87
|
+
{{t "ember-gwr.components.modelForm.importFromCaluma"}}
|
|
88
|
+
</LinkTo>
|
|
57
89
|
</li>
|
|
58
90
|
{{/if}}
|
|
59
91
|
{{#if @hasStatus}}
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
@submit={{@submit}}
|
|
10
10
|
@submitErrors={{@submitErrors}}
|
|
11
11
|
@hasStatus={{and @hasStatus @model (not @model.isNew)}}
|
|
12
|
-
@
|
|
12
|
+
@modelHasImport={{@modelHasImport}}
|
|
13
13
|
@import={{@import}}
|
|
14
14
|
@importAllData={{@importAllData}}
|
|
15
15
|
@openStatus={{fn (mut this.changeStatus) true}}
|
|
16
|
+
@modelName={{@modelName}}
|
|
17
|
+
@translationBase={{@translationBase}}
|
|
16
18
|
/>
|
|
17
19
|
</div>
|
|
18
20
|
{{#if (and @model (not @model.isNew))}}
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
@getCorrectionParameters={{@getCorrectionParameters}}
|
|
50
52
|
@getChangeHint={{@getChangeHint}}
|
|
51
53
|
@modelStatusField={{@modelStatusField}}
|
|
52
|
-
@translationBase={{@translationBase}}
|
|
54
|
+
@translationBase={{or @translationBaseHeader @translationBase}}
|
|
53
55
|
/>
|
|
54
56
|
{{/if}}
|
|
55
57
|
{{/let}}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
f.submit
|
|
12
12
|
type="submit"
|
|
13
13
|
label=(t "ember-gwr.components.modelForm.save")
|
|
14
|
-
disabled=(or this.isSaving @disabled @
|
|
14
|
+
disabled=(or this.isSaving @disabled @import)
|
|
15
15
|
buttonComponent=(component
|
|
16
16
|
"model-form/submit" loading=this.isSaving color="primary"
|
|
17
17
|
)
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
@modelName={{@headerModelName}}
|
|
34
34
|
@modelDescription={{@headerModelDescription}}
|
|
35
35
|
@hasStatus={{@hasStatus}}
|
|
36
|
-
@hasImport={{@hasImport}}
|
|
37
36
|
@import={{@import}}
|
|
37
|
+
@modelHasImport={{this.modelHasImport}}
|
|
38
38
|
@importAllData={{this.importAllData}}
|
|
39
39
|
@modelStatusOptions={{@modelStatusOptions}}
|
|
40
40
|
@nextValidStates={{@nextValidStates}}
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
@getCorrectionParameters={{@getCorrectionParameters}}
|
|
45
45
|
@getChangeHint={{@getChangeHint}}
|
|
46
46
|
@modelStatusField={{@modelStatusField}}
|
|
47
|
-
@
|
|
47
|
+
@translationBaseHeader={{@translationBaseHeader}}
|
|
48
|
+
@translationBase={{@translationBase}}
|
|
48
49
|
@submit={{Submit}}
|
|
49
50
|
@submitErrors={{SubmitErrors}}
|
|
50
51
|
/>
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
(component
|
|
53
54
|
"model-form/field"
|
|
54
55
|
model=f.model
|
|
55
|
-
importData=@
|
|
56
|
+
importData=@import.data
|
|
56
57
|
translationBase=@translationBase
|
|
57
58
|
input=f.input
|
|
58
59
|
registerDiff=this.registerDiff
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
}}
|
|
63
64
|
<div class="uk-flex-inline uk-flex-nowrap uk-flex-top uk-margin-top">
|
|
64
65
|
<Submit class="uk-flex-none" />
|
|
65
|
-
{{#if @
|
|
66
|
+
{{#if @import}}
|
|
66
67
|
<LinkTo
|
|
67
68
|
@query={{hash import=false}}
|
|
68
69
|
class="uk-button uk-button-default uk-flex-none uk-margin-small-left"
|
|
@@ -8,6 +8,7 @@ export default class ModelFormComponent extends Component {
|
|
|
8
8
|
@service router;
|
|
9
9
|
@service notification;
|
|
10
10
|
@service intl;
|
|
11
|
+
@service config;
|
|
11
12
|
|
|
12
13
|
// This array is only used for tracking the still open diffs
|
|
13
14
|
// so we can transition out of the import once the array is empty.
|
|
@@ -18,11 +19,17 @@ export default class ModelFormComponent extends Component {
|
|
|
18
19
|
return this.submit.isRunning || this.args.onSubmit.isRunning;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
get modelHasImport() {
|
|
23
|
+
return this.config.importModels.includes(this.args.headerModelName);
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
finishImport() {
|
|
22
27
|
this.notification.success(
|
|
23
28
|
this.intl.t("ember-gwr.components.modelForm.diff.resolved")
|
|
24
29
|
);
|
|
25
|
-
this.router.transitionTo({
|
|
30
|
+
this.router.transitionTo({
|
|
31
|
+
queryParams: { import: false, index: undefined },
|
|
32
|
+
});
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
@dropTask
|
|
@@ -53,14 +60,19 @@ export default class ModelFormComponent extends Component {
|
|
|
53
60
|
importAllData() {
|
|
54
61
|
// We cannot just `Object.assign` here since the child object like `identification` would
|
|
55
62
|
// not be classes with tracked fields etc. anymore but just pojos. We need to preserve the classes.
|
|
63
|
+
|
|
64
|
+
// TODO: How should we handle the status field, if this is in the imported data this will get
|
|
65
|
+
// set here...
|
|
56
66
|
const deepMerge = (original, objectToApply) => {
|
|
57
67
|
Object.entries(objectToApply).forEach(([key, value]) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
if (value !== null && value !== undefined) {
|
|
69
|
+
typeof value === "object"
|
|
70
|
+
? deepMerge(original[key], objectToApply[key])
|
|
71
|
+
: (original[key] = value);
|
|
72
|
+
}
|
|
61
73
|
});
|
|
62
74
|
};
|
|
63
|
-
deepMerge(this.args.model, this.args.
|
|
75
|
+
deepMerge(this.args.model, this.args.import.data);
|
|
64
76
|
this.finishImport();
|
|
65
77
|
}
|
|
66
78
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<InputField
|
|
17
17
|
@attr={{@attr}}
|
|
18
18
|
@required={{@required}}
|
|
19
|
-
@value={{get @project @attr}}
|
|
19
|
+
@value={{or @value (get @project @attr)}}
|
|
20
20
|
@options={{@options}}
|
|
21
21
|
@noPlaceholder={{@noPlaceholder}}
|
|
22
22
|
@update={{fn (or @update this.updateProjectField) @attr}}
|
|
@@ -1,13 +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
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
|
|
|
@@ -34,6 +35,7 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
34
35
|
try {
|
|
35
36
|
this.errors = [];
|
|
36
37
|
|
|
38
|
+
yield this.fetchCalumaData.perform();
|
|
37
39
|
yield this.fetchEntrances.perform();
|
|
38
40
|
if (this.model.dwelling?.isNew) {
|
|
39
41
|
this.model.dwelling.EDID = this.entrances[0].EDID;
|
|
@@ -46,6 +48,7 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
46
48
|
);
|
|
47
49
|
dwelling.oldEDID = EDID;
|
|
48
50
|
|
|
51
|
+
this.errors = [];
|
|
49
52
|
return dwelling;
|
|
50
53
|
} catch (error) {
|
|
51
54
|
console.error(error);
|
|
@@ -69,6 +72,12 @@ export default class BuildingEditDwellingEditController extends Controller {
|
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
|
|
75
|
+
@action
|
|
76
|
+
cancelMerge() {
|
|
77
|
+
this.resetImport();
|
|
78
|
+
this.fetchDwelling.perform();
|
|
79
|
+
}
|
|
80
|
+
|
|
72
81
|
@dropTask
|
|
73
82
|
*saveDwelling() {
|
|
74
83
|
try {
|
|
@@ -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
|
|
|
@@ -24,6 +26,7 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
24
26
|
this.errors = [];
|
|
25
27
|
let buildingEntrance;
|
|
26
28
|
|
|
29
|
+
yield this.fetchCalumaData.perform();
|
|
27
30
|
if (this.buildingEntranceAPI.newRecord) {
|
|
28
31
|
buildingEntrance = this.buildingEntranceAPI.newRecord;
|
|
29
32
|
} else {
|
|
@@ -34,6 +37,7 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
34
37
|
|
|
35
38
|
buildingEntrance.EGID = this.model.buildingId;
|
|
36
39
|
}
|
|
40
|
+
this.errors = [];
|
|
37
41
|
return buildingEntrance;
|
|
38
42
|
} catch (error) {
|
|
39
43
|
console.error(error);
|
|
@@ -43,6 +47,12 @@ export default class BuildingEditEntranceEditIndexController extends Controller
|
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
@action
|
|
51
|
+
cancelMerge() {
|
|
52
|
+
this.resetImport();
|
|
53
|
+
this.fetchBuildingEntrance.perform();
|
|
54
|
+
}
|
|
55
|
+
|
|
46
56
|
@dropTask
|
|
47
57
|
*saveBuildingEntrance() {
|
|
48
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,15 +1,17 @@
|
|
|
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
|
-
BuildingWorkValidations =
|
|
12
|
+
BuildingWorkValidations = buildingWorkValidation(false);
|
|
13
|
+
|
|
14
|
+
importModelName = "building";
|
|
13
15
|
|
|
14
16
|
@service constructionProject;
|
|
15
17
|
@service("building") buildingAPI;
|
|
@@ -35,16 +37,18 @@ export default class BuildingFormController extends Controller {
|
|
|
35
37
|
*fetchBuildingWork() {
|
|
36
38
|
try {
|
|
37
39
|
this.errors = [];
|
|
38
|
-
|
|
40
|
+
this.fetchCalumaData.perform();
|
|
39
41
|
|
|
40
42
|
if (this.model.buildingWork?.isNew) {
|
|
41
|
-
return this.model.buildingWork;
|
|
43
|
+
return this.buildingAPI.newRecord ?? this.model.buildingWork;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
const project = yield this.constructionProject.getFromCacheOrApi(
|
|
45
47
|
this.model.projectId
|
|
46
48
|
);
|
|
47
49
|
|
|
50
|
+
yield this.fetchBuilding.perform();
|
|
51
|
+
|
|
48
52
|
return project.work?.find(
|
|
49
53
|
(buildingWork) =>
|
|
50
54
|
buildingWork.building.EGID === Number(this.model.buildingId)
|
|
@@ -69,6 +73,12 @@ export default class BuildingFormController extends Controller {
|
|
|
69
73
|
return building;
|
|
70
74
|
}
|
|
71
75
|
|
|
76
|
+
@action
|
|
77
|
+
cancelMerge() {
|
|
78
|
+
this.resetImport();
|
|
79
|
+
this.fetchBuildingWork.perform();
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
@dropTask
|
|
73
83
|
*saveBuildingWork() {
|
|
74
84
|
try {
|
|
@@ -81,12 +91,14 @@ export default class BuildingFormController extends Controller {
|
|
|
81
91
|
EGID = building.EGID;
|
|
82
92
|
} else {
|
|
83
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(
|
|
97
|
+
this.model.projectId,
|
|
98
|
+
this.buildingWork
|
|
99
|
+
);
|
|
100
|
+
}
|
|
84
101
|
}
|
|
85
|
-
yield this.buildingAPI.bindBuildingToConstructionProject(
|
|
86
|
-
this.model.projectId,
|
|
87
|
-
EGID,
|
|
88
|
-
this.buildingWork
|
|
89
|
-
);
|
|
90
102
|
|
|
91
103
|
// refresh work list
|
|
92
104
|
const project = yield this.constructionProject.get(this.model.projectId);
|
|
@@ -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
|
+
}
|