1 import {Component, OnInit, ViewChild, AfterViewInit, Input} from '@angular/core';
2 import {Observable} from 'rxjs/Observable';
3 import 'rxjs/add/observable/of';
4 import {IdlObject, IdlService} from '@eg/core/idl.service';
5 import {PcrudService} from '@eg/core/pcrud.service';
6 import {NetService} from '@eg/core/net.service';
7 import {AuthService} from '@eg/core/auth.service';
8 import {OrgService} from '@eg/core/org.service';
9 import {GridComponent} from '@eg/share/grid/grid.component';
10 import {GridDataSource} from '@eg/share/grid/grid';
11 import {Pager} from '@eg/share/util/pager';
12 import {MatchSetNewPointComponent} from './match-set-new-point.component';
15 selector: 'eg-match-set-quality',
16 templateUrl: 'match-set-quality.component.html'
18 export class MatchSetQualityComponent implements OnInit {
20 // Match set arrives from parent async.
22 @Input() set matchSet(ms: IdlObject) {
25 this.matchSetType = ms.mtype();
34 dataSource: GridDataSource;
35 @ViewChild('newPoint') newPoint: MatchSetNewPointComponent;
36 @ViewChild('grid') grid: GridComponent;
37 deleteSelected: (rows: IdlObject[]) => void;
40 private idl: IdlService,
41 private pcrud: PcrudService,
42 private net: NetService,
43 private auth: AuthService,
44 private org: OrgService
47 this.dataSource = new GridDataSource();
48 this.dataSource.getRows = (pager: Pager, sort: any[]) => {
50 if (!this.matchSet_) {
51 return Observable.of();
54 const orderBy: any = {};
56 orderBy.vmsq = sort[0].name + ' ' + sort[0].dir;
65 const search = {match_set: this.matchSet_.id()};
66 return this.pcrud.search('vmsq', search, searchOps);
69 this.deleteSelected = (rows: any[]) => {
70 this.pcrud.remove(rows).subscribe(
71 ok => console.log('deleted ', ok),
72 err => console.error(err),
73 () => this.grid.reload()
81 const quality = this.idl.create('vmsq');
82 const values = this.newPoint.values;
84 quality.match_set(this.matchSet_.id());
85 quality.quality(values.matchScore);
86 quality.value(values.value);
88 if (values.recordAttr) {
89 quality.svf(values.recordAttr);
91 quality.tag(values.marcTag);
92 quality.subfield(values.marcSf);
95 this.pcrud.create(quality).subscribe(
96 ok => console.debug('created ', ok),
97 err => console.error(err),
99 this.newPointType = null;