Skip to content

Commit

Permalink
fix: Set permissions success callback
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipLeitner authored and jmacura committed Feb 13, 2024
1 parent 0f5b7ea commit 297ea26
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,26 @@ import {UpsertLayerObject} from 'hslayers-ng/types';
imports: [CommonModule, TranslateCustomPipe, HsLaymanModule],
})
export class HsSetPermissionsDialogComponent
implements HsDialogComponent, OnInit {
implements HsDialogComponent, OnInit
{
dialogItem: HsDialogItem;
viewRef: ViewRef;
currentAccessRights: accessRightsModel = {
'access_rights.write': 'private',
'access_rights.read': 'EVERYONE',
};
/**
* @param onPermissionSaved Callback method as service instance and method name.
* Pass service as property to not polute the component
* and because compoent is cosntructed dynamically via dialog service (no input)
*/
data: {
recordType: string;
selectedRecord: HsAddDataLayerDescriptor;
onPermissionSaved: () => any;
onPermissionSaved: {
service: any;
method: string;
};
};
endpoint: HsEndpoint;
state: 'idle' | 'loading' | 'success' | 'error' = 'idle';
Expand Down Expand Up @@ -107,7 +116,9 @@ export class HsSetPermissionsDialogComponent
return;
}
this.state = 'success';
this.data.onPermissionSaved();
this.data.onPermissionSaved.service[
this.data.onPermissionSaved.method
]();
break;
case 'composition':
await this.hsLaymanService.updateCompositionAccessRights(
Expand All @@ -120,7 +131,9 @@ export class HsSetPermissionsDialogComponent
return;
}
this.state = 'success';
this.data.onPermissionSaved();
this.data.onPermissionSaved.service[
this.data.onPermissionSaved.method
]();
break;
default:
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ export class HsCatalogueListItemComponent implements OnInit {
this.hsDialogContainerService.create(HsSetPermissionsDialogComponent, {
recordType: 'layer',
selectedRecord: layer,
onPermissionSaved: this.hsAddDataCatalogueService.reloadData,
onPermissionSaved: {
service: this.hsAddDataCatalogueService,
method: 'reloadData',
},
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ export class HsCompositionsListItemComponent {
this.hsDialogContainerService.create(HsSetPermissionsDialogComponent, {
recordType: 'composition',
selectedRecord: composition,
onPermissionSaved:
this.hsCompositionsCatalogueService.loadFilteredCompositions,
onPermissionSaved: {
service: this.hsCompositionsCatalogueService,
method: 'loadFilteredCompositions',
},
});
}

Expand Down

0 comments on commit 297ea26

Please sign in to comment.