Skip to content

Commit 698a6d4

Browse files
authored
Feature/eui 1370 complex type aa (#605)
* EUI-1370 some initial work * EUI-1370 work done and tests * EUI-1370 @£$%^&*(*&^%$ linting * EUI-1370 some initial work * EUI-1370 work done and tests * EUI-1370 @£$%^&*(*&^%$ linting * EUI-1370 fixed bug relating to startsWith * EUI-1370 release details
1 parent 8bebbc9 commit 698a6d4

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

RELEASE-NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## RELEASE NOTES
2+
### Version 2.64.52-collection-permission
3+
**EUI-1370** UI When using case role collection of complex types doesn't seem to work
4+
25
### Version 2.64.50-case-share-hot-fix
36
* correct and cherry-pick the right commits
47

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hmcts/ccd-case-ui-toolkit",
3-
"version": "2.64.51-retain-hidden-value-complex-and-collection-types-fix",
3+
"version": "2.64.52-collection-permission",
44
"engines": {
55
"yarn": "^1.12.3",
66
"npm": "^5.6.0"

src/shared/components/palette/collection/write-collection-field.component.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ describe('WriteCollectionFieldComponent', () => {
9090
label: 'X',
9191
field_type: SIMPLE_FIELD_TYPE,
9292
display_context: 'OPTIONAL',
93+
display_context_parameter: '#COLLECTION(allowInsert)',
9394
value: VALUES.slice(0),
9495
acls: [
9596
{
@@ -255,6 +256,13 @@ describe('WriteCollectionFieldComponent', () => {
255256
});
256257

257258
it('should display removal confirmation dialog when remove button is clicked', () => {
259+
const tempCaseField = <CaseField>({
260+
...caseField,
261+
display_context_parameter: '#COLLECTION(allowInsert,allowDelete)'
262+
});
263+
component.caseFields = [tempCaseField];
264+
component.ngOnInit();
265+
fixture.detectChanges();
258266
let removeButtons = de.queryAll($REMOVE_BUTTONS);
259267

260268
let removeFirstButton = removeButtons[0];
@@ -265,6 +273,19 @@ describe('WriteCollectionFieldComponent', () => {
265273
});
266274

267275
it('should remove item from collection when remove button is clicked and confirmed', () => {
276+
const tempCaseField = <CaseField>({
277+
...caseField,
278+
display_context_parameter: '#COLLECTION(allowInsert,allowDelete)'
279+
});
280+
component.caseField = tempCaseField;
281+
component.caseFields = [tempCaseField];
282+
component.ngOnInit();
283+
fixture.detectChanges();
284+
// Manually populate the form array as item field are mocked and can't register themselves
285+
VALUES.forEach((collectionItem, index) => {
286+
component.buildControlRegistrer(collectionItem.id, index)(new FormControl(collectionItem.value));
287+
});
288+
fixture.detectChanges();
268289
// Confirm removal through mock dialog
269290
dialogRef.afterClosed.and.returnValue(of('Remove'));
270291

src/shared/components/palette/collection/write-collection-field.component.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,14 @@ export class WriteCollectionFieldComponent extends AbstractFieldWriteComponent i
140140
if (this.isExpanded) {
141141
return false;
142142
}
143-
return !this.profile.user.idam.roles.find(role => this.hasCreateAccess(role));
143+
return !this.getCollectionPermission(this.caseField, 'allowInsert');
144144
}
145145

146-
hasCreateAccess(role: any) {
147-
return !!this.caseField.acls.find( acl => acl.role === role && acl.create === true);
146+
getCollectionPermission(field: CaseField, type: string) {
147+
return field.display_context_parameter &&
148+
field.display_context_parameter.split('#')
149+
.filter(item => item.startsWith('COLLECTION('))[0]
150+
.includes(type);
148151
}
149152

150153
isNotAuthorisedToUpdate(index: number) {
@@ -170,11 +173,7 @@ export class WriteCollectionFieldComponent extends AbstractFieldWriteComponent i
170173
if (this.formArray.at(index)) {
171174
id = this.formArray.at(index).get('id').value;
172175
}
173-
return !!id && !this.profile.user.idam.roles.find(role => this.hasDeleteAccess(role));
174-
}
175-
176-
hasDeleteAccess(role: any): boolean {
177-
return !!this.caseField.acls.find(acl => acl.role === role && acl.delete === true);
176+
return !!id && !this.getCollectionPermission(this.caseField, 'allowDelete');
178177
}
179178

180179
openModal(i: number) {

0 commit comments

Comments
 (0)