mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-25 22:55:32 +02:00
✨ Show banner when in edit mode
This commit is contained in:
parent
5aefbb272f
commit
159748e3de
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="dashy">
|
<div id="dashy">
|
||||||
|
<EditModeTopBanner v-if="isEditMode" />
|
||||||
<LoadingScreen :isLoading="isLoading" v-if="shouldShowSplash" />
|
<LoadingScreen :isLoading="isLoading" v-if="shouldShowSplash" />
|
||||||
<Header :pageInfo="pageInfo" />
|
<Header :pageInfo="pageInfo" />
|
||||||
<router-view />
|
<router-view />
|
||||||
@ -10,6 +11,7 @@
|
|||||||
|
|
||||||
import Header from '@/components/PageStrcture/Header.vue';
|
import Header from '@/components/PageStrcture/Header.vue';
|
||||||
import Footer from '@/components/PageStrcture/Footer.vue';
|
import Footer from '@/components/PageStrcture/Footer.vue';
|
||||||
|
import EditModeTopBanner from '@/components/InteractiveEditor/EditModeTopBanner.vue';
|
||||||
import LoadingScreen from '@/components/PageStrcture/LoadingScreen.vue';
|
import LoadingScreen from '@/components/PageStrcture/LoadingScreen.vue';
|
||||||
import { welcomeMsg } from '@/utils/CoolConsole';
|
import { welcomeMsg } from '@/utils/CoolConsole';
|
||||||
import ErrorHandler from '@/utils/ErrorHandler';
|
import ErrorHandler from '@/utils/ErrorHandler';
|
||||||
@ -27,6 +29,7 @@ export default {
|
|||||||
Header,
|
Header,
|
||||||
Footer,
|
Footer,
|
||||||
LoadingScreen,
|
LoadingScreen,
|
||||||
|
EditModeTopBanner,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -57,6 +60,9 @@ export default {
|
|||||||
visibleComponents() {
|
visibleComponents() {
|
||||||
return this.$store.getters.visibleComponents;
|
return this.$store.getters.visibleComponents;
|
||||||
},
|
},
|
||||||
|
isEditMode() {
|
||||||
|
return this.$store.state.editMode;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.$store.dispatch('initializeConfig');
|
this.$store.dispatch('initializeConfig');
|
||||||
|
@ -152,10 +152,17 @@ export default {
|
|||||||
},
|
},
|
||||||
/* Saves the updated item to VueX Store */
|
/* Saves the updated item to VueX Store */
|
||||||
saveItem() {
|
saveItem() {
|
||||||
|
// Convert form data back into section.item data structure
|
||||||
const structured = {};
|
const structured = {};
|
||||||
this.formData.forEach((row) => { structured[row.name] = row.value; });
|
this.formData.forEach((row) => { structured[row.name] = row.value; });
|
||||||
|
// Some attributes need a little extra formatting
|
||||||
const newItem = this.formatBeforeSave(structured);
|
const newItem = this.formatBeforeSave(structured);
|
||||||
|
// Update the data store, with new item data
|
||||||
this.$store.commit(StoreKeys.UPDATE_ITEM, { newItem, itemId: this.itemId });
|
this.$store.commit(StoreKeys.UPDATE_ITEM, { newItem, itemId: this.itemId });
|
||||||
|
// If we're not already in edit mode, enable it now
|
||||||
|
this.$store.commit(StoreKeys.SET_EDIT_MODE, true);
|
||||||
|
// Close edit menu
|
||||||
|
this.$emit('closeEditMenu');
|
||||||
},
|
},
|
||||||
/* Adds filed from extras list to main form, then removes from extras list */
|
/* Adds filed from extras list to main form, then removes from extras list */
|
||||||
appendNewField(fieldId) {
|
appendNewField(fieldId) {
|
||||||
|
20
src/components/InteractiveEditor/EditModeTopBanner.vue
Normal file
20
src/components/InteractiveEditor/EditModeTopBanner.vue
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<div class="edit-mode-top-banner">
|
||||||
|
<span>Edit Mode Enabled</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
div.edit-mode-top-banner {
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
padding: 0.2rem 0;
|
||||||
|
background: var(--primary);
|
||||||
|
opacity: var(--dimming-factor);
|
||||||
|
span {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--background);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -13,12 +13,14 @@ const {
|
|||||||
SET_MODAL_OPEN,
|
SET_MODAL_OPEN,
|
||||||
SET_LANGUAGE,
|
SET_LANGUAGE,
|
||||||
UPDATE_ITEM,
|
UPDATE_ITEM,
|
||||||
|
SET_EDIT_MODE,
|
||||||
} = Keys;
|
} = Keys;
|
||||||
|
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
config: {},
|
config: {},
|
||||||
lang: '', // The users language, auto-detected or read from local storage / config
|
lang: '', // The users language, auto-detected or read from local storage / config
|
||||||
|
editMode: false, // While true, the user can drag and edit items + sections
|
||||||
modalOpen: false, // KB shortcut functionality will be disabled when modal is open
|
modalOpen: false, // KB shortcut functionality will be disabled when modal is open
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
@ -59,6 +61,9 @@ const store = new Vuex.Store({
|
|||||||
[SET_MODAL_OPEN](state, modalOpen) {
|
[SET_MODAL_OPEN](state, modalOpen) {
|
||||||
state.modalOpen = modalOpen;
|
state.modalOpen = modalOpen;
|
||||||
},
|
},
|
||||||
|
[SET_EDIT_MODE](state, editMode) {
|
||||||
|
state.editMode = editMode;
|
||||||
|
},
|
||||||
[UPDATE_ITEM](state, payload) {
|
[UPDATE_ITEM](state, payload) {
|
||||||
const { itemId, newItem } = payload;
|
const { itemId, newItem } = payload;
|
||||||
const newConfig = state.config;
|
const newConfig = state.config;
|
||||||
|
@ -4,6 +4,7 @@ const KEY_NAMES = [
|
|||||||
'SET_MODAL_OPEN',
|
'SET_MODAL_OPEN',
|
||||||
'SET_LANGUAGE',
|
'SET_LANGUAGE',
|
||||||
'UPDATE_ITEM',
|
'UPDATE_ITEM',
|
||||||
|
'SET_EDIT_MODE',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Convert array of key names into an object, and export
|
// Convert array of key names into an object, and export
|
||||||
|
Loading…
x
Reference in New Issue
Block a user