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.
Files changed (116) hide show
  1. package/.github/workflows/release.yml +2 -0
  2. package/CHANGELOG.md +95 -0
  3. package/addon/components/back-route.hbs +10 -0
  4. package/addon/components/import-modal/building-data.hbs +64 -0
  5. package/addon/components/import-modal/dwelling-data.hbs +30 -0
  6. package/addon/components/import-modal/entrance-data.hbs +14 -0
  7. package/addon/components/import-modal.hbs +54 -0
  8. package/addon/components/import-modal.js +6 -0
  9. package/addon/components/link-building-modal.hbs +1 -1
  10. package/addon/components/link-building-modal.js +2 -0
  11. package/addon/components/link-street.hbs +105 -0
  12. package/addon/components/link-street.js +24 -0
  13. package/addon/components/linked-models.hbs +12 -6
  14. package/addon/components/linked-models.js +6 -0
  15. package/addon/components/linked-projects.hbs +1 -1
  16. package/addon/components/linked-projects.js +6 -0
  17. package/addon/components/model-errors/error-indicator.hbs +3 -1
  18. package/addon/components/model-errors/header.hbs +4 -2
  19. package/addon/components/model-errors.hbs +1 -0
  20. package/addon/components/model-form/date.hbs +1 -0
  21. package/addon/components/model-form/date.js +6 -6
  22. package/addon/components/model-form/diff.hbs +40 -27
  23. package/addon/components/model-form/field.hbs +13 -8
  24. package/addon/components/model-form/field.js +36 -9
  25. package/addon/components/model-form/header/actions.hbs +70 -36
  26. package/addon/components/model-form/header/actions.js +6 -0
  27. package/addon/components/model-form/header/status-selector/submit-parameters.hbs +1 -1
  28. package/addon/components/model-form/header/status-selector.hbs +1 -1
  29. package/addon/components/model-form/header.hbs +4 -2
  30. package/addon/components/model-form/submit-errors.hbs +41 -23
  31. package/addon/components/model-form.hbs +6 -5
  32. package/addon/components/model-form.js +25 -5
  33. package/addon/components/model-inview.hbs +8 -0
  34. package/addon/components/model-inview.js +12 -0
  35. package/addon/components/project-form/date.hbs +1 -1
  36. package/addon/components/project-form/field.hbs +1 -1
  37. package/addon/components/project-form/field.js +5 -1
  38. package/addon/components/search/filters.hbs +0 -5
  39. package/addon/components/search/filters.js +1 -3
  40. package/addon/components/sub-nav.hbs +5 -10
  41. package/addon/controllers/building/edit/dwelling/edit.js +27 -32
  42. package/addon/controllers/building/edit/dwellings.js +1 -1
  43. package/addon/controllers/building/edit/entrance/edit/index.js +26 -13
  44. package/addon/controllers/building/edit/entrance/edit/link-street.js +45 -20
  45. package/addon/controllers/building/edit/entrances.js +18 -2
  46. package/addon/controllers/building/edit/form.js +29 -44
  47. package/addon/controllers/import.js +70 -0
  48. package/addon/controllers/project/errors.js +25 -29
  49. package/addon/controllers/project/form.js +35 -48
  50. package/addon/controllers/project.js +2 -1
  51. package/addon/helpers/housing-stat-link.js +13 -0
  52. package/addon/helpers/is-unset.js +7 -0
  53. package/addon/helpers/show-model-field.js +13 -0
  54. package/addon/models/address.js +39 -9
  55. package/addon/models/building-entrance.js +17 -7
  56. package/addon/models/building.js +74 -75
  57. package/addon/models/client.js +1 -1
  58. package/addon/models/construction-project.js +18 -16
  59. package/addon/models/date-partially-known.js +1 -1
  60. package/addon/models/dwelling.js +28 -1
  61. package/addon/models/heating.js +1 -1
  62. package/addon/models/identification.js +2 -1
  63. package/addon/models/options.js +251 -1
  64. package/addon/models/organisation-identification.js +6 -3
  65. package/addon/models/realestate-identification.js +0 -6
  66. package/addon/models/street.js +2 -0
  67. package/addon/models/xml-model.js +18 -7
  68. package/addon/models.js +2 -1
  69. package/addon/routes/building/edit/entrance/edit/index.js +0 -2
  70. package/addon/routes/building/edit/entrance/edit/link-street.js +10 -1
  71. package/addon/routes/building/edit/entrance/new.js +9 -16
  72. package/addon/routes/building/edit/index.js +8 -1
  73. package/addon/routes/building/new.js +10 -1
  74. package/addon/routes/project/form.js +5 -0
  75. package/addon/routes/project/new.js +3 -2
  76. package/addon/services/building-entrance.js +13 -9
  77. package/addon/services/building.js +195 -193
  78. package/addon/services/construction-project.js +140 -152
  79. package/addon/services/gwr.js +47 -2
  80. package/addon/services/street.js +10 -0
  81. package/addon/templates/building/edit/dwelling/edit.hbs +29 -6
  82. package/addon/templates/building/edit/dwellings.hbs +7 -4
  83. package/addon/templates/building/edit/entrance/edit/index.hbs +49 -84
  84. package/addon/templates/building/edit/entrance/edit/link-street.hbs +41 -12
  85. package/addon/templates/building/edit/entrances.hbs +6 -3
  86. package/addon/templates/building/edit/form.hbs +75 -21
  87. package/addon/templates/project/errors.hbs +121 -132
  88. package/addon/templates/project/form.hbs +126 -97
  89. package/addon/templates/project/linked-buildings.hbs +13 -20
  90. package/addon/templates/project.hbs +29 -19
  91. package/addon/templates/search-building.hbs +6 -0
  92. package/addon/templates/search-project.hbs +6 -0
  93. package/addon/utils.js +8 -0
  94. package/addon/validations/building-entrance.js +6 -4
  95. package/addon/validations/building-work.js +131 -11
  96. package/addon/validations/construction-project.js +154 -6
  97. package/addon/validations/coordinates.js +2 -2
  98. package/addon/validations/dwelling.js +61 -6
  99. package/addon/validations/realestate-identification.js +9 -9
  100. package/addon/validations/status/status-project-change.js +1 -1
  101. package/addon/validations/status/status-project-correction.js +1 -1
  102. package/addon/validators/range-state.js +27 -0
  103. package/addon/xml/helpers.js +4 -0
  104. package/addon/xml/templates/building-entrance.js +0 -14
  105. package/addon/xml/templates/building.js +0 -6
  106. package/addon/xml/templates/construction-project.js +2 -9
  107. package/addon/xml/templates/street.js +1 -7
  108. package/app/styles/ember-ebau-gwr.scss +32 -5
  109. package/config/environment.js +3 -0
  110. package/package.json +2 -2
  111. package/translations/building/de.yaml +13 -8
  112. package/translations/building-entrance/de.yaml +4 -10
  113. package/translations/construction-project/de.yaml +270 -15
  114. package/translations/de.yaml +46 -13
  115. package/translations/dwelling/de.yaml +14 -0
  116. package/translations/locality/de.yaml +2 -0
