From 9cce1573f38a3524a200f9dce2e740ee2c9158f7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 18 Jul 2018 17:42:51 -0400 Subject: [PATCH] LP#1779158 Initial match set UI Signed-off-by: Bill Erickson --- .../vandelay/match-set-expression.component.html | 19 +++++ .../cat/vandelay/match-set-expression.component.ts | 82 ++++++++++++++++++++++ .../staff/cat/vandelay/match-set-list.component.ts | 2 +- .../staff/cat/vandelay/match-set.component.html | 23 ++++++ .../app/staff/cat/vandelay/match-set.component.ts | 19 ++++- .../src/app/staff/cat/vandelay/vandelay.module.ts | 7 +- 6 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-expression.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-expression.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-expression.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-expression.component.html new file mode 100644 index 0000000000..4f206d58fb --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-expression.component.html @@ -0,0 +1,19 @@ + +
+
+ +
+ +
+
+ + +
+
+
+ diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-expression.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-expression.component.ts new file mode 100644 index 0000000000..33eb9bec62 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-expression.component.ts @@ -0,0 +1,82 @@ +import {Component, OnInit, ViewChild, AfterViewInit, Input} from '@angular/core'; +import {IdlObject} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {OrgService} from '@eg/core/org.service'; +import {Tree, TreeNode} from '@eg/share/tree/tree'; + +@Component({ + selector: 'eg-match-set-expression', + templateUrl: 'match-set-expression.component.html' +}) +export class MatchSetExpressionComponent implements OnInit { + + // Match set arrives from parent async. + matchSet_: IdlObject; + @Input() set matchSet(ms: IdlObject) { + this.matchSet_ = ms; + if (ms && !this.initDone) { + this.initDone = true; + this.refreshTree(); + } + } + + tree: Tree; + initDone: boolean; + + constructor( + private pcrud: PcrudService, + private org: OrgService + ) { } + + ngOnInit() { + } + + refreshTree() { + if (!this.matchSet_) { return; } + + this.pcrud.search('vmsp', + {match_set: this.matchSet_.id()}, {}, {atomic: true} + ).toPromise().then(points => { + + // create tree nodes + const nodes = []; + const idmap: any = {}; + points.forEach(point => { + const node = new TreeNode({ + id: point.id(), + expanded: true, + label: point.bool_op() + || point.svf() + || (point.tag() + ' ‡' + point.subfield()) + }); + nodes.push(node); + idmap[node.id + ''] = node; + }); + + // then apply the parent/child relationship + + points.forEach(point => { + const node = idmap[point.id() + '']; + if (point.parent()) { + idmap[point.parent() + ''].children.push(node); + } else { + this.tree = new Tree(node); + } + }); + }); + } + + nodeClicked(node: TreeNode) { + console.log('node clicked: ' + node.label + + ' expanded ' + node.expanded); + } + + deleteNode() { + this.tree.removeNode(this.tree.activeNode()); + } + + hasActiveNode(): boolean { + return Boolean(this.tree.activeNode()); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.ts index 6a67531a72..e20c954be2 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.ts @@ -31,7 +31,7 @@ export class MatchSetListComponent implements AfterViewInit { this.contextOrg = this.org.get(this.auth.user().ws_ou()); this.gridSource.getRows = (pager: Pager) => { - const orgs = this.org.descendants(this.contextOrg, true); + const orgs = this.org.ancestors(this.contextOrg, true); return this.pcrud.search('vms', {owner: orgs}, { order_by: {vms: ['name']}, limit: pager.limit, diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.html index ce6287e391..2c88b34433 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.html @@ -1,7 +1,30 @@ +
+
+
+
Match Set Summary
+
+
+
Match Set Name:
+
{{matchSet.name()}}
+
+
+
Owning Library:
+
{{matchSet.owner().shortname()}}
+
+
+
Type:
+
{{matchSet.mtype()}}
+
+
+
+
+
+ + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts index 3527d41ef5..15a19aaa42 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts @@ -1,24 +1,39 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; +import {IdlObject} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {OrgService} from '@eg/core/org.service'; @Component({ templateUrl: 'match-set.component.html' }) -export class MatchSetComponent { +export class MatchSetComponent implements OnInit { + matchSet: IdlObject; matchSetId: number; matchSetTab: string; constructor( private router: Router, - private route: ActivatedRoute) { + private route: ActivatedRoute, + private pcrud: PcrudService, + private org: OrgService + ) { this.route.paramMap.subscribe((params: ParamMap) => { this.matchSetId = +params.get('id'); this.matchSetTab = params.get('matchSetTab'); }); } + ngOnInit() { + this.pcrud.retrieve('vms', this.matchSetId) + .toPromise().then(ms => { + ms.owner(this.org.get(ms.owner())); + this.matchSet = ms; + }); + } + // Changing a tab in the UI means changing the route. // Changing the route ultimately results in changing the tab. onTabChange(evt: NgbTabChangeEvent) { diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts index 5726b4e87c..0215fa9ec2 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts @@ -18,6 +18,8 @@ import {QueueItemsComponent} from './queue-items.component'; import {RecordItemsComponent} from './record-items.component'; import {MatchSetListComponent} from './match-set-list.component'; import {MatchSetComponent} from './match-set.component'; +import {MatchSetExpressionComponent} from './match-set-expression.component'; +import {TreeModule} from '@eg/share/tree/tree.module'; @NgModule({ declarations: [ @@ -34,9 +36,11 @@ import {MatchSetComponent} from './match-set.component'; QueueItemsComponent, RecordItemsComponent, MatchSetListComponent, - MatchSetComponent + MatchSetComponent, + MatchSetExpressionComponent ], imports: [ + TreeModule, StaffCommonModule, CatalogCommonModule, VandelayRoutingModule, @@ -48,5 +52,4 @@ import {MatchSetComponent} from './match-set.component'; }) export class VandelayModule { - } -- 2.11.0