ember-ebau-gwr 6.0.1 → 6.0.3

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 CHANGED
@@ -1,3 +1,23 @@
1
+ ## [6.0.3](https://github.com/adfinis-sygroup/ember-ebau-gwr/compare/v6.0.2...v6.0.3) (2022-09-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **import:** fix import functionality ([27da792](https://github.com/adfinis-sygroup/ember-ebau-gwr/commit/27da792438fe63b37e54cd6ff8d41f5816a8664c))
7
+ * **project:** don't rerender unnecessarily ([df737d5](https://github.com/adfinis-sygroup/ember-ebau-gwr/commit/df737d57ca5048574e684f1eac3705cc34f83c19))
8
+ * **projects:** handle refetching of projects for new projects ([192fddb](https://github.com/adfinis-sygroup/ember-ebau-gwr/commit/192fddb0b7325ececd8d95acfe0390c3d9576100))
9
+
10
+ ## [6.0.2](https://github.com/adfinis-sygroup/ember-ebau-gwr/compare/v6.0.1...v6.0.2) (2022-09-21)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **global:** minor ui change ([524b789](https://github.com/adfinis-sygroup/ember-ebau-gwr/commit/524b78955f723ba24f17547136afe02a82dc09ed))
16
+ * **projects:** fix instance link querying by eproid ([e1fff2e](https://github.com/adfinis-sygroup/ember-ebau-gwr/commit/e1fff2ed40b5b33b9ed3d8b1aea41b688749a59b))
17
+ * **quarterly-closure:** fix fetching of status after closure ([4f19d91](https://github.com/adfinis-sygroup/ember-ebau-gwr/commit/4f19d91b797c34631d7741e5dcbb698dc7cb427c))
18
+ * **search:** make search pagination optional ([3e883e9](https://github.com/adfinis-sygroup/ember-ebau-gwr/commit/3e883e96bb9d624c90b57029db44346d15902047))
19
+ * **status:** fix lifecycle error links for global views ([801936b](https://github.com/adfinis-sygroup/ember-ebau-gwr/commit/801936bdf11c40a67fdcd5f5024a5edfa9ff1365))
20
+
1
21
  ## [6.0.1](https://github.com/adfinis-sygroup/ember-ebau-gwr/compare/v6.0.0...v6.0.1) (2022-09-19)
2
22
 
3
23
 
@@ -7,6 +7,7 @@
7
7
  class="uk-text-danger uk-text-small"
8
8
  @route={{@errors.linkToRoute}}
9
9
  @models={{@errors.linkToModels}}
10
+ @query={{@errors.linkToQuery}}
10
11
  >
11
12
  {{@errors.linkToText}}
12
13
  </LinkTo>
@@ -1,41 +1,40 @@
1
- {{#if this.import.isLoading}}
2
- <Loading />
3
- {{else}}
4
-
5
- {{#if this.import.error}}
6
- <div
7
- class={{if this.noImportData "uk-alert-warning" "uk-alert-error"}}
8
- uk-alert
9
- >
1
+ {{#if this.import.error}}
2
+ <div
3
+ class={{if this.noImportData "uk-alert-warning" "uk-alert-error"}}
4
+ uk-alert
5
+ >
10
6
 
11
- {{! The aria-label attr results in a template-lint error for some reason: error Cannot read properties of undefined (reading 'replace') undefined}}
12
- {{! template-lint-disable}}
13
- <a
14
- aria-label={{t "ember-gwr.close"}}
15
- class="uk-alert-close"
16
- href=""
17
- uk-close
18
- ></a>
19
- {{! template-lint-enable}}
20
- <p>
21
- {{#if this.noImportData}}
22
- {{t "ember-gwr.components.modelForm.noImportData"}}
23
- {{else}}
24
- {{t "ember-gwr.components.modelForm.importError"}}
25
- {{/if}}
26
- </p>
27
- </div>
28
- {{/if}}
7
+ {{! The aria-label attr results in a template-lint error for some reason: error Cannot read properties of undefined (reading 'replace') undefined}}
8
+ {{! template-lint-disable}}
9
+ <a
10
+ aria-label={{t "ember-gwr.close"}}
11
+ class="uk-alert-close"
12
+ href=""
13
+ uk-close
14
+ ></a>
15
+ {{! template-lint-enable}}
16
+ <p>
17
+ {{#if this.noImportData}}
18
+ {{t "ember-gwr.components.modelForm.noImportData"}}
19
+ {{else}}
20
+ {{t "ember-gwr.components.modelForm.importError"}}
21
+ {{/if}}
22
+ </p>
23
+ </div>
24
+ {{/if}}
29
25
 
30
- <ValidatedForm
31
- @model={{if @validations (changeset @model @validations) @model}}
32
- @on-submit={{perform this.submit}}
33
- @on-invalid-submit={{fn (mut this.invalidSubmit) true}}
34
- @validateBeforeSubmit={{true}}
35
- class="validated-form"
36
- ...attributes
37
- as |f|
38
- >
26
+ <ValidatedForm
27
+ @model={{if @validations (changeset @model @validations) @model}}
28
+ @on-submit={{perform this.submit}}
29
+ @on-invalid-submit={{fn (mut this.invalidSubmit) true}}
30
+ @validateBeforeSubmit={{true}}
31
+ class="validated-form"
32
+ ...attributes
33
+ as |f|
34
+ >
35
+ {{#if this.import.isLoading}}
36
+ <Loading />
37
+ {{else}}
39
38
  {{#let
40
39
  (component
41
40
  f.submit
@@ -111,5 +110,5 @@
111
110
  {{/if}}
112
111
  </div>
113
112
  {{/let}}
114
- </ValidatedForm>
115
- {{/if}}
113
+ {{/if}}
114
+ </ValidatedForm>
@@ -25,7 +25,7 @@ export default class ModelFormComponent extends Component {
25
25
  }));
26
26
 
27
27
  get importData() {
28
- const index = Number(this.args.importIndex);
28
+ const index = parseInt(this.args.importIndex);
29
29
  const data =
30
30
  Array.isArray(this.import.value) && !isNaN(index)
31
31
  ? this.import.value[index]
@@ -117,7 +117,7 @@ export default class ModelFormComponent extends Component {
117
117
  }
118
118
  });
119
119
  };
120
- deepMerge(this.args.model, this.import.value.data);
120
+ deepMerge(this.args.model, this.importData.data);
121
121
  this.finishImport();
122
122
  }
123
123
  }
@@ -33,7 +33,7 @@ export default class QuarterlyClosureStatus extends Component {
33
33
 
34
34
  const notificationType =
35
35
  NOTIFICATION_TYPES[this.quarterlyClosure.status.type];
36
- this.notification[notificationType](
36
+ this.notification[notificationType]?.(
37
37
  this.quarterlyClosure.status.shortLabel
38
38
  );
39
39
  } catch (error) {
@@ -1,16 +1,17 @@
1
- <div>
1
+ <div class="ember-ebau-gwr-quarterly-closure-status">
2
2
  <div class="uk-flex uk-flex-middle">
3
- <span class="uk-text-bold margin-right-xs">
3
+ <div
4
+ class="uk-text-bold uk-text-meta uk-text-emphasis uk-text-uppercase margin-right-xs"
5
+ >
4
6
  {{t "ember-gwr.quarterlyClosure.status.label"}}
5
- </span>
7
+ </div>
6
8
  <FaIcon class={{this.statusClass.text}}
7
9
  @icon={{this.statusClass.icon}}
8
10
  @prefix={{this.statusClass.prefix}}
9
- @fixedWidth={{true}}
10
11
  @size="sm"
11
12
  />
12
13
  </div>
13
- <div>
14
+ <div class="uk-text-meta uk-text-emphasis">
14
15
  {{this.quarterlyClosure.status.label}}
15
16
  </div>
16
17
  </div>
@@ -10,6 +10,7 @@ export default class SearchComponent extends Component {
10
10
  @tracked page = 1;
11
11
  @tracked searchResults = null;
12
12
  @tracked hasMoreResults = false;
13
+ @tracked rawQuery = {};
13
14
 
14
15
  @service notification;
15
16
  @service intl;
@@ -53,6 +54,11 @@ export default class SearchComponent extends Component {
53
54
  lookupValidator(validations),
54
55
  validations
55
56
  );
57
+
58
+ this.rawQuery = baseQuery;
59
+ if (this.args.paginate) {
60
+ this.onSubmit.perform();
61
+ }
56
62
  }
57
63
 
58
64
  @dropTask
@@ -61,11 +67,15 @@ export default class SearchComponent extends Component {
61
67
  this.rawQuery = {
62
68
  ...this.rawQuery,
63
69
  ..._query?.pendingData,
64
- page: this.page,
70
+ ...(this.args.paginate ? { page: this.page } : {}),
65
71
  };
66
72
 
67
73
  const _results = yield this.args.service.search(this.rawQuery);
68
- if (!_results || _results.length < this.config.pageSize) {
74
+ if (
75
+ !this.args.paginate ||
76
+ !_results ||
77
+ _results.length < this.config.pageSize
78
+ ) {
69
79
  this.hasMoreResults = false;
70
80
  } else {
71
81
  this.hasMoreResults = true;
@@ -110,6 +110,9 @@ export default class BuildingEditDwellingEditController extends ImportController
110
110
  );
111
111
  }
112
112
  }
113
+
114
+ this.resetImportQueryParams();
115
+
113
116
  // Ensure dwelling list is refreshed
114
117
  this.building.clearCache(this.model.buildingId);
115
118
  this.errors = [];
@@ -147,6 +147,9 @@ export default class BuildingFormController extends ImportController {
147
147
  // Clear cache so after transition we fetch the project form api
148
148
  this.constructionProject.clearCache(this.model.projectId);
149
149
  }
150
+
151
+ this.resetImportQueryParams();
152
+
150
153
  this.buildingAPI.clearCache(this.model.buildingId);
151
154
  this.errors = [];
152
155
  this.router.transitionTo("building.edit.form", EGID);
@@ -1,11 +1,12 @@
1
1
  import Controller from "@ember/controller";
2
+ import { registerDestructor } from "@ember/destroyable";
2
3
  import { inject as service } from "@ember/service";
3
- import { trackedFunction } from "ember-resources/util/function";
4
+ import { task, lastValue } from "ember-concurrency";
5
+ import { Resource } from "ember-resources";
4
6
 
5
7
  export default class ProjectController extends Controller {
6
8
  @service router;
7
9
  @service config;
8
- @service intl;
9
10
  @service constructionProject;
10
11
 
11
12
  get activeProjectId() {
@@ -24,30 +25,71 @@ export default class ProjectController extends Controller {
24
25
  );
25
26
  }
26
27
 
27
- projects = trackedFunction(this, async () => {
28
- // TrackedFunction only re-runs in case of changes in tracked properties
29
- // appearing before the first await / yield expression (which is necessary in this
30
- // case due to the infinite loop of fetching issue).
31
- // Related issue: https://github.com/NullVoxPopuli/ember-resources/issues/340
32
- const activeProjectId = this.activeProjectId;
33
- const model = this.model;
34
- await Promise.resolve();
35
-
36
- if (!model) {
37
- return [
38
- await this.constructionProject.getFromCacheOrApi(activeProjectId),
39
- ];
40
- }
28
+ projects = ProjectsResource.from(this, () => ({
29
+ model: this.model,
30
+ activeProjectId: this.activeProjectId,
31
+ }));
32
+ }
33
+
34
+ // The `ProjectController.activeProjectId` getter is computed even if
35
+ // `ProjectController.router.externalRouter.currentRoute` has changes
36
+ // in its query params and `ProjectController.activeProjectId` has not actually
37
+ // changed. This could be the case when all import fields are resolved
38
+ // and we transition form `?import=true` to `?import=false`.
39
+ //
40
+ // To prevent a rerender of the whole form (since if `ProjectController.isLoading` is true,
41
+ // we render a spinner) the `ProjectsResource.fetchProjects` task is only performed, if the
42
+ // `ProjectController.activeProjectId` has actually changed.
43
+ export class ProjectsResource extends Resource {
44
+ @service constructionProject;
45
+ @service router;
41
46
 
42
- // We then use `gwr.projects` in the template to reference this.
43
- // This is so we can update the table if we add a new project in the subroute /new
44
- const projects = await this.constructionProject.all.perform(model);
47
+ _lastActiveProjectId = null;
45
48
 
46
- // Load the first project in the list if none is selected so we always display a project.
47
- if (projects.length && this.router.currentRouteName === "project.index") {
48
- this.router.transitionTo("project.form", projects[0].EPROID);
49
+ constructor(owner) {
50
+ super(owner);
51
+
52
+ registerDestructor(this, () => {
53
+ this.fetchProjects.cancelAll({ resetState: true });
54
+ });
55
+ }
56
+
57
+ modify(_positional, named) {
58
+ // The task is only performed, if the `activeProjectId` has changed
59
+ // since the last run. String cast is used to catch NaN values, since NaN
60
+ // is not equal to NaN.
61
+ if (String(this._lastActiveProjectId) !== String(named.activeProjectId)) {
62
+ this.fetchProjects.perform(named);
63
+ this._lastActiveProjectId = named.activeProjectId;
49
64
  }
65
+ }
50
66
 
51
- return this.constructionProject.projects;
52
- });
67
+ get isLoading() {
68
+ return this.fetchProjects.isRunning;
69
+ }
70
+
71
+ @lastValue("fetchProjects") value;
72
+ @task
73
+ *fetchProjects({ model, activeProjectId }) {
74
+ try {
75
+ if (!model) {
76
+ return [
77
+ yield this.constructionProject.getFromCacheOrApi(activeProjectId),
78
+ ];
79
+ }
80
+
81
+ // We then use `gwr.projects` in the template to reference this.
82
+ // This is so we can update the table if we add a new project in the subroute /new
83
+ const projects = yield this.constructionProject.all.perform(model);
84
+
85
+ // Load the first project in the list if none is selected so we always display a project.
86
+ if (projects.length && this.router.currentRouteName === "project.index") {
87
+ this.router.transitionTo("project.form", projects[0].EPROID);
88
+ }
89
+
90
+ return this.constructionProject.projects;
91
+ } catch (error) {
92
+ console.error(error);
93
+ }
94
+ }
53
95
  }
@@ -36,10 +36,12 @@ export default class SearchProjectController extends Controller {
36
36
  @lastValue("fetchInstanceLinks") links;
37
37
  @dropTask
38
38
  *fetchInstanceLinks(projects) {
39
+ if (!projects) {
40
+ return [];
41
+ }
42
+
39
43
  const links = yield this.store.query("gwr-link", {
40
- filter: {
41
- eproid: projects.map(({ EPROID }) => EPROID),
42
- },
44
+ eproid__in: projects.map(({ EPROID }) => EPROID).join(","),
43
45
  });
44
46
  const instanceLinks = yield this.config.fetchInstanceLinks(
45
47
  links.map(({ localId }) => localId)
@@ -43,8 +43,6 @@ export default class ImportResource extends Resource {
43
43
  @lastValue("fetchCalumaData") value;
44
44
  @task
45
45
  *fetchCalumaData({ instanceId, showImport, importModelName }) {
46
- this.error = null;
47
-
48
46
  if (instanceId && showImport) {
49
47
  assert(
50
48
  "Must set `importModelName` to a string.",
@@ -64,6 +62,7 @@ export default class ImportResource extends Resource {
64
62
  });
65
63
  this.error = NO_DATA_ERROR;
66
64
  } else {
65
+ this.error = null;
67
66
  return data?.length === 1 ? data[0] : data;
68
67
  }
69
68
  } catch (error) {
@@ -155,8 +155,7 @@ export default class GwrService extends Service {
155
155
  ? "building.edit.dwelling.edit"
156
156
  : "building.edit.form",
157
157
  linkToModels: [
158
- instanceId,
159
- projectId,
158
+ ...(instanceId ? [instanceId] : []),
160
159
  buildingId,
161
160
  ...(dwellingId ? [dwellingId] : []),
162
161
  ],
@@ -172,6 +171,7 @@ export default class GwrService extends Service {
172
171
  linkToTextAfter: this.intl.t(`ember-gwr.lifeCycles.statusError`, {
173
172
  states: this.concatStates(states),
174
173
  }),
174
+ linkToQuery: projectId ? { projectId } : {},
175
175
  };
176
176
  }
177
177
 
@@ -119,13 +119,12 @@ export default class QuarterlyClosureService extends Service {
119
119
  return null;
120
120
  }
121
121
 
122
- const response = await this.authFetch.fetch(
122
+ await this.authFetch.fetch(
123
123
  `/constructionsurveydepts/${this.constructionSurveyDeptNumber}/closeQuarterlySurvey`,
124
124
  { method: "put" }
125
125
  );
126
- this.quarterlyClosureStatus = new QuarterlyClosureStatus(
127
- await response.text()
128
- );
126
+
127
+ await this.pollProgressStatus();
129
128
  }
130
129
 
131
130
  async checkQuarterlySurveyDept() {
@@ -1,12 +1,12 @@
1
- <div class="uk-padding">
2
- <h1 class="uk-text-center">
1
+ <div class="uk-padding-large">
2
+ <h1>
3
3
  {{t "ember-gwr.globalLandingPage.heading"}}
4
4
  </h1>
5
- <h4 class="uk-text-center uk-margin-remove-top uk-margin-large">
5
+ <h4 class="uk-margin-remove-top uk-margin-medium-bottom">
6
6
  {{t "ember-gwr.globalLandingPage.infoText"}}
7
7
  </h4>
8
8
 
9
- <div uk-grid class="uk-child-width-1-1 uk-child-width-1-3@m">
9
+ <div uk-grid class="uk-child-width-1-1 uk-child-width-1-3@m uk-padding-remove-left">
10
10
  <TitleCard
11
11
  @title={{t "ember-gwr.globalLandingPage.searchProject"}}
12
12
  @route="search-project"
@@ -21,6 +21,7 @@
21
21
  @extendedSearch={{true}}
22
22
  @service={{this.building}}
23
23
  @baseQuery={{this.baseQuery}}
24
+ @paginate={{true}}
24
25
  @validations={{this.validations}}
25
26
  @idField="EGID"
26
27
  >
@@ -20,6 +20,7 @@
20
20
  <Search
21
21
  @service={{this.constructionProject}}
22
22
  @baseQuery={{this.baseQuery}}
23
+ @paginate={{true}}
23
24
  @extendedSearch={{true}}
24
25
  @validations={{this.validations}}
25
26
  @idField="EPROID"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-ebau-gwr",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "Ember engine to integrate ebau-gwr into an ember app.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -34,7 +34,7 @@ ember-gwr:
34
34
  690: Kopieren der Daten in den Snapshot
35
35
  691: Erzwungener Abschluss von BFS
36
36
  short:
37
- processing: Eine Anfrage ist noch nicht verarbeitet
37
+ processing: Anfrage noch nicht verarbeitet
38
38
  610: Quartalsabschluss initialisiert
39
39
  620: Abschluss erforderlich
40
40
  630: Fehler müssen korrigiert werden