</a>
</ng-template>
+<ng-template #targetTemplate let-row="row">
+ <ng-container *ngIf="isOverlayTarget(row.id)">
+ <span i18n-title title="Selected Merge Target"
+ class="material-icons">check_circle</span>
+ </ng-container>
+</ng-template>
+
<ng-container *ngIf="queueType == 'bib'">
<eg-grid #bibGrid [dataSource]="bibDataSource"
- [rowFlairIsEnabled]="true"
- [rowFlairCallback]="matchRowCallback"
+ (onRowClick)="matchRowClick($event)"
[disableMultiSelect]="true">
+ <!--
<eg-grid-toolbar-action i18n-label label="Mark As Overlay Target"
[action]="markOverlayTarget">
</eg-grid-toolbar-action>
+ -->
<eg-grid-column name="id" [index]="true" [hidden]="true"
i18n-label label="Match ID">
</eg-grid-column>
+ <eg-grid-column name="selected" i18n-label label="Merge Target"
+ [cellTemplate]="targetTemplate">
+ </eg-grid-column>
<eg-grid-column name="eg_record" i18n-label label="Record ID"
[cellTemplate]="bibIdTemplate">
</eg-grid-column>
import {map} from 'rxjs/operators/map';
import {Pager} from '@eg/share/util/pager';
import {GridComponent} from '@eg/share/grid/grid.component';
-import {GridDataSource, GridColumn, GridRowFlairEntry} from '@eg/share/grid/grid';
+import {GridDataSource, GridColumn} from '@eg/share/grid/grid';
import {IdlObject} from '@eg/core/idl.service';
import {EventService} from '@eg/core/event.service';
import {NetService} from '@eg/core/net.service';
bibDataSource: GridDataSource;
authDataSource: GridDataSource;
markOverlayTarget: (rows: any[]) => any;
- matchRowCallback: (row: any) => GridRowFlairEntry;
+ matchRowClick: (row: any) => void;
+ matchMap: {[id: number]: IdlObject};
constructor(
private router: Router,
}
*/
- this.markOverlayTarget = (rows: any[]) => {
+ // Mark or un-mark as row as the merge target on row click
+ this.matchRowClick = (row: any) => {
+ this.toggleMergeTarget(row.id);
+ }
+ }
+
+ toggleMergeTarget(matchId: number) {
+
+ if (this.isOverlayTarget(matchId)) {
+
+ // clear selection on secondary click;
+ delete this.vandelay.importSelection.overlayMap[this.recordId];
+
+ } else {
+ // Add to selection.
+ // Start a new one if necessary, which will be adopted
+ // and completed by the queue UI before import.
- // Start a new import selection object if needed.
- // This will be adopted by the queue UI before import.
let selection = this.vandelay.importSelection;
if (!selection) {
selection = new VandelayImportSelection();
this.vandelay.importSelection = selection;
}
-
- // Grid is configured for single-row-select.
- const match = rows[0];
- selection.overlayMap[this.recordId] = match.eg_record;
- }
-
- this.matchRowCallback = (row: any) => {
- const selection = this.vandelay.importSelection;
- if (selection) {
- const target = selection.overlayMap[this.recordId];
- if (target === row.eg_record) {
- return {icon: 'check_circle'};
- }
- }
- return null;
+ const match = this.matchMap[matchId];
+ selection.overlayMap[this.recordId] = match.eg_record();
}
}
- hasOverlayTarget(rid: number): boolean {
- return this.vandelay.importSelection &&
- Boolean(this.vandelay.importSelection.overlayMap[rid]);
+ isOverlayTarget(matchId: number): boolean {
+ const selection = this.vandelay.importSelection;
+ if (selection) {
+ const match = this.matchMap[matchId];
+ return selection.overlayMap[this.recordId] === match.eg_record();
+ }
+ return false;
}
ngOnInit() {}
const matches = this.queuedRecord.matches();
const recIds = [];
+ this.matchMap = {};
matches.forEach(m => {
+ this.matchMap[m.id()] = m;
if (!recIds.includes(m.eg_record())) {
recIds.push(m.eg_record());
}