return this.orgList;
}
+ // Returns a list of org unit type objects
+ typeList(): IdlObject[] {
+ const types = [];
+ this.list().forEach(org => {
+ if ((types.filter(t => t.id() === org.ou_type().id())).length === 0) {
+ types.push(org.ou_type());
+ }
+ });
+ return types;
+ }
+
/**
* Returns a list of org units that match the selected criteria.
* All filters must match for an org to be included in the result set.
// Entry ID of the default entry to select (optional)
// onChange() is NOT fired when applying the default value,
// unless startIdFiresOnChange is set to true.
- @Input() startId: any;
+ @Input() startId: any = null;
@Input() startIdFiresOnChange: boolean;
@Input() asyncDataSource: (term: string) => Observable<ComboboxEntry>;
// Apply a default selection where needed
applySelection() {
- if (this.startId &&
+ if (this.startId !== null &&
this.entrylist && !this.defaultSelectionApplied) {
const entry =
</eg-fm-record-editor>
<div class="row">
- <div class="col-lg-4">
+ <div class="col-lg-3">
<h3 i18n>Permission Groups</h3>
<eg-tree [tree]="tree" (nodeClicked)="nodeClicked($event)"></eg-tree>
</div>
- <div class="col-lg-8">
+ <div class="col-lg-9">
<h3 i18n class="mb-3">Selected Permission Group</h3>
<ng-container *ngIf="!selected">
<div class="alert alert-info font-italic" i18n>
<div class="row font-weight-bold">
<div class="col-lg-5" i18n>Permissions</div>
- <div class="col-lg-2" i18n>Depth</div>
- <div class="col-lg-3" i18n>Group</div>
- <div class="col-lg-2" i18n>Grantable?</div>
+ <div class="col-lg-4" i18n>Group</div>
+ <div class="col-lg-1" i18n>Depth</div>
+ <div class="col-lg-1" i18n>Grantable?</div>
+ <div class="col-lg-1" i18n>Select</div>
</div>
<div class="row" *ngFor="let map of groupPermMaps()">
<div class="col-lg-5">{{map.perm().code()}}</div>
- <div class="col-lg-2">{{map.depth()}}</div>
- <div class="col-lg-3">{{map.grp().name()}}</div>
- <div class="col-lg-2">
- <ng-container *ngIf="permIsInherited(map); else nativeMap">
- <!-- TODO migrate to <eg-bool/> once merged-->
- {{map.grantable() == 't'}}
- </ng-container>
- <ng-template #nativeMap>
+ <div class="col-lg-4">{{map.grp().name()}}</div>
+ <ng-container *ngIf="permIsInherited(map); else nativeMap">
+ <div class="col-lg-1 text-center">{{map.depth()}}</div>
+ <!-- TODO migrate to <eg-bool/> once merged-->
+ <div class="col-lg-1">{{map.grantable() == 't'}}</div>
+ </ng-container>
+ <ng-template #nativeMap>
+ <div class="col-lg-1">
+ <eg-combobox [entries]="orgDepths" [startId]="map.depth()"
+ (onChange)="map.depth($event ? $event.id : null); map.ischanged(true)">
+ </eg-combobox>
+ </div>
+ <div class="col-lg-1">
<input type="checkbox"
[ngModel]="map.grantable() == 't'"
(ngModelChange)="map.grantable($event ? 't' : 'f')"/>
- </ng-template>
- </div>
+ </div>
+ <div class="col-lg-1">
+ <button class="btn btn-warning" (click)="deleteMap(map)" i18n>
+ Delete
+ </button>
+ </div>
+ </ng-template>
</div>
</ng-template>
</ngb-tab>
permIdMap: {[id: number]: IdlObject};
permEntries: ComboboxEntry[];
permMaps: IdlObject[];
+ orgDepths: ComboboxEntry[];
@ViewChild('editDialog') editDialog: FmRecordEditorComponent;
@ViewChild('editString') editString: StringComponent;
ngOnInit() {
this.loadPgtTree();
+ this.setOrgDepths();
+ }
+
+ setOrgDepths() {
+ const depths = this.org.typeList().map(t => Number(t.depth()));
+ const depths2 = [];
+ depths.forEach(d => {
+ if (!depths2.includes(d)) {
+ depths2.push(d);
+ }
+ });
+
+ this.orgDepths = depths2.sort().map(d => ({id: d, label: d}));
}
groupPermMaps(): IdlObject[] {
m1.perm().code() < m2.perm().code() ? -1 : 1);
}
-
-
loadPgtTree() {
this.pcrud.search('pgt', {parent: null},
// Returns true if the perm map belongs to an ancestore of the
// currently selected group.
permIsInherited(map: IdlObject): boolean {
- let treeNode = this.tree.findNode(this.selected.callerData.parent());
- while (treeNode) {
- if (+map.grp().id() === +treeNode.id) {
- return true;
- }
- treeNode = this.tree.findNode(treeNode.callerData.parent());
- }
- return false;
+ // We know the provided map came from this.groupPermMaps() which
+ // only returns maps for the selected group plus parent groups.
+ return map.grp().id() !== this.selected.callerData.id();
}
// List of perm maps that owned by perm groups which are ancestors
}
);
}
+
+ deleteMap(map: IdlObject) {
+
+ }
}