mirror of https://github.com/Lissy93/dashy.git
🚧 Working on `pages` form in interactive editor
This commit is contained in:
parent
9ca11a5f63
commit
3347dc9f61
|
@ -51,10 +51,11 @@
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<!-- Open Modal Buttons -->
|
<!-- Open Modal Buttons -->
|
||||||
<div class="edit-banner-section edit-site-config-buttons">
|
<div class="edit-banner-section edit-config-buttons-container">
|
||||||
<p class="section-sub-title">
|
<p class="section-sub-title">
|
||||||
{{ $t('interactive-editor.menu.edit-site-data-subheading') }}
|
{{ $t('interactive-editor.menu.edit-site-data-subheading') }}
|
||||||
</p>
|
</p>
|
||||||
|
<!-- Button to open pageInfo editor -->
|
||||||
<Button
|
<Button
|
||||||
:click="openEditPageInfo"
|
:click="openEditPageInfo"
|
||||||
:disallow="!permissions.allowViewConfig"
|
:disallow="!permissions.allowViewConfig"
|
||||||
|
@ -63,6 +64,7 @@
|
||||||
{{ $t('interactive-editor.menu.edit-page-info-btn') }}
|
{{ $t('interactive-editor.menu.edit-page-info-btn') }}
|
||||||
<PageInfoIcon />
|
<PageInfoIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
<!-- Button to open appConfig editor -->
|
||||||
<Button
|
<Button
|
||||||
:click="openEditAppConfig"
|
:click="openEditAppConfig"
|
||||||
:disallow="!permissions.allowViewConfig"
|
:disallow="!permissions.allowViewConfig"
|
||||||
|
@ -71,10 +73,20 @@
|
||||||
{{ $t('interactive-editor.menu.edit-app-config-btn') }}
|
{{ $t('interactive-editor.menu.edit-app-config-btn') }}
|
||||||
<AppConfigIcon />
|
<AppConfigIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
<!-- Button to open pages editor -->
|
||||||
|
<Button
|
||||||
|
:click="openEditMultiPages"
|
||||||
|
:disallow="!permissions.allowViewConfig"
|
||||||
|
v-tooltip="tooltip($t('interactive-editor.menu.edit-pages-tooltip'))"
|
||||||
|
>
|
||||||
|
{{ $t('interactive-editor.menu.edit-pages-btn') }}
|
||||||
|
<MultiPagesIcon />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<!-- Modals for editing appConfig + pageInfo -->
|
<!-- Modals for editing appConfig, pageInfo and pages -->
|
||||||
<EditPageInfo />
|
<EditPageInfo />
|
||||||
<EditAppConfig />
|
<EditAppConfig />
|
||||||
|
<EditMultiPages />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -84,6 +96,7 @@ import Button from '@/components/FormElements/Button';
|
||||||
import StoreKeys from '@/utils/StoreMutations';
|
import StoreKeys from '@/utils/StoreMutations';
|
||||||
import EditPageInfo from '@/components/InteractiveEditor/EditPageInfo';
|
import EditPageInfo from '@/components/InteractiveEditor/EditPageInfo';
|
||||||
import EditAppConfig from '@/components/InteractiveEditor/EditAppConfig';
|
import EditAppConfig from '@/components/InteractiveEditor/EditAppConfig';
|
||||||
|
import EditMultiPages from '@/components/InteractiveEditor/EditMultiPages';
|
||||||
import { modalNames } from '@/utils/defaults';
|
import { modalNames } from '@/utils/defaults';
|
||||||
import AccessError from '@/components/Configuration/AccessError';
|
import AccessError from '@/components/Configuration/AccessError';
|
||||||
|
|
||||||
|
@ -93,6 +106,7 @@ import ExportIcon from '@/assets/interface-icons/interactive-editor-export-chang
|
||||||
import CancelIcon from '@/assets/interface-icons/interactive-editor-cancel-changes.svg';
|
import CancelIcon from '@/assets/interface-icons/interactive-editor-cancel-changes.svg';
|
||||||
import AppConfigIcon from '@/assets/interface-icons/interactive-editor-app-config.svg';
|
import AppConfigIcon from '@/assets/interface-icons/interactive-editor-app-config.svg';
|
||||||
import PageInfoIcon from '@/assets/interface-icons/interactive-editor-page-info.svg';
|
import PageInfoIcon from '@/assets/interface-icons/interactive-editor-page-info.svg';
|
||||||
|
import MultiPagesIcon from '@/assets/interface-icons/config-pages.svg';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'EditModeSaveMenu',
|
name: 'EditModeSaveMenu',
|
||||||
|
@ -100,13 +114,15 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
Button,
|
Button,
|
||||||
EditPageInfo,
|
EditPageInfo,
|
||||||
|
EditAppConfig,
|
||||||
|
EditMultiPages,
|
||||||
SaveLocallyIcon,
|
SaveLocallyIcon,
|
||||||
SaveToDiskIcon,
|
SaveToDiskIcon,
|
||||||
ExportIcon,
|
ExportIcon,
|
||||||
CancelIcon,
|
CancelIcon,
|
||||||
AppConfigIcon,
|
AppConfigIcon,
|
||||||
PageInfoIcon,
|
PageInfoIcon,
|
||||||
EditAppConfig,
|
MultiPagesIcon,
|
||||||
AccessError,
|
AccessError,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -138,6 +154,10 @@ export default {
|
||||||
this.$modal.show(modalNames.EDIT_APP_CONFIG);
|
this.$modal.show(modalNames.EDIT_APP_CONFIG);
|
||||||
this.$store.commit(StoreKeys.SET_MODAL_OPEN, true);
|
this.$store.commit(StoreKeys.SET_MODAL_OPEN, true);
|
||||||
},
|
},
|
||||||
|
openEditMultiPages() {
|
||||||
|
this.$modal.show(modalNames.EDIT_MULTI_PAGES);
|
||||||
|
this.$store.commit(StoreKeys.SET_MODAL_OPEN, true);
|
||||||
|
},
|
||||||
tooltip(content) {
|
tooltip(content) {
|
||||||
return { content, trigger: 'hover focus', delay: 250 };
|
return { content, trigger: 'hover focus', delay: 250 };
|
||||||
},
|
},
|
||||||
|
@ -145,7 +165,11 @@ export default {
|
||||||
this.$toasted.show(message, { className: `toast-${success ? 'success' : 'error'}` });
|
this.$toasted.show(message, { className: `toast-${success ? 'success' : 'error'}` });
|
||||||
},
|
},
|
||||||
saveLocally() {
|
saveLocally() {
|
||||||
this.saveConfigLocally(this.config);
|
const msg = this.$t('interactive-editor.menu.save-locally-warning');
|
||||||
|
const youSure = confirm(msg); // eslint-disable-line no-alert, no-restricted-globals
|
||||||
|
if (youSure) {
|
||||||
|
this.saveConfigLocally(this.config);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
writeToDisk() {
|
writeToDisk() {
|
||||||
this.writeConfigToDisk(this.config);
|
this.writeConfigToDisk(this.config);
|
||||||
|
@ -168,14 +192,15 @@ div.edit-mode-bottom-banner {
|
||||||
background: var(--interactive-editor-background-darker);
|
background: var(--interactive-editor-background-darker);
|
||||||
box-shadow: 0 -5px 7px var(--transparent-50);
|
box-shadow: 0 -5px 7px var(--transparent-50);
|
||||||
grid-template-columns: 45% 10% 45%;
|
grid-template-columns: 45% 10% 45%;
|
||||||
@include laptop-up { grid-template-columns: 40% 20% 40%; }
|
@include laptop-up { grid-template-columns: 50% 10% 40%; }
|
||||||
@include monitor-up { grid-template-columns: 30% 40% 30%; }
|
@include monitor-up { grid-template-columns: 40% 30% 30%; }
|
||||||
@include big-screen-up { grid-template-columns: 25% 50% 25%; }
|
@include big-screen-up { grid-template-columns: 25% 50% 25%; }
|
||||||
|
|
||||||
/* Main sections */
|
/* Main sections */
|
||||||
.edit-banner-section {
|
.edit-banner-section {
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
height: 90%;
|
height: 90%;
|
||||||
|
display: grid;
|
||||||
/* Section sub-titles */
|
/* Section sub-titles */
|
||||||
p.section-sub-title {
|
p.section-sub-title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -196,22 +221,24 @@ div.edit-mode-bottom-banner {
|
||||||
padding: 0 0.5rem;
|
padding: 0 0.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
button {
|
||||||
|
margin: 0.25rem;
|
||||||
|
height: stretch;
|
||||||
|
max-height: 3rem;
|
||||||
|
}
|
||||||
/* Button containers */
|
/* Button containers */
|
||||||
&.edit-site-config-buttons,
|
&.edit-config-buttons-container {
|
||||||
&.save-buttons-container {
|
grid-template-columns: repeat(3, 1fr);
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(2, 1fr);
|
|
||||||
button {
|
|
||||||
margin: 0.25rem;
|
|
||||||
height: stretch;
|
|
||||||
max-height: 3rem;
|
|
||||||
}
|
|
||||||
p.section-sub-title {
|
p.section-sub-title {
|
||||||
grid-column-start: span 2;
|
grid-column-start: span 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&.save-buttons-container {
|
&.save-buttons-container {
|
||||||
grid-row-start: span 2;
|
grid-row-start: span 2;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
p.section-sub-title {
|
||||||
|
grid-column-start: span 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
<template>
|
||||||
|
<modal
|
||||||
|
:name="modalName" @closed="modalClosed"
|
||||||
|
:resizable="true" width="50%" height="80%"
|
||||||
|
classes="dashy-modal edit-multi-pages"
|
||||||
|
>
|
||||||
|
<div class="edit-multi-pages-inner" v-if="allowViewConfig">
|
||||||
|
<h3>{{ $t('interactive-editor.menu.edit-page-info-btn') }}</h3>
|
||||||
|
<FormSchema
|
||||||
|
:schema="schema"
|
||||||
|
v-model="formData"
|
||||||
|
@submit.prevent="saveToState"
|
||||||
|
class="multi-page-form"
|
||||||
|
name="multiPageForm"
|
||||||
|
>
|
||||||
|
<SaveCancelButtons :saveClick="saveToState" :cancelClick="cancelEditing" />
|
||||||
|
</FormSchema>
|
||||||
|
</div>
|
||||||
|
<AccessError v-else />
|
||||||
|
</modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import FormSchema from '@formschema/native';
|
||||||
|
import DashySchema from '@/utils/ConfigSchema';
|
||||||
|
import StoreKeys from '@/utils/StoreMutations';
|
||||||
|
import { modalNames } from '@/utils/defaults';
|
||||||
|
import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons';
|
||||||
|
import AccessError from '@/components/Configuration/AccessError';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'EditPageInfo',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
formData: {},
|
||||||
|
schema: DashySchema.properties.pages,
|
||||||
|
modalName: modalNames.EDIT_MULTI_PAGES,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
FormSchema,
|
||||||
|
SaveCancelButtons,
|
||||||
|
AccessError,
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.formData = this.pages;
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
pages() {
|
||||||
|
return this.$store.getters.pages;
|
||||||
|
},
|
||||||
|
allowViewConfig() {
|
||||||
|
return this.$store.getters.permissions.allowViewConfig;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/* When form submitted, update VueX store with new pageInfo, and close modal */
|
||||||
|
saveToState() {
|
||||||
|
this.$store.commit(StoreKeys.SET_PAGES, this.formData);
|
||||||
|
this.$modal.hide(this.modalName);
|
||||||
|
this.$store.commit(StoreKeys.SET_MODAL_OPEN, false);
|
||||||
|
this.$store.commit(StoreKeys.SET_EDIT_MODE, true);
|
||||||
|
},
|
||||||
|
/* Called when modal manually closed, updates state to allow searching again */
|
||||||
|
modalClosed() {
|
||||||
|
this.$store.commit(StoreKeys.SET_MODAL_OPEN, false);
|
||||||
|
},
|
||||||
|
cancelEditing() {
|
||||||
|
this.$modal.hide(this.modalName);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '@/styles/style-helpers.scss';
|
||||||
|
@import '@/styles/media-queries.scss';
|
||||||
|
@import '@/styles/schema-editor.scss';
|
||||||
|
|
||||||
|
.edit-multi-pages-inner {
|
||||||
|
padding: 1rem;
|
||||||
|
background: var(--interactive-editor-background);
|
||||||
|
color: var(--interactive-editor-color);
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
@extend .scroll-bar;
|
||||||
|
h3 {
|
||||||
|
font-size: 1.4rem;
|
||||||
|
margin: 0.5rem;
|
||||||
|
}
|
||||||
|
.multi-page-form {
|
||||||
|
@extend .schema-form;
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
fieldset div[data-fs-wrapper], fieldset div[data-fs-kind=object] {
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
[name=multiPageForm] button {
|
||||||
|
width: 8rem;
|
||||||
|
margin: 0 0.5rem 0.5rem 0.5rem;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
&[data-fs-button=push]::after { content: " Add New"; }
|
||||||
|
&[data-fs-button=moveUp]::after { content: " Move Up"; }
|
||||||
|
&[data-fs-button=moveDown]::after { content: " Move Down"; }
|
||||||
|
&[data-fs-button=delete]::after { content: " Delete"; }
|
||||||
|
}
|
||||||
|
div[data-fs-type=object] div[data-fs-type=object] {
|
||||||
|
div[data-fs-input=object] { border: none; }
|
||||||
|
label { display: none; }
|
||||||
|
div[data-fs-input=object] label { display: block; }
|
||||||
|
}
|
||||||
|
fieldset div[data-fs-kind=object] span {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
fieldset button[data-fs-button=push] {
|
||||||
|
min-width: 15rem;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
margin: 0.5rem 0;
|
||||||
|
font-size: 1rem;
|
||||||
|
color: var(--interactive-editor-color);
|
||||||
|
background: var(--interactive-editor-background);
|
||||||
|
border: 1px solid var(--interactive-editor-color);
|
||||||
|
border-radius: var(--curve-factor);
|
||||||
|
&:hover {
|
||||||
|
color: var(--interactive-editor-background);
|
||||||
|
background: var(--interactive-editor-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -56,6 +56,9 @@ export default {
|
||||||
path { fill: var(--interactive-editor-background); }
|
path { fill: var(--interactive-editor-background); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&:focus {
|
||||||
|
box-shadow: 1px 1px 6px var(--interactive-editor-color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue