Skip to content

Commit 7cf8419

Browse files
MartijnBogaertandreo141
authored andcommitted
Only allow editing ICR-data for Agentschap Binnenlands Bestuur and Digitaal Vlaanderen (#93)
* Add ICR role check * Only allow editing ICR data by correct role * Store icr roles as constant Co-authored-by: andreo141 <82985453+andreo141@users.noreply.github.com> * Rename constant * Merge branch 'development' into feature/abb-dv-icr * Revert "Only allow editing ICR data by correct role" This reverts commit 4a8c27c. * Store ovo codes in environment * Allow abb and dv to edit each other's processes * Add process check for abb or dv * Only show icr card on abb and dv processes
1 parent 200b49d commit 7cf8419

File tree

6 files changed

+44
-22
lines changed

6 files changed

+44
-22
lines changed

app/controllers/processes/process/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ export default class ProcessesProcessIndexController extends Controller {
128128
this.currentSession.canEdit &&
129129
this.currentSession.group &&
130130
this.process?.publisher &&
131-
this.process.publisher.id === this.currentSession.group.id
131+
(this.process.publisher.id === this.currentSession.group.id ||
132+
(this.process.isPublishedByAbbOrDv && this.currentSession.isAbbOrDv))
132133
);
133134
}
134135

app/models/group.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
22

33
export default class GroupModel extends Model {
44
@attr name;
5+
@attr identifier;
56
@belongsTo('site', { inverse: null, async: false }) primarySite;
67
@belongsTo('administrative-unit-classification-code', {
78
async: false,

app/models/process.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,9 @@ export default class ProcessModel extends Model {
8585
);
8686
return diagramsSorted[0];
8787
}
88+
89+
get isPublishedByAbbOrDv() {
90+
const ovoCodes = [ENV.ovoCodes.abb, ENV.ovoCodes.dv];
91+
return ovoCodes.includes(this.publisher?.identifier);
92+
}
8893
}

app/services/current-session.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import Service, { service } from '@ember/service';
22
import { tracked } from '@glimmer/tracking';
3+
import ENV from 'frontend-openproceshuis/config/environment';
34

45
const EDITOR_ROLES = [
56
'LoketLB-OpenProcesHuisGebruiker',
67
'LoketLB-OpenProcesHuisAfnemer',
78
];
89
const ADMIN_ROLE = 'LoketLB-admin';
10+
const ABB_DV_IDENTIFIERS = [ENV.ovoCodes.abb, ENV.ovoCodes.dv];
911

1012
export default class CurrentSessionService extends Service {
1113
@service session;
@@ -48,12 +50,16 @@ export default class CurrentSessionService extends Service {
4850
return this.roles.some((role) => EDITOR_ROLES.includes(role));
4951
}
5052

53+
get isAbbOrDv() {
54+
return ABB_DV_IDENTIFIERS.includes(this.group?.identifier);
55+
}
56+
5157
get canEdit() {
5258
return this.isAuthenticated && this.hasEditorRole;
5359
}
5460

5561
get readOnly() {
56-
return !this.isAdmin && this.isAuthenticated && !this.hasEditorRole;
62+
return this.isAuthenticated && !this.isAdmin && !this.hasEditorRole;
5763
}
5864

5965
get isAdmin() {

app/templates/processes/process/index.hbs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,18 @@
140140
/>
141141
</:content>
142142
</Item>
143-
<Item>
144-
<:label>Blauwdruk</:label>
145-
<:content>
146-
<AuToggleSwitch
147-
@onChange={{this.toggleBlueprintStatus}}
148-
@checked={{this.process.isBlueprint}}
149-
@disabled={{not this.canEdit}}
150-
/>
151-
</:content>
152-
</Item>
143+
{{#if this.process.isPublishedByAbbOrDv}}
144+
<Item>
145+
<:label>Blauwdruk</:label>
146+
<:content>
147+
<AuToggleSwitch
148+
@onChange={{this.toggleBlueprintStatus}}
149+
@checked={{this.process.isBlueprint}}
150+
@disabled={{not this.canEdit}}
151+
/>
152+
</:content>
153+
</Item>
154+
{{/if}}
153155
</:right>
154156
</Card.Columns>
155157
</:card>
@@ -242,15 +244,17 @@
242244
/>
243245
</:content>
244246
</Item>
245-
<Item>
246-
<:label>Blauwdruk</:label>
247-
<:content>
248-
<AuToggleSwitch
249-
@disabled={{not this.isEditing}}
250-
@checked={{this.process.isBlueprint}}
251-
/>
252-
</:content>
253-
</Item>
247+
{{#if this.process.isPublishedByAbbOrDv}}
248+
<Item>
249+
<:label>Blauwdruk</:label>
250+
<:content>
251+
<AuToggleSwitch
252+
@disabled={{not this.isEditing}}
253+
@checked={{this.process.isBlueprint}}
254+
/>
255+
</:content>
256+
</Item>
257+
{{/if}}
254258
</:right>
255259
</Card.Columns>
256260
</:card>
@@ -370,7 +374,7 @@
370374

371375
{{! ICR }}
372376
<div class="au-o-grid__item">
373-
{{#if this.process.isBlueprint}}
377+
{{#if (and this.process.isBlueprint this.process.isPublishedByAbbOrDv)}}
374378
<Process::IcrCard @canEdit={{this.canEdit}} @process={{this.process}} />
375379
{{else}}
376380
<Process::BlueprintCard

config/environment.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ module.exports = function (environment) {
2121

2222
appName: 'Open Proces Huis',
2323

24+
ovoCodes: {
25+
abb: 'OVO001835',
26+
dv: 'OVO002949',
27+
},
28+
2429
conceptSchemes: {
2530
bpmnElementTypes:
2631
'http://lblod.data.gift/concept-schemes/d4259f0b-6d6e-4a46-b9e1-114b774e0f1e',

0 commit comments

Comments
 (0)