@@ -7,28 +7,30 @@
7
7
  {{if @isInvalid "uk-form-danger"}}
8
8
  {{if @isValid "uk-form-success"}}"
9
9
  >
10
- <div class="uk-margin">
11
- <div
12
- class="uk-flex uk-flex-between uk-flex-bottom uk-margin-small-bottom"
13
- >
14
- <span>
15
- {{t "ember-gwr.components.modelForm.diff.existingData"}}
16
- </span>
17
- <button
18
- type="button"
19
- class="uk-button uk-button-default uk-button-small"
20
- {{on "click" (fn @updateModelField @current)}}
10
+ {{#if @current}}
11
+ <div class="uk-margin">
12
+ <div
13
+ class="uk-flex uk-flex-between uk-flex-bottom uk-margin-small-bottom"
21
14
  >
22
- {{t "ember-gwr.components.modelForm.diff.apply"}}
23
- </button>
15
+ <span>
16
+ {{t "ember-gwr.components.modelForm.diff.existingData"}}
17
+ </span>
18
+ <button
19
+ type="button"
20
+ class="uk-button uk-button-default uk-button-small"
21
+ {{on "click" (fn @updateModelField @current)}}
22
+ >
23
+ {{t "ember-gwr.components.modelForm.diff.apply"}}
24
+ </button>
25
+ </div>
26
+ {{#let
27
+ (component @inputComponent disabled=true value=@current)
28
+ as |InputComponent|
29
+ }}
30
+ <InputComponent disabled />
31
+ {{/let}}
24
32
  </div>
25
- {{#let
26
- (component @inputComponent disabled=true value=@current)
27
- as |InputComponent|
28
- }}
29
- <InputComponent disabled />
30
- {{/let}}
31
- </div>
33
+ {{/if}}
32
34
  <div>
33
35
  <div
34
36
  class="uk-flex uk-flex-between uk-flex-bottom uk-margin-small-bottom"
@@ -36,13 +38,24 @@
36
38
  <span>
37
39
  {{t "ember-gwr.components.modelForm.diff.importData"}}
38
40
  </span>
39
- <button
40
- type="button"
41
- class="uk-button uk-button-default uk-button-small"
42
- {{on "click" (fn @updateModelField this.newValue)}}
43
- >
44
- {{t "ember-gwr.components.modelForm.diff.apply"}}
45
- </button>
41
+ <div>
42
+ <button
43
+ type="button"
44
+ class="uk-button uk-button-primary uk-button-small"
45
+ {{on "click" (fn @updateModelField this.newValue)}}
46
+ >
47
+ {{t "ember-gwr.components.modelForm.diff.apply"}}
48
+ </button>
49
+ {{#unless @current}}
50
+ <button
51
+ type="button"
52
+ class="uk-button uk-button-default uk-button-small"
53
+ {{on "click" (fn @updateModelField)}}
54
+ >
55
+ {{t "ember-gwr.components.modelForm.diff.cancel"}}
56
+ </button>
57
+ {{/unless}}
58
+ </div>
46
59
  </div>
47
60
  {{component
48
61
  @inputComponent
@@ -1,15 +1,20 @@
1
- <div class="{{unless @noMargin "uk-margin"}}">
1
+ <div
2
+ class="{{unless @noMargin "uk-margin"}}"
3
+ {{did-update this.initializeImport @importData @model @attr}}
4
+ >
2
5
  {{#let
3
6
  (component
4
7
  @input
5
- label=(unless @noLabel (t (or @label (concat @translationBase "." @attr))))
8
+ label=(unless
9
+ @noLabel (t (or @label (concat @translationBase "." @attr)))
10
+ )
6
11
  name=@attr
7
12
  inputName=@inputName
8
13
  hint=@hint
9
14
  type=(or @type @inputType)
10
15
  disabled=(or @disabled this.disableInput)
11
16
  required=@required
12
- value=(or @value (get @model @attr))
17
+ value=this.value
13
18
  validateBeforeSubmit=true
14
19
  auto-complete=@auto-complete
15
20
  placeholder=@placeholder
@@ -29,8 +34,8 @@
29
34
  promptIsSelectable=true
30
35
  on-update=(if
31
36
  @on-update
32
- (queue (fn this.updateModelField @attr) @on-update)
33
- (fn this.updateModelField @attr)
37
+ (queue (fn this.updateModelField) @on-update)
38
+ (fn this.updateModelField)
34
39
  )
35
40
  renderComponent=(component
36
41
  this.fieldComponent
@@ -45,9 +50,9 @@
45
50
  {{#if this.showDiff}}
46
51
  <ModelForm::Diff
47
52
  @inputComponent={{InputComponent}}
48
- @current={{get @model @attr}}
49
- @new={{get @importData @attr}}
50
- @updateModelField={{fn this.updateModelField @attr}}
53
+ @current={{this.value}}
54
+ @new={{this.importValue}}
55
+ @updateModelField={{fn this.updateModelField}}
51
56
  @horizontal={{this.isHorizontal}}
52
57
  />
53
58
  {{else}}
@@ -2,6 +2,7 @@ import { get, action } from "@ember/object";
2
2
  import { inject as service } from "@ember/service";
3
3
  import Component from "@glimmer/component";
4
4
  import { tracked } from "@glimmer/tracking";
5
+ import { isIsoDate } from "ember-ebau-gwr/utils";
5
6
 
6
7
  export const converstionTypeMapping = {
7
8
  number: Number,
@@ -13,15 +14,32 @@ export default class ModelFormFieldComponent extends Component {
13
14
  @service intl;
14
15
  @tracked diffResolved = false;
15
16
 
17
+ constructor(...args) {
18
+ super(...args);
19
+ this.initializeImport();
20
+ }
21
+
22
+ get value() {
23
+ return (
24
+ this.args.value ??
25
+ get(this.args.model, this.args.attr) ??
26
+ // for zero values get returns undefined instead of 0
27
+ this.args.model?.[this.args.attr]
28
+ );
29
+ }
30
+
31
+ get importValue() {
32
+ return get(this.args.importData, this.args.attr);
33
+ }
34
+
16
35
  get showDiff() {
17
36
  if (this.args.importData) {
18
- const currentData = get(this.args.model, this.args.attr);
19
- const newData = get(this.args.importData, this.args.attr);
20
- const showDiff = !this.diffResolved && newData && newData !== currentData;
21
- if (showDiff) {
22
- this.args.registerDiff(this.args.attr);
23
- }
24
- return showDiff;
37
+ return (
38
+ !this.diffResolved &&
39
+ this.importValue !== null &&
40
+ this.importValue !== undefined &&
41
+ this.importValue !== this.value
42
+ );
25
43
  }
26
44
  return false;
27
45
  }
@@ -70,14 +88,23 @@ export default class ModelFormFieldComponent extends Component {
70
88
  }
71
89
 
72
90
  @action
73
- updateModelField(attr, eventOrValue) {
91
+ initializeImport() {
92
+ if (this.showDiff) {
93
+ this.args.registerDiff(this.args.attr);
94
+ }
95
+ }
96
+
97
+ @action
98
+ updateModelField(eventOrValue) {
99
+ const attr = this.args.attr;
74
100
  const value = eventOrValue?.target?.value ?? eventOrValue;
75
101
 
76
102
  // If we supply a custom update method use this
77
103
  if (this.args.update) {
78
104
  this.args.update(attr, value);
79
105
  } else {
80
- this.args.model.set(attr, value);
106
+ // Date casts necessary for import
107
+ this.args.model.set(attr, isIsoDate(value) ? new Date(value) : value);
81
108
 
82
109
  if (this.args.importData) {
83
110
  this.diffResolved = true;
@@ -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 @hasImport @import)}}
4
- <button
5
- class="uk-button uk-button-default uk-margin-small-right"
6
- type="button"
7
- {{on "click" @importAllData}}
8
- >
9
- {{t "ember-gwr.components.modelForm.applyAll"}}
10
- </button>
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 @hasImport @hasStatus)}}
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,39 +75,30 @@
32
75
  <ul
33
76
  class="uk-nav uk-dropdown-nav uk-list uk-list-divider uk-list-collapse"
34
77
  >
35
- {{#if @hasImport}}
78
+ {{#if @modelHasImport}}
36
79
  <li>
37
- {{#if this.project.isNew}}
38
- <button
39
- disabled={{@import}}
40
- class="uk-button uk-text-left uk-highlight-hover uk-text-secondary uk-width-1-1 uk-background-default uk-padding-remove"
41
- type="button"
42
- {{on "click" @importAllData}}
43
- >
44
- {{t "ember-gwr.components.modelForm.importFromCaluma"}}
45
- </button>
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
+ {{on "click" (fn (mut this.showImportModal) true)}}
87
+ >
88
+ {{t "ember-gwr.components.modelForm.importFromCaluma"}}
89
+ </LinkTo>
57
90
  </li>
58
91
  {{/if}}
59
92
  {{#if @hasStatus}}
60
93
  <li>
61
- <button
94
+ <a
95
+ href="#ember-ebau-gwr-status"
96
+ uk-scroll
62
97
  class="uk-button uk-text-left uk-highlight-hover uk-text-secondary uk-width-1-1 uk-background-default uk-padding-remove"
63
- type="button"
64
98
  {{on "click" @openStatus}}
65
99
  >
66
100
  {{t "ember-gwr.components.modelForm.changeStatus"}}
67
- </button>
101
+ </a>
68
102
  </li>
69
103
  {{/if}}
70
104
  </ul>
@@ -0,0 +1,6 @@
1
+ import Component from "@glimmer/component";
2
+ import { tracked } from "@glimmer/tracking";
3
+
4
+ export default class ModelFormHeaderActionsComponent extends Component {
5
+ @tracked showImportModal = false;
6
+ }
@@ -65,7 +65,7 @@
65
65
  {{@confirmLabel}}
66
66
  </UkButton>
67
67
  </div>
68
- {{#if @errors.length}}
68
+ {{#if (or @errors.length @errors.linkToRoute)}}
69
69
  <div class="uk-margin-small-top">
70
70
  <ModelForm::SubmitErrors @errors={{@errors}} />
71
71
  </div>
@@ -135,7 +135,7 @@
135
135
  </div>
136
136
  </div>
137
137
  {{/if}}
138
- {{#if this.errors.length}}
138
+ {{#if (or this.errors.length this.errors.linkToRoute)}}
139
139
  <div class="uk-flex-inline">
140
140
  <ModelForm::SubmitErrors @errors={{this.errors}} />
141
141
  </div>
@@ -9,10 +9,12 @@
9
9
  @submit={{@submit}}
10
10
  @submitErrors={{@submitErrors}}
11
11
  @hasStatus={{and @hasStatus @model (not @model.isNew)}}
12
- @hasImport={{@hasImport}}
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}}
@@ -1,26 +1,44 @@
1
- {{#if @errors}}
2
- {{#if (eq @errors.length 1)}}
3
- <div
4
- class="uk-alert-danger uk-text-small uk-flex-1 uk-margin-remove-bottom"
5
- uk-alert
1
+ {{#if @errors.linkToRoute}}
2
+ <div
3
+ class="uk-alert-danger uk-text-small uk-flex-1 uk-margin-remove-bottom"
4
+ uk-alert
5
+ >
6
+ <LinkTo
7
+ class="uk-text-danger uk-text-small"
8
+ @route={{@errors.linkToRoute}}
9
+ @models={{@errors.linkToModels}}
6
10
  >
7
- {{object-at 0 @errors}}
8
- </div>
9
- {{else}}
10
- <button
11
- type="button"
12
- class="uk-button ember-ebau-gwr-submit-errors-multiple uk-alert-danger uk-text-small uk-flex-1 uk-margin-remove-bottom"
13
- uk-alert
14
- {{on "click" this.updateCurrentIndex}}
15
- >
16
- <div class="uk-flex-inline uk-flex-middle">
17
- <div class="uk-text-small uk-margin-small-right">
18
- {{inc this.errorIndex}}<span>/</span>{{@errors.length}}
19
- </div>
20
- <div>
21
- {{object-at this.errorIndex @errors}}
22
- </div>
11
+ {{@errors.linkToText}}
12
+ </LinkTo>
13
+ <span>
14
+ {{@errors.linkToTextAfter}}
15
+ </span>
16
+ </div>
17
+ {{else if (eq @errors.length 1)}}
18
+ <div
19
+ class="uk-alert-danger uk-text-small uk-flex-1 uk-margin-remove-bottom"
20
+ uk-alert
21
+ >
22
+ {{object-at 0 @errors}}
23
+ </div>
24
+ {{else if (gt @errors.length 1)}}
25
+ <button
26
+ type="button"
27
+ class="uk-button ember-ebau-gwr-submit-errors-multiple uk-alert-danger uk-text-small uk-flex-1 uk-margin-remove-bottom"
28
+ uk-alert
29
+ {{on "click" this.updateCurrentIndex}}
30
+ >
31
+ <div class="uk-flex-inline uk-flex-middle">
32
+ <div class="uk-text-small uk-margin-small-right">
33
+ {{inc this.errorIndex}}
34
+ <span>
35
+ /
36
+ </span>
37
+ {{@errors.length}}
23
38
  </div>
24
- </button>
25
- {{/if}}
39
+ <div>
40
+ {{object-at this.errorIndex @errors}}
41
+ </div>
42
+ </div>
43
+ </button>
26
44
  {{/if}}
@@ -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 @importData)
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
- @translationBase={{or @translationBaseHeader @translationBase}}
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=@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 @importData}}
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"
@@ -3,11 +3,13 @@ import { inject as service } from "@ember/service";
3
3
  import Component from "@glimmer/component";
4
4
  import { tracked } from "@glimmer/tracking";
5
5
  import { dropTask } from "ember-concurrency-decorators";
6
+ import { isIsoDate } from "ember-ebau-gwr/utils";
6
7
 
7
8
  export default class ModelFormComponent extends Component {
8
9
  @service router;
9
10
  @service notification;
10
11
  @service intl;
12
+ @service config;
11
13
 
12
14
  // This array is only used for tracking the still open diffs
13
15
  // so we can transition out of the import once the array is empty.
@@ -18,11 +20,17 @@ export default class ModelFormComponent extends Component {
18
20
  return this.submit.isRunning || this.args.onSubmit.isRunning;
19
21
  }
20
22
 
23
+ get modelHasImport() {
24
+ return this.config.importModels.includes(this.args.headerModelName);
25
+ }
26
+
21
27
  finishImport() {
22
28
  this.notification.success(
23
29
  this.intl.t("ember-gwr.components.modelForm.diff.resolved")
24
30
  );
25
- this.router.transitionTo({ queryParams: { import: false } });
31
+ this.router.transitionTo({
32
+ queryParams: { import: false, index: undefined },
33
+ });
26
34
  }
27
35
 
28
36
  @dropTask
@@ -53,14 +61,26 @@ export default class ModelFormComponent extends Component {
53
61
  importAllData() {
54
62
  // We cannot just `Object.assign` here since the child object like `identification` would
55
63
  // not be classes with tracked fields etc. anymore but just pojos. We need to preserve the classes.
64
+
65
+ // TODO: How should we handle the status field, if this is in the imported data this will get
66
+ // set here...
56
67
  const deepMerge = (original, objectToApply) => {
57
68
  Object.entries(objectToApply).forEach(([key, value]) => {
58
- typeof value === "object"
59
- ? deepMerge(original[key], objectToApply[key])
60
- : (original[key] = value);
69
+ if (
70
+ original !== null &&
71
+ original !== undefined &&
72
+ value !== null &&
73
+ value !== undefined
74
+ ) {
75
+ typeof value === "object"
76
+ ? deepMerge(original[key], objectToApply[key])
77
+ : isIsoDate(value) // Date casts necessary for import
78
+ ? (original[key] = new Date(value))
79
+ : (original[key] = value);
80
+ }
61
81
  });
62
82
  };
63
- deepMerge(this.args.model, this.args.importData);
83
+ deepMerge(this.args.model, this.args.import.data);
64
84
  this.finishImport();
65
85
  }
66
86
  }
@@ -0,0 +1,8 @@
1
+ <div
2
+ class="inview-trigger"
3
+ {{on "inview" (perform this.fetch @model)}}
4
+ >
5
+ {{yield (hash
6
+ model=this.fetchedModel
7
+ )}}
8
+ </div>
@@ -0,0 +1,12 @@
1
+ import Component from "@glimmer/component";
2
+ import { tracked } from "@glimmer/tracking";
3
+ import { task } from "ember-concurrency-decorators";
4
+
5
+ export default class ModelInviewComponent extends Component {
6
+ @tracked fetchedModel;
7
+
8
+ @task
9
+ *fetch(model) {
10
+ this.fetchedModel = yield this.args.fetchModel(model);
11
+ }
12
+ }
@@ -1,6 +1,6 @@
1
1
  <PikadayInput
2
2
  @format="DD.MM.YYYY"
3
- @placeholder={{t "ember-gwr.components.projectForm.datePlaceholder"}}
3
+ @placeholder={{t "ember-gwr.components.modelForm.datePlaceholder"}}
4
4
  @value={{@value}}
5
5
  @onSelection={{@update}}
6
6
  class="uk-width-1 uk-input"
@@ -16,7 +16,7 @@
16
16
  <InputField
17
17
  @attr={{@attr}}
18
18
  @required={{@required}}
19
- @value={{get @project @attr}}
19
+ @value={{this.value}}
20
20
  @options={{@options}}
21
21
  @noPlaceholder={{@noPlaceholder}}
22
22
  @update={{fn (or @update this.updateProjectField) @attr}}
@@ -25,7 +25,7 @@ export default class ProjectFormFieldComponent extends Component {
25
25
  }
26
26
 
27
27
  get disableInput() {
28
- return this.args.importData && !this.showDiff;
28
+ return (this.args.importData && !this.showDiff) || this.args.disabled;
29
29
  }
30
30
 
31
31
  @action
@@ -48,4 +48,8 @@ export default class ProjectFormFieldComponent extends Component {
48
48
  }
49
49
  }
50
50
  }
51
+
52
+ get value() {
53
+ return this.args.value ?? this.args.project?.[this.args.attr];
54
+ }
51
55
  }
@@ -32,12 +32,7 @@
32
32
  </div>
33
33
  {{/if}}
34
34
  <Field @attr="realestateIdentification.EGRID" />
35
- <Field
36
- @attr="realestateIdentification.numberSuffix"
37
- type="number"
38
- />
39
35
  <Field @attr="realestateIdentification.subDistrict" type="number" />
40
- <Field @attr="realestateIdentification.lot" type="number" />
41
36
  </div>
42
37
 
43
38
  <div>
@@ -39,9 +39,7 @@ export default class SearchFiltersComponent extends Component {
39
39
  // We have to check that the number is set.
40
40
  if (
41
41
  (realestateIdentification.EGRID ||
42
- realestateIdentification.numberSuffix ||
43
- realestateIdentification.subDistrict ||
44
- realestateIdentification.lot) &&
42
+ realestateIdentification.subDistrict) &&
45
43
  !realestateIdentification.number
46
44
  ) {
47
45
  this.validationErrors.realestateIdentification = this.intl.t(