-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfa682f
commit 9eb471f
Showing
15 changed files
with
749 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
53 changes: 53 additions & 0 deletions
53
webapp/src/ts/components/duplicate-info/duplicate-info.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,53 @@ | ||
<div | ||
id="duplicate_info" | ||
[ngStyle]="{ display: duplicates.length > 0 ? 'block' : 'none' }"> | ||
<p class="results_header">{{ duplicates.length }} {{'potential duplicate item(s) found:' | translate }}</p> | ||
<div class="divider"></div> | ||
<div> | ||
<label for="check" class="acknowledge_label"> | ||
<input | ||
id="check" | ||
type="checkbox" | ||
[checked]="acknowledged" | ||
(change)="toggleAcknowledged()" | ||
class="acknowledge_checkbox"/> | ||
{{'Acknowledge duplicate siblings and proceed with submission' | translate }} | ||
</label> | ||
</div> | ||
<div class="divider"></div> | ||
<div *ngFor="let duplicate of duplicates; let i = index" > | ||
<div class="card"> | ||
<strong>{{ 'Item number:' | translate }}</strong> {{ i + 1 }} | ||
<hr> | ||
<p> | ||
<strong>{{ 'Name:' | translate }}</strong> {{ duplicate.name }} | ||
<br> | ||
<strong>{{ 'Created on:' | translate }}</strong> {{ duplicate.reported_date | date: 'EEE MMM dd yyyy HH:mm:ss' }} | ||
</p> | ||
<button class="toggle-button" (click)="toggleSection(getPath('', duplicate._id))"> | ||
{{ isExpanded(getPath('', duplicate._id)) ? '▼' : '▶' }} | ||
{{ (isExpanded(getPath('', duplicate._id)) ? 'Show less details' : 'Show more details') | translate }} | ||
</button> | ||
<div *ngIf="isExpanded(getPath('', duplicate._id))" class="nested-section"> | ||
<ng-container *ngTemplateOutlet="renderObject; context: { obj: duplicate, path: duplicate._id }"></ng-container> | ||
</div> | ||
<hr> | ||
<button class="btn submit btn-primary" (click)="_navigateToDuplicate(duplicate._id)">{{ 'Take me there' | translate }}</button> | ||
</div> | ||
</div> | ||
<ng-template #renderObject let-obj="obj" let-path="path"> | ||
<div *ngFor="let key of obj | keyvalue"> | ||
<div *ngIf="isObject(key.value); else primitiveValue"> | ||
<button class="toggle-button" (click)="toggleSection(getPath(path, key.key))"> | ||
{{ isExpanded(getPath(path, key.key)) ? '▼' : '▶' }} {{ key.key }} | ||
</button> | ||
<div *ngIf="isExpanded(getPath(path, key.key))" class="nested-section"> | ||
<ng-container *ngTemplateOutlet="renderObject; context: { obj: key.value, path: getPath(path, key.key) }"></ng-container> | ||
</div> | ||
</div> | ||
<ng-template #primitiveValue> | ||
<strong>{{ key.key }}:</strong> {{ key.value }} | ||
</ng-template> | ||
</div> | ||
</ng-template> | ||
</div> |
40 changes: 40 additions & 0 deletions
40
webapp/src/ts/components/duplicate-info/duplicate-info.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,40 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'mm-duplicate-info', | ||
templateUrl: './duplicate-info.component.html', | ||
}) | ||
export class DuplicateInfoComponent { | ||
@Input() acknowledged: boolean = false; | ||
@Output() acknowledgedChange = new EventEmitter<boolean>(); | ||
@Output() navigateToDuplicate = new EventEmitter<string>(); | ||
@Input() duplicates: { _id: string; name: string; reported_date: string | Date; [key: string]: string | Date }[] = []; | ||
|
||
toggleAcknowledged() { | ||
this.acknowledged = !this.acknowledged; | ||
this.acknowledgedChange.emit(this.acknowledged); | ||
} | ||
|
||
_navigateToDuplicate(_id: string){ | ||
this.navigateToDuplicate.emit(_id); | ||
} | ||
|
||
// Handles collapse / expand of duplicate doc details | ||
expandedSections = new Map<string, boolean>(); | ||
|
||
toggleSection(path: string): void { | ||
this.expandedSections.set(path, !this.expandedSections.get(path)); | ||
} | ||
|
||
isExpanded(path: string): boolean { | ||
return this.expandedSections.get(path) || false; | ||
} | ||
|
||
isObject(value: any): boolean { | ||
return value && typeof value === 'object' && !Array.isArray(value); | ||
} | ||
|
||
getPath(parentPath: string, key: string): string { | ||
return parentPath ? `${parentPath}.${key}` : key; | ||
} | ||
} |
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
Oops, something went wrong.