From 38fb163c2dc5615d6fe2e2d5a849601e46720a23 Mon Sep 17 00:00:00 2001 From: Brian DiChiara Date: Fri, 20 Sep 2024 10:20:34 -0500 Subject: [PATCH] [#31420] Replace confirms with Modals, added Mixins --- resources/js/components/Category/Editable.vue | 93 ++++++---- .../js/components/Concept/mixins/Term.js | 12 -- resources/js/components/Term/Editable.vue | 166 +++++++++++------- resources/js/components/Term/List.vue | 2 +- .../components/Term/mixins/ConfirmDelete.js | 17 ++ .../Term/mixins/ConfirmPreferred.js | 17 ++ .../js/components/Term/mixins/InlineEdit.js | 33 ++++ 7 files changed, 225 insertions(+), 115 deletions(-) create mode 100644 resources/js/components/Term/mixins/ConfirmDelete.js create mode 100644 resources/js/components/Term/mixins/ConfirmPreferred.js create mode 100644 resources/js/components/Term/mixins/InlineEdit.js diff --git a/resources/js/components/Category/Editable.vue b/resources/js/components/Category/Editable.vue index 49b251c..7b7c10e 100644 --- a/resources/js/components/Category/Editable.vue +++ b/resources/js/components/Category/Editable.vue @@ -1,35 +1,52 @@ diff --git a/resources/js/components/Term/List.vue b/resources/js/components/Term/List.vue index da45c7b..e6c8fe3 100644 --- a/resources/js/components/Term/List.vue +++ b/resources/js/components/Term/List.vue @@ -23,7 +23,7 @@ > {{ term.text }} diff --git a/resources/js/components/Term/mixins/ConfirmDelete.js b/resources/js/components/Term/mixins/ConfirmDelete.js new file mode 100644 index 0000000..b9c53a2 --- /dev/null +++ b/resources/js/components/Term/mixins/ConfirmDelete.js @@ -0,0 +1,17 @@ +export default { + methods: { + showDeleteModal() { + this.$refs.deleteModal.show(); + }, + hideDeleteModal() { + this.$refs.deleteModal.hide(); + }, + confirmDelete() { + this.$emit('delete-term', this.termId, this.termIndex); + this.hideDeleteModal(); + }, + focusConfirmDeleteButton() { + this.$refs.confirmDeleteButton.focus(); + }, + }, +}; diff --git a/resources/js/components/Term/mixins/ConfirmPreferred.js b/resources/js/components/Term/mixins/ConfirmPreferred.js new file mode 100644 index 0000000..8a5bf2e --- /dev/null +++ b/resources/js/components/Term/mixins/ConfirmPreferred.js @@ -0,0 +1,17 @@ +export default { + methods: { + showPreferredModal() { + this.$refs.preferredModal.show(); + }, + hidePreferredModal() { + this.$refs.preferredModal.hide(); + }, + confirmPreferred() { + this.$emit('make-term-preferred', this.term, this.termIndex); + this.hidePreferredModal(); + }, + focusConfirmPreferredButton() { + this.$refs.confirmPreferredButton.focus(); + }, + }, +}; diff --git a/resources/js/components/Term/mixins/InlineEdit.js b/resources/js/components/Term/mixins/InlineEdit.js new file mode 100644 index 0000000..6328fc9 --- /dev/null +++ b/resources/js/components/Term/mixins/InlineEdit.js @@ -0,0 +1,33 @@ +export default { + computed: { + inlineEdit() { + return this.inEdit; + }, + }, + methods: { + showCancelModal() { + this.$refs.cancelModal.show(); + }, + hideCancelModal() { + this.$refs.cancelModal.hide(); + }, + confirmCancel() { + this.$emit('cancel-inline-edit', this.term, this.termIndex); + this.text = this.originalText; + this.resetTerm(); + this.hideCancelModal(); + }, + focusConfirmCancelButton() { + this.$refs.confirmCancelButton.focus(); + }, + cancelInlineEdit() { + if (this.isDirty()) { + this.showCancelModal(); + } else { + this.$emit('cancel-inline-edit', this.term, this.termIndex); + this.text = this.originalText; + this.resetTerm(); + } + }, + }, +};