Reusable save/cancel buttons for new config editors

This commit is contained in:
Alicia Sykes 2021-10-26 17:01:36 +01:00
parent 70ebce4da7
commit 6bdc4fe313
No known key found for this signature in database
GPG Key ID: 3D0EA672EE9945ED
10 changed files with 131 additions and 82 deletions

View File

@ -217,7 +217,16 @@
"cancel-stage-btn": "Cancel" "cancel-stage-btn": "Cancel"
}, },
"edit-section": { "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": {
"export-title": "Export Config", "export-title": "Export Config",

View File

@ -9,17 +9,21 @@
> >
<div class="edit-app-config-inner"> <div class="edit-app-config-inner">
<h3>{{ $t('interactive-editor.menu.edit-app-config-btn') }}</h3> <h3>{{ $t('interactive-editor.menu.edit-app-config-btn') }}</h3>
<!-- Show caution message -->
<div class="app-config-intro"> <div class="app-config-intro">
<p class="use-caution">Proceed with Caution</p> <p class="use-caution">
The following options are for advanded app configration. {{ $t('interactive-editor.edit-app-config.warning-msg-title') }}
If you are unsure about any of the fields, please reference the </p>
<a href="https://dashy.to/docs/configuring#appconfig-optional">documentation</a> {{ $t('interactive-editor.edit-app-config.warning-msg-l1') }}
to avoid unintended consequences. {{ $t('interactive-editor.edit-app-config.warning-msg-l2') }}
<a href="https://dashy.to/docs/configuring#appconfig-optional">
{{ $t('interactive-editor.edit-app-config.warning-msg-docs') }}
</a>
{{ $t('interactive-editor.edit-app-config.warning-msg-l3') }}
</div> </div>
<Button class="save-app-config-btn" :click="saveToState"> <!-- Save Button, upper -->
{{ $t('interactive-editor.menu.save-stage-btn') }} <SaveCancelButtons :saveClick="saveToState" :cancelClick="cancelEditing" />
<SaveIcon /> <!-- The main form -->
</button>
<FormSchema <FormSchema
:schema="schema" :schema="schema"
v-model="formData" v-model="formData"
@ -28,10 +32,8 @@
class="app-config-form" class="app-config-form"
name="appConfigForm" name="appConfigForm"
></FormSchema> ></FormSchema>
<Button class="save-app-config-btn" :click="saveToState"> <!-- Save Button, lower -->
{{ $t('interactive-editor.menu.save-stage-btn') }} <SaveCancelButtons :saveClick="saveToState" :cancelClick="cancelEditing" />
<SaveIcon />
</button>
</div> </div>
</modal> </modal>
</template> </template>
@ -41,8 +43,7 @@ import FormSchema from '@formschema/native';
import DashySchema from '@/utils/ConfigSchema'; import DashySchema from '@/utils/ConfigSchema';
import StoreKeys from '@/utils/StoreMutations'; import StoreKeys from '@/utils/StoreMutations';
import { modalNames } from '@/utils/defaults'; import { modalNames } from '@/utils/defaults';
import Button from '@/components/FormElements/Button'; import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons';
import SaveIcon from '@/assets/interface-icons/save-config.svg';
export default { export default {
name: 'EditAppConfig', name: 'EditAppConfig',
@ -56,8 +57,7 @@ export default {
props: {}, props: {},
components: { components: {
FormSchema, FormSchema,
Button, SaveCancelButtons,
SaveIcon,
}, },
mounted() { mounted() {
this.formData = this.appConfig; this.formData = this.appConfig;
@ -76,6 +76,9 @@ export default {
this.$store.commit(StoreKeys.SET_MODAL_OPEN, false); this.$store.commit(StoreKeys.SET_MODAL_OPEN, false);
this.$store.commit(StoreKeys.SET_EDIT_MODE, true); 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 */ /* Called when modal manually closed, updates state to allow searching again */
modalClosed() { modalClosed() {
this.$store.commit(StoreKeys.SET_MODAL_OPEN, false); this.$store.commit(StoreKeys.SET_MODAL_OPEN, false);
@ -126,9 +129,6 @@ export default {
color: var(--interactive-editor-color); color: var(--interactive-editor-color);
} }
} }
button.save-app-config-btn {
margin: 0.5rem auto 1.5rem;
}
} }
</style> </style>

View File

@ -65,7 +65,7 @@
</div> </div>
</div> </div>
<!-- Save to state button --> <!-- Save to state button -->
<Button class="edit-item-save-btn" :click="saveItem">Save</Button> <SaveCancelButtons :saveClick="saveItem" :cancelClick="modalClosed" />
</div> </div>
</modal> </modal>
</template> </template>
@ -73,10 +73,10 @@
<script> <script>
import AddIcon from '@/assets/interface-icons/interactive-editor-add.svg'; import AddIcon from '@/assets/interface-icons/interactive-editor-add.svg';
import BinIcon from '@/assets/interface-icons/interactive-editor-remove.svg'; import BinIcon from '@/assets/interface-icons/interactive-editor-remove.svg';
import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons';
import Input from '@/components/FormElements/Input'; import Input from '@/components/FormElements/Input';
import Radio from '@/components/FormElements/Radio'; import Radio from '@/components/FormElements/Radio';
import Select from '@/components/FormElements/Select'; import Select from '@/components/FormElements/Select';
import Button from '@/components/FormElements/Button';
import StoreKeys from '@/utils/StoreMutations'; import StoreKeys from '@/utils/StoreMutations';
import DashySchema from '@/utils/ConfigSchema'; import DashySchema from '@/utils/ConfigSchema';
import { modalNames } from '@/utils/defaults'; import { modalNames } from '@/utils/defaults';
@ -102,9 +102,9 @@ export default {
Input, Input,
Radio, Radio,
Select, Select,
Button,
AddIcon, AddIcon,
BinIcon, BinIcon,
SaveCancelButtons,
}, },
mounted() { mounted() {
if (!this.isNew) { // Get existing item data if (!this.isNew) { // Get existing item data
@ -304,16 +304,6 @@ export default {
border-color: var(--interactive-editor-color); border-color: var(--interactive-editor-color);
background: var(--interactive-editor-background); background: var(--interactive-editor-background);
} }
button.edit-item-save-btn {
color: var(--interactive-editor-color);
border-color: var(--interactive-editor-color);
background: var(--interactive-editor-background);
&:hover {
color: var(--interactive-editor-background);
border-color: var(--interactive-editor-color);
background: var(--interactive-editor-color);
}
}
svg { svg {
path { fill: var(--interactive-editor-color); } path { fill: var(--interactive-editor-color); }
background: var(--interactive-editor-background); background: var(--interactive-editor-background);

View File

@ -1,11 +1,8 @@
<template> <template>
<modal <modal
:name="modalName" :name="modalName" @closed="modalClosed"
:resizable="true" :resizable="true" width="50%" height="80%"
width="50%"
height="80%"
classes="dashy-modal edit-page-info" classes="dashy-modal edit-page-info"
@closed="modalClosed"
> >
<div class="edit-page-info-inner"> <div class="edit-page-info-inner">
<h3>{{ $t('interactive-editor.menu.edit-page-info-btn') }}</h3> <h3>{{ $t('interactive-editor.menu.edit-page-info-btn') }}</h3>
@ -19,7 +16,7 @@
<Button type="submit"> <Button type="submit">
{{ $t('interactive-editor.menu.save-stage-btn') }} {{ $t('interactive-editor.menu.save-stage-btn') }}
<SaveIcon /> <SaveIcon />
</button> </Button>
</FormSchema> </FormSchema>
</div> </div>
</modal> </modal>
@ -42,7 +39,6 @@ export default {
modalName: modalNames.EDIT_PAGE_INFO, modalName: modalNames.EDIT_PAGE_INFO,
}; };
}, },
props: {},
components: { components: {
FormSchema, FormSchema,
Button, Button,

View File

@ -8,15 +8,17 @@
@closed="modalClosed" @closed="modalClosed"
> >
<div class="edit-section-inner"> <div class="edit-section-inner">
<h3>Edit Section</h3> <h3>{{ $t('interactive-editor.edit-section.edit-section-title') }}</h3>
<FormSchema <FormSchema
:schema="customSchema" :schema="customSchema"
v-model="sectionData" v-model="sectionData"
name="editSectionForm" name="editSectionForm"
class="edit-section-form" class="edit-section-form"
/> />
<!-- Save to state button --> <SaveCancelButtons
<Button class="edit-section-save-btn" :click="saveSection">Save</Button> :saveClick="saveSection"
:cancelClick="modalClosed"
/>
</div> </div>
</modal> </modal>
</template> </template>
@ -25,8 +27,8 @@
import FormSchema from '@formschema/native'; import FormSchema from '@formschema/native';
import StoreKeys from '@/utils/StoreMutations'; import StoreKeys from '@/utils/StoreMutations';
import DashySchema from '@/utils/ConfigSchema'; import DashySchema from '@/utils/ConfigSchema';
import Button from '@/components/FormElements/Button';
import { modalNames } from '@/utils/defaults'; import { modalNames } from '@/utils/defaults';
import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons';
export default { export default {
name: 'EditSection', name: 'EditSection',
@ -34,7 +36,7 @@ export default {
sectionIndex: Number, sectionIndex: Number,
}, },
components: { components: {
Button, SaveCancelButtons,
FormSchema, FormSchema,
}, },
data() { data() {

View File

@ -23,16 +23,7 @@
label="Append To" label="Append To"
:initialOption="appendTo" :initialOption="appendTo"
/> />
<div class="button-wrapper"> <SaveCancelButtons :saveClick="save" :cancelClick="close" />
<Button class="save-move" :click="save">
{{ $t('interactive-editor.menu.save-stage-btn') }}
<SaveIcon />
</Button>
<Button class="save-move" :click="close">
{{ $t('interactive-editor.menu.cancel-stage-btn') }}
<CancelIcon />
</Button>
</div>
</div> </div>
</modal> </modal>
</template> </template>
@ -40,9 +31,7 @@
<script> <script>
import Select from '@/components/FormElements/Select'; import Select from '@/components/FormElements/Select';
import Radio from '@/components/FormElements/Radio'; import Radio from '@/components/FormElements/Radio';
import Button from '@/components/FormElements/Button'; import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons';
import SaveIcon from '@/assets/interface-icons/save-config.svg';
import CancelIcon from '@/assets/interface-icons/config-close.svg';
import StoreKeys from '@/utils/StoreMutations'; import StoreKeys from '@/utils/StoreMutations';
import { modalNames } from '@/utils/defaults'; import { modalNames } from '@/utils/defaults';
@ -51,9 +40,7 @@ export default {
components: { components: {
Select, Select,
Radio, Radio,
Button, SaveCancelButtons,
SaveIcon,
CancelIcon,
}, },
props: { props: {
itemId: String, // Unique ID for item itemId: String, // Unique ID for item

View File

@ -0,0 +1,61 @@
<template>
<div class="save-cancel-btn-container">
<Button class="save-app-config-btn" :click="saveClick">
{{ $t('interactive-editor.menu.save-stage-btn') }}
<SaveIcon />
</Button>
<Button class="save-app-config-btn" :click="cancelClick">
{{ $t('interactive-editor.menu.cancel-stage-btn') }}
<CancelIcon />
</Button>
</div>
</template>
<script>
import Button from '@/components/FormElements/Button';
import SaveIcon from '@/assets/interface-icons/save-config.svg';
import CancelIcon from '@/assets/interface-icons/config-close.svg';
export default {
name: 'SaveCancelButton',
props: {
saveClick: Function,
cancelClick: Function,
},
components: {
Button,
SaveIcon,
CancelIcon,
},
};
</script>
<style scoped lang="scss">
.save-cancel-btn-container {
display: flex;
margin: 0.5rem 0;
justify-content: center;
border-top: 1px dashed var(--interactive-editor-color);
button {
margin: 1rem 0.5rem;
color: var(--interactive-editor-color);
border-color: var(--interactive-editor-color);
background: var(--interactive-editor-background);
svg {
border: none;
width: 1.2rem;
height: 1.2rem;
}
&:hover {
color: var(--interactive-editor-background);
border-color: var(--interactive-editor-color);
background: var(--interactive-editor-color);
svg {
background: var(--interactive-editor-color);
path { fill: var(--interactive-editor-background); }
}
}
}
}
</style>

View File

@ -33,7 +33,7 @@
<EditModeIcon v-if="isEditMode" class="edit-mode-item" @click="openItemSettings()" /> <EditModeIcon v-if="isEditMode" class="edit-mode-item" @click="openItemSettings()" />
</a> </a>
<ContextMenu <ContextMenu
:show="contextMenuOpen" :show="contextMenuOpen && !isAddNew"
v-click-outside="closeContextMenu" v-click-outside="closeContextMenu"
:posX="contextPos.posX" :posX="contextPos.posX"
:posY="contextPos.posY" :posY="contextPos.posY"
@ -86,14 +86,14 @@ export default {
type: String, type: String,
validator: targetValidator, validator: targetValidator,
}, },
itemSize: String, itemSize: String, // Item size: small | medium | large
enableStatusCheck: Boolean, enableStatusCheck: Boolean, // Should run status checks
statusCheckHeaders: Object, statusCheckHeaders: Object, // Custom status check headers
statusCheckUrl: String, statusCheckUrl: String, // Custom URL for status check endpoint
statusCheckInterval: Number, statusCheckInterval: Number, // Num seconds beteween repeating checks
statusCheckAllowInsecure: Boolean, statusCheckAllowInsecure: Boolean, // Status check ignore SSL certs
parentSectionTitle: String, parentSectionTitle: String, // Title of parent section (for add new)
isAddNew: Boolean, isAddNew: Boolean, // Only set if 'fake' item used as Add New button
}, },
components: { components: {
Icon, Icon,

View File

@ -5,41 +5,41 @@
<!-- Open Options --> <!-- Open Options -->
<ul class="menu-section"> <ul class="menu-section">
<li class="section-title"> <li class="section-title">
{{ $t('menu.open-section-title') }} {{ $t('context-menus.item.open-section-title') }}
</li> </li>
<li @click="launch('sametab')"> <li @click="launch('sametab')">
<SameTabOpenIcon /> <SameTabOpenIcon />
<span>{{ $t('menu.sametab') }}</span> <span>{{ $t('context-menus.item.sametab') }}</span>
</li> </li>
<li @click="launch('newtab')"> <li @click="launch('newtab')">
<NewTabOpenIcon /> <NewTabOpenIcon />
<span>{{ $t('menu.newtab') }}</span> <span>{{ $t('context-menus.item.newtab') }}</span>
</li> </li>
<li @click="launch('modal')"> <li @click="launch('modal')">
<IframeOpenIcon /> <IframeOpenIcon />
<span>{{ $t('menu.modal') }}</span> <span>{{ $t('context-menus.item.modal') }}</span>
</li> </li>
<li @click="launch('workspace')"> <li @click="launch('workspace')">
<WorkspaceOpenIcon /> <WorkspaceOpenIcon />
<span>{{ $t('menu.workspace') }}</span> <span>{{ $t('context-menus.item.workspace') }}</span>
</li> </li>
</ul> </ul>
<!-- Edit Options --> <!-- Edit Options -->
<ul class="menu-section"> <ul class="menu-section">
<li class="section-title"> <li class="section-title">
{{ $t('menu.options-section-title') }} {{ $t('context-menus.item.options-section-title') }}
</li> </li>
<li @click="openSettings()"> <li @click="openSettings()">
<EditIcon /> <EditIcon />
<span>{{ $t('menu.edit-item') }}</span> <span>{{ $t('context-menus.item.edit-item') }}</span>
</li> </li>
<li v-if="isEditMode" @click="openMoveMenu()"> <li v-if="isEditMode" @click="openMoveMenu()">
<MoveIcon /> <MoveIcon />
<span>{{ $t('menu.move-item') }}</span> <span>{{ $t('context-menus.item.move-item') }}</span>
</li> </li>
<li v-if="isEditMode" @click="openDeleteItem()"> <li v-if="isEditMode" @click="openDeleteItem()">
<BinIcon /> <BinIcon />
<span>{{ $t('menu.remove-item') }}</span> <span>{{ $t('context-menus.item.remove-item') }}</span>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -238,8 +238,12 @@ export default {
}, },
/* Deletes current section, in local state */ /* Deletes current section, in local state */
removeSection() { removeSection() {
const payload = { sectionIndex: this.index, sectionName: this.title }; const confirmMsg = this.$t('interactive-editor.edit-section.remove-confirm');
this.$store.commit(StoreKeys.REMOVE_SECTION, payload); 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(); this.closeContextMenu();
}, },
/* Open custom context menu, and set position */ /* Open custom context menu, and set position */