From: Bill Erickson Date: Mon, 8 Apr 2019 17:30:12 +0000 (-0400) Subject: LPXXX Angular Permission group tree admin UI X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3e4ab888e79d6a06e55ed807b85c8ee6bf1f8ebe;p=working%2FEvergreen.git LPXXX Angular Permission group tree admin UI Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/core/org.service.ts b/Open-ILS/src/eg2/src/app/core/org.service.ts index c666957d2c..ba2b4e39f8 100644 --- a/Open-ILS/src/eg2/src/app/core/org.service.ts +++ b/Open-ILS/src/eg2/src/app/core/org.service.ts @@ -44,6 +44,17 @@ export class OrgService { 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. diff --git a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts index 8b018d5e38..7731dc2e13 100644 --- a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts +++ b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts @@ -58,7 +58,7 @@ export class ComboboxComponent implements OnInit { // 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; @@ -120,7 +120,7 @@ export class ComboboxComponent implements OnInit { // Apply a default selection where needed applySelection() { - if (this.startId && + if (this.startId !== null && this.entrylist && !this.defaultSelectionApplied) { const entry = diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.html b/Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.html index 31a3477c81..fad125628f 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.html @@ -21,11 +21,11 @@
-
+

Permission Groups

-
+

Selected Permission Group

@@ -102,26 +102,37 @@
Permissions
-
Depth
-
Group
-
Grantable?
+
Group
+
Depth
+
Grantable?
+
Select
{{map.perm().code()}}
-
{{map.depth()}}
-
{{map.grp().name()}}
-
- - - {{map.grantable() == 't'}} - - +
{{map.grp().name()}}
+ +
{{map.depth()}}
+ +
{{map.grantable() == 't'}}
+
+ +
+ + +
+
- -
+
+
+ +
+
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.ts index 0c11ff93cd..4151d8a6cd 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.ts @@ -24,6 +24,7 @@ export class PermGroupTreeComponent implements OnInit { permIdMap: {[id: number]: IdlObject}; permEntries: ComboboxEntry[]; permMaps: IdlObject[]; + orgDepths: ComboboxEntry[]; @ViewChild('editDialog') editDialog: FmRecordEditorComponent; @ViewChild('editString') editString: StringComponent; @@ -47,6 +48,19 @@ export class PermGroupTreeComponent implements OnInit { 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[] { @@ -58,8 +72,6 @@ export class PermGroupTreeComponent implements OnInit { m1.perm().code() < m2.perm().code() ? -1 : 1); } - - loadPgtTree() { this.pcrud.search('pgt', {parent: null}, @@ -124,14 +136,9 @@ export class PermGroupTreeComponent implements OnInit { // 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 @@ -226,5 +233,9 @@ export class PermGroupTreeComponent implements OnInit { } ); } + + deleteMap(map: IdlObject) { + + } }