From: Bill Erickson Date: Tue, 24 Jul 2018 19:51:21 +0000 (-0400) Subject: LP#1779158 Match set UI continued X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1ca1423f8a1d47d13133a8f43b826f321949bb3b;p=working%2FEvergreen.git LP#1779158 Match set UI continued Signed-off-by: Bill Erickson --- 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 index 98404ee584..fe7d8171c9 100644 --- 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 @@ -20,92 +20,29 @@
Add New: + (click)="newPointType='attr'" i18n>Record Attribute + (click)="newPointType='marc'" i18n>MARC Tag and Subfield + (click)="newPointType='heading'" i18n>Normalized Authority Heading + (click)="newPointType='bool'" i18n>Boolean Operator
-
-
- -
-
Record Attribute:
-
- - -
-
-
- -
-
Tag:
-
- -
-
-
-
Subfield ‡:
-
- -
-
-
- -
-
Normalized Heading:
-
- -
-
-
- -
-
Match Score:
-
- -
-
-
-
Negate:
-
- -
-
-
- -
-
Operator:
-
- -
-
-
-
- -
-
-
    -
  1. Define a new match point using the above fields.
  2. -
  3. Select a boolean node in the tree.
  4. -
  5. Click the "Add..." button to add the new matchpoint - as a child of the selected node.
  6. -
