Skip to content

Commit

Permalink
Merge pull request #576 from lblod/GN-4509-address-variable-plugin-mu…
Browse files Browse the repository at this point in the history
…nicipality-should-only-be-prefilled-when-logged-in-user-is-a-municipality

GN-4509: only prefill address municipality if logged in user is part of a muncipality/OCMW
  • Loading branch information
elpoelma authored Sep 15, 2023
2 parents 750dec4 + 78b632d commit cb06b4f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-bats-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend-gelinkt-notuleren': patch
---

Only prefill address municipality if logged in user is part of a municipality/OCMW
12 changes: 11 additions & 1 deletion app/controllers/agendapoints/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ import { color } from '@lblod/ember-rdfa-editor/plugins/color/marks/color';
import ENV from 'frontend-gelinkt-notuleren/config/environment';
import { validation } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation';
import { atLeastOneArticleContainer } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/utils/validation-rules';
import {
GEMEENTE,
OCMW,
} from '../../utils/bestuurseenheid-classificatie-codes';

export default class AgendapointsEditController extends Controller {
@service store;
Expand Down Expand Up @@ -198,8 +202,14 @@ export default class AgendapointsEditController extends Controller {
structures: structureSpecs,
};
}

get defaultMunicipality() {
return this.currentSession.group.naam;
const classificatie = this.currentSession.classificatie;
if (classificatie.uri === GEMEENTE || classificatie.uri === OCMW) {
return this.currentSession.group.naam;
} else {
return null;
}
}

get codelistEditOptions() {
Expand Down
14 changes: 13 additions & 1 deletion app/controllers/regulatory-statements/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ import { document_title } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/d
import { highlight } from '@lblod/ember-rdfa-editor/plugins/highlight/marks/highlight';
import { color } from '@lblod/ember-rdfa-editor/plugins/color/marks/color';
import ENV from 'frontend-gelinkt-notuleren/config/environment';
import {
GEMEENTE,
OCMW,
} from '../../utils/bestuurseenheid-classificatie-codes';

export default class RegulatoryStatementsRoute extends Controller {
@service documentService;
Expand Down Expand Up @@ -264,9 +268,17 @@ export default class RegulatoryStatementsRoute extends Controller {
nonZonalLocationCodelistUri: ENV.nonZonalLocationCodelistUri,
};
}

get defaultMunicipality() {
return this.currentSession.group.naam;
const classificatie = this.currentSession.classificatie;

if (classificatie.uri === GEMEENTE || classificatie.uri === OCMW) {
return this.currentSession.group.naam;
} else {
return null;
}
}

@action
download() {
this.editorDocument.content = this.controller.htmlContent;
Expand Down
2 changes: 2 additions & 0 deletions app/services/current-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default class CurrentSessionService extends Service {
@tracked user;
@tracked group;
@tracked roles = [];
@tracked classificatie;

get canRead() {
return this.hasRole('GelinktNotuleren-lezer');
Expand Down Expand Up @@ -39,6 +40,7 @@ export default class CurrentSessionService extends Service {
this.group = await this.store.findRecord('bestuurseenheid', groupId, {
include: 'classificatie',
});
this.classificatie = await this.group.classificatie;
this.roles = this.session.data.authenticated.data.attributes.roles;
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/utils/bestuurseenheid-classificatie-codes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const GEMEENTE =
'http://data.vlaanderen.be/id/concept/BestuurseenheidClassificatieCode/5ab0e9b8a3b2ca7c5e000001';
export const OCMW =
'http://data.vlaanderen.be/id/concept/BestuurseenheidClassificatieCode/5ab0e9b8a3b2ca7c5e000002';

0 comments on commit cb06b4f

Please sign in to comment.