-
Notifications
You must be signed in to change notification settings - Fork 4
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
DSP-638 Value Deletion Comment #198
Changes from all commits
5e11a78
6b78c2b
b113b22
1c657c6
b65052c
8a09c7e
050a4cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
<mat-dialog-content> | ||
<p class="title"> Are you sure you want to delete this value from {{data.value.propertyLabel}}?</p> | ||
<dsp-confirmation-message [value]="data.value"></dsp-confirmation-message> | ||
</mat-dialog-content> | ||
<mat-dialog-actions class="action-buttons"> | ||
<button class="cancel" mat-raised-button mat-dialog-close>{{data.buttonTextCancel}}</button> | ||
<button class="ok" mat-raised-button color="primary" (click)="onConfirmClick()">{{data.buttonTextOk}}</button> | ||
</mat-dialog-actions> | ||
<div class="deletion-dialog"> | ||
<mat-dialog-content> | ||
<p class="title"> Are you sure you want to delete this value from {{data.value.propertyLabel}}?</p> | ||
<dsp-confirmation-message #confirmMessage [value]="data.value"></dsp-confirmation-message> | ||
</mat-dialog-content> | ||
<mat-dialog-actions class="action-buttons"> | ||
<button class="cancel" mat-raised-button mat-dialog-close>{{data.buttonTextCancel}}</button> | ||
<button class="ok" mat-raised-button color="primary" (click)="onConfirmClick()">{{data.buttonTextOk}}</button> | ||
</mat-dialog-actions> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1 @@ | ||
.title { | ||
font-weight: bold; | ||
font-size: 18px; | ||
text-align: center; | ||
} | ||
|
||
.action-buttons { | ||
float: right; | ||
} | ||
@import "../../../../assets/style/viewer"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
import { Component, Inject } from '@angular/core'; | ||
import { Component, Inject, ViewChild } from '@angular/core'; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | ||
import { ReadValue } from '@dasch-swiss/dsp-js'; | ||
import { ConfirmationMessageComponent } from './confirmation-message/confirmation-message.component'; | ||
|
||
export class ConfirmationDialogData { | ||
value: ReadValue; | ||
buttonTextOk: string; | ||
buttonTextCancel: string; | ||
} | ||
|
||
export class ConfirmationDialogValueDeletionPayload { | ||
confirmed: boolean; | ||
deletionComment?: string; | ||
} | ||
|
||
@Component({ | ||
selector: 'dsp-confirmation-dialog', | ||
templateUrl: './confirmation-dialog.component.html', | ||
styleUrls: ['./confirmation-dialog.component.scss'] | ||
}) | ||
export class ConfirmationDialogComponent { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this component specific for value deletion? If so, could its name say so? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. renamed in 050a4cd |
||
@ViewChild('confirmMessage') confirmationMessageComponent: ConfirmationMessageComponent; | ||
|
||
// type assertion doesn't seem to be enforced | ||
// https://stackoverflow.com/a/57787554 | ||
|
@@ -23,7 +30,10 @@ export class ConfirmationDialogComponent { | |
) { } | ||
|
||
onConfirmClick(): void { | ||
this._dialogRef.close(true); | ||
const payload = new ConfirmationDialogValueDeletionPayload(); | ||
payload.confirmed = true; | ||
payload.deletionComment = this.confirmationMessageComponent.comment ? this.confirmationMessageComponent.comment : undefined; | ||
this._dialogRef.close(payload); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
<div class="message"> | ||
<div class="deletion-dialog-message"> | ||
<p class="val-label">Confirming this action will delete the following value from {{value.propertyLabel}}:</p> | ||
<p class="val-value">Value: {{value.strval}}</p> | ||
<p class="val-comment">Value Comment: {{value.valueHasComment ? value.valueHasComment : 'No comment'}}</p> | ||
<p class="val-creation-date">Value Creation Date: {{value.valueCreationDate}}</p> | ||
<textarea | ||
matinput | ||
class="deletion-comment" | ||
type="text" | ||
(keyup)="onKey($event)" | ||
[placeholder]="'Comment why value is being deleted'" | ||
></textarea> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1 @@ | ||
.message { | ||
font-size: 16px; | ||
background-color: #ededf5; | ||
border: 1px solid #d8d8df; | ||
border-radius: 5px; | ||
padding: 20px 10px 20px 10px; | ||
text-align: center; | ||
} | ||
@import "../../../../../assets/style/viewer"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,8 @@ import { | |
import { mergeMap } from 'rxjs/operators'; | ||
import { | ||
ConfirmationDialogComponent, | ||
ConfirmationDialogData | ||
ConfirmationDialogData, | ||
ConfirmationDialogValueDeletionPayload | ||
} from '../../../action/components/confirmation-dialog/confirmation-dialog.component'; | ||
import { DspApiConnectionToken } from '../../../core/core.module'; | ||
import { | ||
|
@@ -222,9 +223,9 @@ export class DisplayEditComponent implements OnInit { | |
const dialogRef = | ||
this._dialog.open<ConfirmationDialogComponent, ConfirmationDialogData>(ConfirmationDialogComponent, { data: dialogData}); | ||
|
||
dialogRef.afterClosed().subscribe((confirmed: boolean) => { | ||
if (confirmed) { | ||
this.deleteValue(); | ||
dialogRef.afterClosed().subscribe((payload: ConfirmationDialogValueDeletionPayload) => { | ||
if (payload && payload.confirmed) { | ||
this.deleteValue(payload.deletionComment); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. made optional in 050a4cd |
||
} | ||
}); | ||
} | ||
|
@@ -233,10 +234,11 @@ export class DisplayEditComponent implements OnInit { | |
* Delete a value from a property. | ||
* Emits an event that can be listened to. | ||
*/ | ||
deleteValue() { | ||
deleteValue(comment?: string) { | ||
const deleteVal = new DeleteValue(); | ||
deleteVal.id = this.displayValue.id; | ||
deleteVal.type = this.displayValue.type; | ||
deleteVal.deleteComment = comment; | ||
|
||
const updateRes = new UpdateResource(); | ||
updateRes.type = this.parentResource.type; | ||
|
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.
Is this more general than value deletion? Wouldn't it make more sense to keep it in the component's CSS file?
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.
After some thinking, I should refactor this a little. The current ConfirmationMessage component should be renamed and made more specific to a deletion message. This way the ConfirmationDialog component can be reused and you can just supply it with the Message component of your choosing.
Ideally the ConfirmationDialog component is just a shell with a button to confirm and a button to cancel and its contents is defined by the type of message component you give it. We should handle this in another PR though.
Task created https://dasch.myjetbrains.com/youtrack/issue/DSP-781