1 import {Component, ViewChild, Input} from '@angular/core';
2 import {of} from 'rxjs';
3 import {IdlObject, IdlService} from '@eg/core/idl.service';
4 import {PcrudService} from '@eg/core/pcrud.service';
5 import {NetService} from '@eg/core/net.service';
6 import {AuthService} from '@eg/core/auth.service';
7 import {OrgService} from '@eg/core/org.service';
8 import {GridComponent} from '@eg/share/grid/grid.component';
9 import {GridDataSource} from '@eg/share/grid/grid';
10 import {Pager} from '@eg/share/util/pager';
11 import {MatchSetNewPointComponent} from './match-set-new-point.component';
14 selector: 'eg-match-set-quality',
15 templateUrl: 'match-set-quality.component.html'
17 export class MatchSetQualityComponent {
19 // Match set arrives from parent async.
21 @Input() set matchSet(ms: IdlObject) {
24 this.matchSetType = ms.mtype();
33 dataSource: GridDataSource;
34 @ViewChild('newPoint', { static: true }) newPoint: MatchSetNewPointComponent;
35 @ViewChild('grid', { static: true }) grid: GridComponent;
36 deleteSelected: (rows: IdlObject[]) => void;
39 private idl: IdlService,
40 private pcrud: PcrudService,
41 private net: NetService,
42 private auth: AuthService,
43 private org: OrgService
46 this.dataSource = new GridDataSource();
47 this.dataSource.getRows = (pager: Pager, sort: any[]) => {
49 if (!this.matchSet_) {
53 const orderBy: any = {};
55 orderBy.vmsq = sort[0].name + ' ' + sort[0].dir;
64 const search = {match_set: this.matchSet_.id()};
65 return this.pcrud.search('vmsq', search, searchOps);
68 this.deleteSelected = (rows: any[]) => {
69 this.pcrud.remove(rows).subscribe(
70 ok => console.log('deleted ', ok),
71 (err: unknown) => console.error(err),
72 () => this.grid.reload()
78 const quality = this.idl.create('vmsq');
79 const values = this.newPoint.values;
81 quality.match_set(this.matchSet_.id());
82 quality.quality(values.matchScore);
83 quality.value(values.value);
85 if (values.recordAttr) {
86 quality.svf(values.recordAttr);
88 quality.tag(values.marcTag);
89 quality.subfield(values.marcSf);
92 this.pcrud.create(quality).subscribe(
93 ok => console.debug('created ', ok),
94 (err: unknown) => console.error(err),
96 this.newPointType = null;