From 6bdc4fe313a6a0e2c5a6c424e43746606c8235b3 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Tue, 26 Oct 2021 17:01:36 +0100 Subject: [PATCH] :zap: Reusable save/cancel buttons for new config editors --- src/assets/locales/en.json | 11 +++- .../InteractiveEditor/EditAppConfig.vue | 40 ++++++------ src/components/InteractiveEditor/EditItem.vue | 16 +---- .../InteractiveEditor/EditPageInfo.vue | 10 +-- .../InteractiveEditor/EditSection.vue | 12 ++-- .../InteractiveEditor/MoveItemTo.vue | 19 +----- .../InteractiveEditor/SaveCancelButtons.vue | 61 +++++++++++++++++++ src/components/LinkItems/Item.vue | 18 +++--- src/components/LinkItems/ItemContextMenu.vue | 18 +++--- src/components/LinkItems/Section.vue | 8 ++- 10 files changed, 131 insertions(+), 82 deletions(-) create mode 100644 src/components/InteractiveEditor/SaveCancelButtons.vue diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index 2c90a392..6d24c59f 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -217,7 +217,16 @@ "cancel-stage-btn": "Cancel" }, "edit-section": { - "edit-tooltip": "Click to Edit, or right-click for more options" + "edit-section-title": "Edit Section", + "edit-tooltip": "Click to Edit, or right-click for more options", + "remove-confirm": "Are you sure you want to remove this section? This action can be undone later." + }, + "edit-app-config": { + "warning-msg-title": "Proceed with Caution", + "warning-msg-l1": "The following options are for advanced app configuration.", + "warning-msg-l2": "If you are unsure about any of the fields, please reference the", + "warning-msg-docs": "documentation", + "warning-msg-l3": "to avoid unintended consequences." }, "export": { "export-title": "Export Config", diff --git a/src/components/InteractiveEditor/EditAppConfig.vue b/src/components/InteractiveEditor/EditAppConfig.vue index a1dfb021..7bb47e31 100644 --- a/src/components/InteractiveEditor/EditAppConfig.vue +++ b/src/components/InteractiveEditor/EditAppConfig.vue @@ -9,17 +9,21 @@ >

{{ $t('interactive-editor.menu.edit-app-config-btn') }}

+
-

Proceed with Caution

- The following options are for advanded app configration. - If you are unsure about any of the fields, please reference the - documentation - to avoid unintended consequences. +

+ {{ $t('interactive-editor.edit-app-config.warning-msg-title') }} +

+ {{ $t('interactive-editor.edit-app-config.warning-msg-l1') }} + {{ $t('interactive-editor.edit-app-config.warning-msg-l2') }} + + {{ $t('interactive-editor.edit-app-config.warning-msg-docs') }} + + {{ $t('interactive-editor.edit-app-config.warning-msg-l3') }}
- + + + - + +
@@ -41,8 +43,7 @@ import FormSchema from '@formschema/native'; import DashySchema from '@/utils/ConfigSchema'; import StoreKeys from '@/utils/StoreMutations'; import { modalNames } from '@/utils/defaults'; -import Button from '@/components/FormElements/Button'; -import SaveIcon from '@/assets/interface-icons/save-config.svg'; +import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons'; export default { name: 'EditAppConfig', @@ -56,8 +57,7 @@ export default { props: {}, components: { FormSchema, - Button, - SaveIcon, + SaveCancelButtons, }, mounted() { this.formData = this.appConfig; @@ -76,6 +76,9 @@ export default { this.$store.commit(StoreKeys.SET_MODAL_OPEN, false); this.$store.commit(StoreKeys.SET_EDIT_MODE, true); }, + cancelEditing() { + this.$modal.hide(this.modalName); + }, /* Called when modal manually closed, updates state to allow searching again */ modalClosed() { this.$store.commit(StoreKeys.SET_MODAL_OPEN, false); @@ -126,9 +129,6 @@ export default { color: var(--interactive-editor-color); } } - button.save-app-config-btn { - margin: 0.5rem auto 1.5rem; - } } diff --git a/src/components/InteractiveEditor/EditItem.vue b/src/components/InteractiveEditor/EditItem.vue index ead995a3..b7a420d3 100644 --- a/src/components/InteractiveEditor/EditItem.vue +++ b/src/components/InteractiveEditor/EditItem.vue @@ -65,7 +65,7 @@ - + @@ -73,10 +73,10 @@ + + diff --git a/src/components/LinkItems/Item.vue b/src/components/LinkItems/Item.vue index 8763ef08..9420d98b 100644 --- a/src/components/LinkItems/Item.vue +++ b/src/components/LinkItems/Item.vue @@ -33,7 +33,7 @@ diff --git a/src/components/LinkItems/Section.vue b/src/components/LinkItems/Section.vue index 5c3b681b..e56bdc42 100644 --- a/src/components/LinkItems/Section.vue +++ b/src/components/LinkItems/Section.vue @@ -238,8 +238,12 @@ export default { }, /* Deletes current section, in local state */ removeSection() { - const payload = { sectionIndex: this.index, sectionName: this.title }; - this.$store.commit(StoreKeys.REMOVE_SECTION, payload); + const confirmMsg = this.$t('interactive-editor.edit-section.remove-confirm'); + const youSure = confirm(confirmMsg); // eslint-disable-line no-alert, no-restricted-globals + if (youSure) { + const payload = { sectionIndex: this.index, sectionName: this.title }; + this.$store.commit(StoreKeys.REMOVE_SECTION, payload); + } this.closeContextMenu(); }, /* Open custom context menu, and set position */