-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TLC-674] Duplicate detection comp, template, i18n
Duplicate data is accessed in the submission section, pooled tasks list and claimed tasks list.
- Loading branch information
Showing
13 changed files
with
281 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/app/core/submission/models/workspaceitem-section-duplicates.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Object model for the data returned by the REST API to present minted identifiers in a submission section | ||
*/ | ||
import { Duplicate } from '../../../shared/object-list/duplicate-data/duplicate.model'; | ||
|
||
export interface WorkspaceitemSectionDuplicatesObject { | ||
potentialDuplicates?: Duplicate[] | ||
} |
24 changes: 24 additions & 0 deletions
24
src/app/shared/object-list/duplicate-data/duplicate.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {autoserialize} from "cerialize"; | ||
import {MetadataMap} from "../../../core/shared/metadata.models"; | ||
|
||
export class Duplicate { | ||
/** | ||
* The item title | ||
*/ | ||
@autoserialize | ||
title: string; | ||
@autoserialize | ||
uuid: string; | ||
@autoserialize | ||
workflowItemId: bigint; | ||
@autoserialize | ||
workspaceItemId: bigint; | ||
@autoserialize | ||
owningCollection: string; | ||
|
||
/** | ||
* Metadata for the bitstream (e.g. dc.description) | ||
*/ | ||
@autoserialize | ||
metadata: MetadataMap; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/app/shared/object-list/duplicate-data/duplicate.resource-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ResourceType } from 'src/app/core/shared/resource-type'; | ||
|
||
/** | ||
* The resource type for Access Status | ||
* | ||
* Needs to be in a separate file to prevent circular | ||
* dependencies in webpack. | ||
*/ | ||
export const DUPLICATE = new ResourceType('duplicate'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/app/submission/sections/duplicates/section-duplicates.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- | ||
Template for the detect duplicates submission section component | ||
@author Kim Shepherd | ||
--> | ||
<div class="text-sm-left" *ngVar="(this.data$ | async) as data"> | ||
<ng-container *ngIf="data.potentialDuplicates.length == 0"> | ||
<p>{{ 'submission.sections.duplicates.none' }}</p> | ||
</ng-container> | ||
<ng-container *ngIf="data.potentialDuplicates.length > 0"> | ||
<p>{{ 'submission.sections.duplicates.detected' | translate }}</p> | ||
<div *ngFor="let dupe of data.potentialDuplicates" class="ds-duplicate"> | ||
<a target="_blank" [href]="'/items/'+dupe.uuid">{{dupe.title}}</a> | ||
<div *ngFor="let metadatum of Metadata.toViewModelList(dupe.metadata)"> | ||
{{('item.preview.' + metadatum.key) | translate}} {{metadatum.value}} | ||
</div> | ||
<p *ngIf="dupe.workspaceItemId">{{ 'submission.sections.duplicates.in-workspace' | translate }}</p> | ||
<p *ngIf="dupe.workflowItemId">{{ 'submission.sections.duplicates.in-workflow' | translate }}</p> | ||
</div> | ||
</ng-container> | ||
</div> |
127 changes: 127 additions & 0 deletions
127
src/app/submission/sections/duplicates/section-duplicates.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import {ChangeDetectionStrategy, Component, Inject } from '@angular/core'; | ||
|
||
import { Observable, of as observableOf, Subscription } from 'rxjs'; | ||
import { TranslateService } from '@ngx-translate/core'; | ||
import { SectionsType } from '../sections-type'; | ||
import { SectionModelComponent } from '../models/section.model'; | ||
import { renderSectionFor } from '../sections-decorator'; | ||
import { SectionDataObject } from '../models/section-data.model'; | ||
import { SubmissionService } from '../../submission.service'; | ||
import { AlertType } from '../../../shared/alert/alert-type'; | ||
import { SectionsService } from '../sections.service'; | ||
import {map} from "rxjs/operators"; | ||
import {ItemDataService} from "../../../core/data/item-data.service"; | ||
import { | ||
WorkspaceitemSectionDuplicatesObject | ||
} from "../../../core/submission/models/workspaceitem-section-duplicates.model"; | ||
import {Metadata} from "../../../core/shared/metadata.utils"; | ||
|
||
/** | ||
* Detect duplicates step | ||
* | ||
* @author Kim Shepherd | ||
*/ | ||
@Component({ | ||
selector: 'ds-submission-section-duplicates', | ||
templateUrl: './section-duplicates.component.html', | ||
changeDetection: ChangeDetectionStrategy.Default | ||
}) | ||
|
||
@renderSectionFor(SectionsType.Duplicates) | ||
export class SubmissionSectionDuplicatesComponent extends SectionModelComponent { | ||
/** | ||
* The Alert categories. | ||
* @type {AlertType} | ||
*/ | ||
public AlertTypeEnum = AlertType; | ||
|
||
/** | ||
* Variable to track if the section is loading. | ||
* @type {boolean} | ||
*/ | ||
public isLoading = true; | ||
|
||
/** | ||
* Array to track all subscriptions and unsubscribe them onDestroy | ||
* @type {Array} | ||
*/ | ||
protected subs: Subscription[] = []; | ||
|
||
/** | ||
* Section data observable | ||
*/ | ||
public data$: Observable<WorkspaceitemSectionDuplicatesObject>; | ||
|
||
/** | ||
* Initialize instance variables. | ||
* | ||
* @param {TranslateService} translate | ||
* @param {SectionsService} sectionService | ||
* @param {SubmissionService} submissionService | ||
* @param itemDataService | ||
* @param nameService | ||
* @param {string} injectedCollectionId | ||
* @param {SectionDataObject} injectedSectionData | ||
* @param {string} injectedSubmissionId | ||
*/ | ||
constructor(protected translate: TranslateService, | ||
protected sectionService: SectionsService, | ||
protected submissionService: SubmissionService, | ||
private itemDataService: ItemDataService, | ||
// private nameService: DSONameService, | ||
@Inject('collectionIdProvider') public injectedCollectionId: string, | ||
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject, | ||
@Inject('submissionIdProvider') public injectedSubmissionId: string) { | ||
super(injectedCollectionId, injectedSectionData, injectedSubmissionId); | ||
} | ||
|
||
ngOnInit() { | ||
super.ngOnInit(); | ||
} | ||
|
||
/** | ||
* Initialize all instance variables and retrieve configuration. | ||
*/ | ||
onSectionInit() { | ||
this.isLoading = false; | ||
this.data$ = this.getDuplicateData().pipe( | ||
map((data: WorkspaceitemSectionDuplicatesObject) => { | ||
console.dir(data); | ||
return data; | ||
}) | ||
); | ||
} | ||
|
||
/** | ||
* Check if identifier section has read-only visibility | ||
*/ | ||
isReadOnly(): boolean { | ||
return true; | ||
} | ||
|
||
/** | ||
* Unsubscribe from all subscriptions, if needed. | ||
*/ | ||
onSectionDestroy(): void { | ||
return; | ||
} | ||
|
||
/** | ||
* Get section status. Because this simple component never requires human interaction, this is basically | ||
* always going to be the opposite of "is this section still loading". This is not the place for API response | ||
* error checking but determining whether the step can 'proceed'. | ||
* | ||
* @return Observable<boolean> | ||
* the section status | ||
*/ | ||
public getSectionStatus(): Observable<boolean> { | ||
return observableOf(!this.isLoading); | ||
} | ||
|
||
public getDuplicateData(): Observable<WorkspaceitemSectionDuplicatesObject> { | ||
return this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType) as | ||
Observable<WorkspaceitemSectionDuplicatesObject>; | ||
} | ||
|
||
protected readonly Metadata = Metadata; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.