Skip to content
Snippets Groups Projects
Commit 88ab7590 authored by Daniel Nemergut's avatar Daniel Nemergut
Browse files

Preventing the save button from persisting an empty form on the editor modal

parent 1e63d35b
No related branches found
No related tags found
3 merge requests!1605Merge 2.8.2.3 work to main,!1581catch up with 2.8.2.3,!1574WS-2215 Editor modal scrubbing
......@@ -31,7 +31,7 @@
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary mr-auto" (click)="undoEditChanges()">Revert Changes</button>
<button type="button" class="btn btn-secondary" (click)="modal.close('exit')">Cancel</button>
<button type="button" class="btn btn-primary" mdbBtn (click)="this.newEditEvent.emit(this.editedData)">Save</button>
<button type="button" class="btn btn-primary" mdbBtn (click)="saveEditChanges()">Save</button>
<button type="button" class="btn btn-primary" mdbBtn (click)="modal.close('save-and-close')">Save and Close</button>
</div>
</ng-template>
......@@ -52,8 +52,8 @@ export class EditorComponent implements OnInit {
this.modalService.open(content, { ariaLabelledBy: "modal-title", centered: true, size: "lg" }).result.then(
(result) => {
if (result === "save-and-close" && this.editedData) {
// "Save" button clicked; emit edited data to parent component
this.newEditEvent.emit(this.editedData)
// "Save and Close" button clicked; emit edited data to parent component and then exit the form
this.saveEditChanges();
this.toggleEditorOpen()
} else {
// Form was exited by clicking out of it or pressing ESC
......@@ -83,6 +83,15 @@ export class EditorComponent implements OnInit {
this.editedData = this._textToEdit
}
public saveEditChanges() {
if (this.editedData) {
// "Save" or "Save and Close" button clicked; emit edited data to parent component
this.newEditEvent.emit(this.editedData);
} else {
alert("No changes were saved");
}
}
public edit(changes: string) {
this.editedData = changes
this._textToEdit = this.editedData
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment