2021-04-10 03:40:50 +00:00
|
|
|
<template>
|
|
|
|
<div class="efzpzdvf">
|
|
|
|
<XWidgets :edit="editMode" :widgets="$store.reactiveState.widgets.value" @add-widget="addWidget" @remove-widget="removeWidget" @update-widget="updateWidget" @update-widgets="updateWidgets" @exit="editMode = false"/>
|
|
|
|
|
2021-04-20 14:22:59 +00:00
|
|
|
<button v-if="editMode" @click="editMode = false" class="_textButton" style="font-size: 0.9em;"><i class="fas fa-check"></i> {{ $ts.editWidgetsExit }}</button>
|
|
|
|
<button v-else @click="editMode = true" class="_textButton" style="font-size: 0.9em;"><i class="fas fa-pencil-alt"></i> {{ $ts.editWidgets }}</button>
|
2021-04-10 03:40:50 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent, defineAsyncComponent } from 'vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import XWidgets from '@/components/widgets.vue';
|
|
|
|
import * as os from '@/os';
|
2021-04-10 03:40:50 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
XWidgets
|
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['mounted'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
editMode: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.$emit('mounted', this.$el);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
addWidget(widget) {
|
|
|
|
this.$store.set('widgets', [{
|
|
|
|
...widget,
|
|
|
|
place: null,
|
|
|
|
}, ...this.$store.state.widgets]);
|
|
|
|
},
|
|
|
|
|
|
|
|
removeWidget(widget) {
|
|
|
|
this.$store.set('widgets', this.$store.state.widgets.filter(w => w.id != widget.id));
|
|
|
|
},
|
|
|
|
|
|
|
|
updateWidget({ id, data }) {
|
|
|
|
this.$store.set('widgets', this.$store.state.widgets.map(w => w.id === id ? {
|
|
|
|
...w,
|
|
|
|
data: data
|
|
|
|
} : w));
|
|
|
|
},
|
|
|
|
|
|
|
|
updateWidgets(widgets) {
|
|
|
|
this.$store.set('widgets', widgets);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.efzpzdvf {
|
|
|
|
position: sticky;
|
|
|
|
height: min-content;
|
|
|
|
min-height: 100vh;
|
|
|
|
padding: var(--margin) 0;
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
> * {
|
|
|
|
margin: var(--margin) 0;
|
|
|
|
width: 300px;
|
|
|
|
|
|
|
|
&:first-child {
|
|
|
|
margin-top: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .add {
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|