-
-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(#9601): prototype duplicate prevention #9609
Open
ChinHairSaintClair
wants to merge
9
commits into
medic:master
Choose a base branch
from
ChinHairSaintClair:duplicate-prevention
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9eb471f
fix: prototype duplicate prevention
ChinHairSaintClair 4728a2c
Merge branch 'master' into duplicate-prevention
ChinHairSaintClair d75a2e2
Merge branch 'master' into duplicate-prevention
ChinHairSaintClair 872daeb
fix: round 1 review changes
ChinHairSaintClair f3df8c1
Merge branch 'master' into duplicate-prevention
ChinHairSaintClair 89257b0
Merge branch 'master' into duplicate-prevention
ChinHairSaintClair 27b509d
fix: sonar cloud changes
ChinHairSaintClair a9836f9
fix: round 2 review changes
ChinHairSaintClair 58b4502
Merge branch 'master' into duplicate-prevention
ChinHairSaintClair File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: number; [key: string]: string | number }[] = []; | ||
|
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: WebStorm is complaining to me that the
reported_date: number
value for theDuplicate
interface does not match thereported_date: string | Date
value for theDuplicateInfoComponent.duplicates
property. I don't think it is a functional issue probably since JS can auto-box a number into a string, but I wonder if we should be type-matchingContactsEditComponent.duplicates
andDuplicateInfoComponent.duplicates
?