From d896152af4a62657392d53b4669222f8906e8228 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 25 Jul 2018 12:15:54 -0400 Subject: [PATCH] LP#1779158 Match set quality UI Signed-off-by: Bill Erickson --- .../cat/vandelay/match-set-expression.component.ts | 57 +++++------ .../vandelay/match-set-new-point.component.html | 23 +++-- .../cat/vandelay/match-set-new-point.component.ts | 5 + .../cat/vandelay/match-set-quality.component.html | 27 ++++++ .../cat/vandelay/match-set-quality.component.ts | 105 +++++++++++++++++++++ .../staff/cat/vandelay/match-set.component.html | 2 + .../src/app/staff/cat/vandelay/vandelay.module.ts | 2 + 7 files changed, 187 insertions(+), 34 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-quality.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-quality.component.ts 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 index cba3f258e6..991206853d 100644 --- 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 @@ -51,41 +51,42 @@ export class MatchSetExpressionComponent implements OnInit { ngOnInit() {} refreshTree(): Promise { - if (!this.matchSet_) { return; } + if (!this.matchSet_) { return Promise.resolve(); } return this.pcrud.search('vmsp', {match_set: this.matchSet_.id()}, {}, {atomic: true, authoritative: true} - ).toPromise().then(points => { - - // create tree nodes - const nodes = []; - const idmap: any = {}; - points.forEach(point => { - - point.negate(point.negate() === 't' ? true : false); - point.heading(point.heading() === 't' ? true : false); - point.children([]); - - const node = new TreeNode({ - id: point.id(), - expanded: true, - callerData: {point: point} - }); - idmap[node.id + ''] = node; - this.setNodeLabel(node, point).then(() => nodes.push(node)); - }); + ).toPromise().then(points => this.ingestMatchPoints(points)); + } + + ingestMatchPoints(points: IdlObject[]) { + const nodes = []; + const idmap: any = {}; + + // massage data, create tree nodes + points.forEach(point => { - // then apply the parent/child relationship + point.negate(point.negate() === 't' ? true : false); + point.heading(point.heading() === 't' ? true : false); + point.children([]); - points.forEach(point => { - const node = idmap[point.id() + '']; - if (point.parent()) { - idmap[point.parent() + ''].children.push(node); - } else { - this.tree = new Tree(node); - } + const node = new TreeNode({ + id: point.id(), + expanded: true, + callerData: {point: point} }); + idmap[node.id + ''] = node; + this.setNodeLabel(node, point).then(() => nodes.push(node)); + }); + + // apply the tree parent/child relationships + points.forEach(point => { + const node = idmap[point.id() + '']; + if (point.parent()) { + idmap[point.parent() + ''].children.push(node); + } else { + this.tree = new Tree(node); + } }); } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.html index 1de54c8884..4ffa40c819 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.html @@ -42,13 +42,15 @@ [(ngModel)]="values.matchScore" step="0.1"/> -
-
Negate:
-
- + +
+
Negate:
+
+ +
-
+
@@ -61,6 +63,15 @@
+ +
+
Value:
+
+ +
+
+
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.ts index 8e7460253e..6298981cff 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.ts @@ -13,6 +13,7 @@ export class MatchSetPointValues { marcSf: string; heading: string; boolOp: string; + value: string; } @Component({ @@ -26,6 +27,9 @@ export class MatchSetNewPointComponent implements OnInit { bibAttrDefs: IdlObject[]; bibAttrDefEntries: ComboboxEntry[]; + // defining a new match_set_quality + @Input() isForQuality: boolean; + // biblio, authority, quality @Input() set pointType(type_: string) { this.values.pointType = type_; @@ -35,6 +39,7 @@ export class MatchSetNewPointComponent implements OnInit { this.values.marcTag = ''; this.values.marcSf = ''; this.values.boolOp = 'AND'; + this.values.value = ''; } constructor( diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-quality.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-quality.component.html new file mode 100644 index 0000000000..5229ddf3ac --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-quality.component.html @@ -0,0 +1,27 @@ +
+
+
+ Add New: + + +
+ + +
+ + +
+
+
+ + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-quality.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-quality.component.ts new file mode 100644 index 0000000000..b2409c196c --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-quality.component.ts @@ -0,0 +1,105 @@ +import {Component, OnInit, ViewChild, AfterViewInit, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import {IdlObject, IdlService} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; +import {OrgService} from '@eg/core/org.service'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridDataSource} from '@eg/share/grid/grid'; +import {Pager} from '@eg/share/util/pager'; +import {MatchSetNewPointComponent} from './match-set-new-point.component'; + +@Component({ + selector: 'eg-match-set-quality', + templateUrl: 'match-set-quality.component.html' +}) +export class MatchSetQualityComponent implements OnInit { + + // Match set arrives from parent async. + matchSet_: IdlObject; + @Input() set matchSet(ms: IdlObject) { + this.matchSet_ = ms; + if (ms) { + this.matchSetType = ms.mtype(); + if (this.grid) { + this.grid.reload(); + } + } + } + + newPointType: string; + matchSetType: string; + dataSource: GridDataSource; + @ViewChild('newPoint') newPoint: MatchSetNewPointComponent; + @ViewChild('grid') grid: GridComponent; + deleteSelected: (rows: IdlObject[]) => void; + + constructor( + private idl: IdlService, + private pcrud: PcrudService, + private net: NetService, + private auth: AuthService, + private org: OrgService + ) { + + this.dataSource = new GridDataSource(); + this.dataSource.getRows = (pager: Pager, sort: any[]) => { + + if (!this.matchSet_) { + return Observable.of(); + } + + const orderBy: any = {}; + if (sort.length) { + orderBy.vmsq = sort[0].name + ' ' + sort[0].dir; + } + + const searchOps = { + offset: pager.offset, + limit: pager.limit, + order_by: orderBy + }; + + const search = {match_set: this.matchSet_.id()}; + return this.pcrud.search('vmsq', search, searchOps); + } + + this.deleteSelected = (rows: any[]) => { + this.pcrud.remove(rows).subscribe( + ok => console.log('deleted ', ok), + err => console.error(err), + () => this.grid.reload() + ); + }; + } + + ngOnInit() {} + + addQuality() { + const quality = this.idl.create('vmsq'); + const values = this.newPoint.values; + + quality.match_set(this.matchSet_.id()); + quality.quality(values.matchScore); + quality.value(values.value); + + if (values.recordAttr) { + quality.svf(values.recordAttr); + } else { + quality.tag(values.marcTag); + quality.subfield(values.marcSf); + } + + this.pcrud.create(quality).subscribe( + ok => console.debug('created ', ok), + err => console.error(err), + () => { + this.newPointType = null; + this.grid.reload(); + } + ); + } +} + 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 2c88b34433..fd69cf93bd 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 @@ -29,6 +29,8 @@ + + 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 31dbd9225c..a4ce09ed23 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 @@ -20,6 +20,7 @@ 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 {MatchSetQualityComponent} from './match-set-quality.component'; import {MatchSetNewPointComponent} from './match-set-new-point.component'; @NgModule({ @@ -39,6 +40,7 @@ import {MatchSetNewPointComponent} from './match-set-new-point.component'; MatchSetListComponent, MatchSetComponent, MatchSetExpressionComponent, + MatchSetQualityComponent, MatchSetNewPointComponent ], imports: [ -- 2.11.0