-
-
+ + +
+ +
+
+
    +
  1. Define a new match point using the above fields.
  2. +
  3. Select a boolean node in the tree.
  4. +
  5. Click the "Add..." button to add the new matchpoint + as a child of the selected node.
  6. +
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 5a77ed9882..cba3f258e6 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 @@ -1,10 +1,13 @@ import {Component, OnInit, ViewChild, AfterViewInit, Input} from '@angular/core'; 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 {Tree, TreeNode} from '@eg/share/tree/tree'; import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; import {StringService} from '@eg/share/string/string.service'; +import {MatchSetNewPointComponent} from './match-set-new-point.component'; @Component({ selector: 'eg-match-set-expression', @@ -25,48 +28,30 @@ export class MatchSetExpressionComponent implements OnInit { tree: Tree; initDone: boolean; - matchSetPoints: {[id: string]: IdlObject}; matchSetType: string; changesMade: boolean; // Current type of new match point newPointType: string; - newRecordAttr: string; - newMatchScore: number; - newNegate: boolean; - newMarcTag: string; - newMarcSf: string; - newHeading: string; - newBoolOp: string; newId: number; - bibAttrDefs: IdlObject[]; - bibAttrDefEntries: ComboboxEntry[]; + @ViewChild('newPoint') newPoint: MatchSetNewPointComponent; constructor( private idl: IdlService, private pcrud: PcrudService, + private net: NetService, + private auth: AuthService, private org: OrgService, private strings: StringService ) { - this.bibAttrDefs = []; - this.bibAttrDefEntries = []; - this.matchSetPoints = {}; this.newId = -1; } - ngOnInit() { - - this.pcrud.retrieveAll('crad', {order_by: {crad: 'label'}}) - .subscribe(attr => { - this.bibAttrDefs.push(attr); - this.bibAttrDefEntries.push({id: attr.name(), label: attr.label()}); - }); - } + ngOnInit() {} refreshTree(): Promise { if (!this.matchSet_) { return; } - this.matchSetPoints = {}; return this.pcrud.search('vmsp', {match_set: this.matchSet_.id()}, {}, @@ -78,11 +63,9 @@ export class MatchSetExpressionComponent implements OnInit { const idmap: any = {}; points.forEach(point => { - // Track the from-database point objects - this.matchSetPoints[point.id()] = point; - point.negate(point.negate() === 't' ? true : false); point.heading(point.heading() === 't' ? true : false); + point.children([]); const node = new TreeNode({ id: point.id(), @@ -127,11 +110,6 @@ export class MatchSetExpressionComponent implements OnInit { deleteNode() { this.changesMade = true; const node = this.tree.selectedNode() - const point = this.matchSetPoints[node.id]; - if (point) { - // point won't be cached if it's new during this session. - point.isdeleted(true); - } this.tree.removeNode(node); } @@ -156,24 +134,27 @@ export class MatchSetExpressionComponent implements OnInit { point.isnew(true); point.parent(pnode.id); point.match_set(this.matchSet_.id()); + point.children([]); + + const ptype = this.newPoint.values.pointType; - if (this.newPointType === 'bool') { - point.bool_op(this.newBoolOp); + if (ptype === 'bool') { + point.bool_op(this.newPoint.values.boolOp); } else { - if (this.newPointType == 'attr') { - point.svf(this.newRecordAttr); + if (ptype == 'attr') { + point.svf(this.newPoint.values.recordAttr); - } else if (this.newPointType == 'marc') { - point.tag(this.newMarcTag); - point.subfield(this.newMarcSf ? this.newMarcSf : null); - } else if (this.newPointType == 'heading') { + } else if (ptype == 'marc') { + point.tag(this.newPoint.values.marcTag); + point.subfield(this.newPoint.values.marcSf); + } else if (ptype == 'heading') { point.heading(true); } - point.negate(this.newNegate); - point.quality(this.newMatchScore); + point.negate(this.newPoint.values.negate); + point.quality(this.newPoint.values.matchScore); } const node: TreeNode = new TreeNode({ @@ -185,16 +166,6 @@ export class MatchSetExpressionComponent implements OnInit { this.setNodeLabel(node, point).then(() => pnode.children.push(node)); } - setNewPointType(type_: string) { - this.newPointType = type_; - this.newRecordAttr = ''; - this.newMatchScore = 1; - this.newNegate = false; - this.newMarcTag = ''; - this.newMarcSf = ''; - this.newBoolOp = 'AND'; - } - expressionAsString(): string { if (!this.tree) { return ''; } @@ -214,21 +185,34 @@ export class MatchSetExpressionComponent implements OnInit { return renderNode(this.tree.rootNode); } + // Server API deletes and recreates the tree on update. + // It manages parent/child relationships via the children array. + // We only need send the current tree in a form the API recognizes. saveTree(): Promise { - // New nodes - let nodes = this.tree.nodeList() - .filter(node => node.callerData.point.isnew()) - .map(node => node.callerData.point); - // Deleted nodes - nodes = nodes.concat( - Object.values(this.matchSetPoints) - .filter(point => point.isdeleted()) - ); + const compileTree = (node?: TreeNode) => { + + if (!node) { node = this.tree.rootNode; } + + const point = node.callerData.point; + + node.children.forEach(child => + point.children().push(compileTree(child))); - return this.pcrud.autoApply(nodes) - .toPromise().then(() => this.refreshTree()) + return point; + }; + + const rootPoint: IdlObject = compileTree(); + + return this.net.request( + 'open-ils.vandelay', + 'open-ils.vandelay.match_set.update', + this.auth.token(), this.matchSet_.id(), rootPoint + ).toPromise().then( + ok =>this.refreshTree(), + err => console.error(err) + ); } } 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 new file mode 100644 index 0000000000..1de54c8884 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.html @@ -0,0 +1,66 @@ +
+
+ +
+
Record Attribute:
+
+ + +
+
+
+ +
+
Tag:
+
+ +
+
+
+
Subfield ‡:
+
+ +
+
+
+ +
+
Normalized Heading:
+
+ +
+
+
+ +
+
Match Score:
+
+ +
+
+
+
Negate:
+
+ +
+
+
+ +
+
Operator:
+
+ +
+
+
+
+
+ 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 new file mode 100644 index 0000000000..8e7460253e --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-new-point.component.ts @@ -0,0 +1,60 @@ +import {Component, OnInit, ViewChild, Output, Input} from '@angular/core'; +import {IdlObject, IdlService} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; + +// Can be used to create match_set_point's and match_set_quality's +export class MatchSetPointValues { + pointType: string; + recordAttr: string; + matchScore: number; + negate: boolean; + marcTag: string; + marcSf: string; + heading: string; + boolOp: string; +} + +@Component({ + selector: 'eg-match-set-new-point', + templateUrl: 'match-set-new-point.component.html' +}) +export class MatchSetNewPointComponent implements OnInit { + + public values: MatchSetPointValues; + + bibAttrDefs: IdlObject[]; + bibAttrDefEntries: ComboboxEntry[]; + + // biblio, authority, quality + @Input() set pointType(type_: string) { + this.values.pointType = type_; + this.values.recordAttr = ''; + this.values.matchScore = 1; + this.values.negate = false; + this.values.marcTag = ''; + this.values.marcSf = ''; + this.values.boolOp = 'AND'; + } + + constructor( + private idl: IdlService, + private pcrud: PcrudService + ) { + this.values = new MatchSetPointValues(); + this.bibAttrDefs = []; + this.bibAttrDefEntries = []; + } + + ngOnInit() { + this.pcrud.retrieveAll('crad', {order_by: {crad: 'label'}}) + .subscribe(attr => { + this.bibAttrDefs.push(attr); + this.bibAttrDefEntries.push({id: attr.name(), label: attr.label()}); + }); + } + + setNewPointType(type_: string) { + } +} + 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 0215fa9ec2..31dbd9225c 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 @@ -2,6 +2,7 @@ import {NgModule} from '@angular/core'; import {StaffCommonModule} from '@eg/staff/common.module'; import {CatalogCommonModule} from '@eg/share/catalog/catalog-common.module'; import {HttpClientModule} from '@angular/common/http'; +import {TreeModule} from '@eg/share/tree/tree.module'; import {VandelayRoutingModule} from './routing.module'; import {VandelayService} from './vandelay.service'; import {VandelayComponent} from './vandelay.component'; @@ -19,7 +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 {TreeModule} from '@eg/share/tree/tree.module'; +import {MatchSetNewPointComponent} from './match-set-new-point.component'; @NgModule({ declarations: [ @@ -37,7 +38,8 @@ import {TreeModule} from '@eg/share/tree/tree.module'; RecordItemsComponent, MatchSetListComponent, MatchSetComponent, - MatchSetExpressionComponent + MatchSetExpressionComponent, + MatchSetNewPointComponent ], imports: [ TreeModule,