2018-06-06 12:22:45 +02:00
|
|
|
<template>
|
2018-06-08 00:43:12 +02:00
|
|
|
<x-column :menu="menu" :naked="true" :narrow="true" :name="name" :column="column" :is-stacked="isStacked" class="wtdtxvecapixsepjtcupubtsmometobz">
|
2018-11-05 17:40:11 +01:00
|
|
|
<span slot="header"><fa icon="calculator"/>{{ name }}</span>
|
2018-06-06 12:22:45 +02:00
|
|
|
|
2018-06-07 21:21:06 +02:00
|
|
|
<div class="gqpwvtwtprsbmnssnbicggtwqhmylhnq">
|
|
|
|
<template v-if="edit">
|
|
|
|
<header>
|
2018-06-12 01:58:50 +02:00
|
|
|
<select v-model="widgetAdderSelected" @change="addWidget">
|
2018-11-08 19:44:35 +01:00
|
|
|
<option value="profile">{{ $t('@.widgets.profile') }}</option>
|
|
|
|
<option value="analog-clock">{{ $t('@.widgets.analog-clock') }}</option>
|
|
|
|
<option value="calendar">{{ $t('@.widgets.calendar') }}</option>
|
|
|
|
<option value="timemachine">{{ $t('@.widgets.timemachine') }}</option>
|
|
|
|
<option value="activity">{{ $t('@.widgets.activity') }}</option>
|
|
|
|
<option value="rss">{{ $t('@.widgets.rss') }}</option>
|
|
|
|
<option value="trends">{{ $t('@.widgets.trends') }}</option>
|
|
|
|
<option value="photo-stream">{{ $t('@.widgets.photo-stream') }}</option>
|
|
|
|
<option value="slideshow">{{ $t('@.widgets.slideshow') }}</option>
|
|
|
|
<option value="version">{{ $t('@.widgets.version') }}</option>
|
|
|
|
<option value="broadcast">{{ $t('@.widgets.broadcast') }}</option>
|
|
|
|
<option value="notifications">{{ $t('@.widgets.notifications') }}</option>
|
|
|
|
<option value="users">{{ $t('@.widgets.users') }}</option>
|
|
|
|
<option value="polls">{{ $t('@.widgets.polls') }}</option>
|
|
|
|
<option value="post-form">{{ $t('@.widgets.post-form') }}</option>
|
|
|
|
<option value="messaging">{{ $t('@.widgets.messaging') }}</option>
|
|
|
|
<option value="memo">{{ $t('@.widgets.memo') }}</option>
|
|
|
|
<option value="hashtags">{{ $t('@.widgets.hashtags') }}</option>
|
|
|
|
<option value="posts-monitor">{{ $t('@.widgets.posts-monitor') }}</option>
|
|
|
|
<option value="server">{{ $t('@.widgets.server') }}</option>
|
|
|
|
<option value="nav">{{ $t('@.widgets.nav') }}</option>
|
|
|
|
<option value="tips">{{ $t('@.widgets.tips') }}</option>
|
2018-06-07 21:21:06 +02:00
|
|
|
</select>
|
|
|
|
</header>
|
|
|
|
<x-draggable
|
|
|
|
:list="column.widgets"
|
2018-06-12 01:58:50 +02:00
|
|
|
:options="{ animation: 150 }"
|
2018-06-07 21:21:06 +02:00
|
|
|
@sort="onWidgetSort"
|
|
|
|
>
|
2018-06-12 01:58:50 +02:00
|
|
|
<div v-for="widget in column.widgets" class="customize-container" :key="widget.id" @contextmenu.stop.prevent="widgetFunc(widget.id)">
|
2018-11-05 17:40:11 +01:00
|
|
|
<button class="remove" @click="removeWidget(widget)"><fa icon="times"/></button>
|
2018-06-12 01:58:50 +02:00
|
|
|
<component :is="`mkw-${widget.name}`" :widget="widget" :ref="widget.id" :is-customize-mode="true" platform="deck"/>
|
2018-06-07 21:21:06 +02:00
|
|
|
</div>
|
|
|
|
</x-draggable>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<component class="widget" v-for="widget in column.widgets" :is="`mkw-${widget.name}`" :key="widget.id" :ref="widget.id" :widget="widget" platform="deck"/>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</x-column>
|
2018-06-06 12:22:45 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 19:44:35 +01:00
|
|
|
import i18n from '../../../../i18n';
|
2018-06-06 12:22:45 +02:00
|
|
|
import XColumn from './deck.column.vue';
|
|
|
|
import * as XDraggable from 'vuedraggable';
|
|
|
|
import * as uuid from 'uuid';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n(),
|
2018-06-06 12:22:45 +02:00
|
|
|
components: {
|
|
|
|
XColumn,
|
|
|
|
XDraggable
|
|
|
|
},
|
|
|
|
|
2018-06-07 22:48:27 +02:00
|
|
|
props: {
|
|
|
|
column: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
isStacked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2018-06-06 12:22:45 +02:00
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
edit: false,
|
|
|
|
menu: null,
|
|
|
|
widgetAdderSelected: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-06 23:13:57 +02:00
|
|
|
computed: {
|
|
|
|
name(): string {
|
|
|
|
if (this.column.name) return this.column.name;
|
2018-11-08 19:44:35 +01:00
|
|
|
return this.$t('@deck.widgets');
|
2018-06-06 23:13:57 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-06 12:22:45 +02:00
|
|
|
created() {
|
|
|
|
this.menu = [{
|
2018-11-05 17:40:11 +01:00
|
|
|
icon: 'cog',
|
2018-11-08 19:44:35 +01:00
|
|
|
text: this.$t('edit'),
|
2018-06-08 04:46:45 +02:00
|
|
|
action: () => {
|
2018-06-06 12:22:45 +02:00
|
|
|
this.edit = !this.edit;
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
widgetFunc(id) {
|
|
|
|
const w = this.$refs[id][0];
|
|
|
|
if (w.func) w.func();
|
|
|
|
},
|
|
|
|
|
|
|
|
onWidgetSort() {
|
|
|
|
this.saveWidgets();
|
|
|
|
},
|
|
|
|
|
|
|
|
addWidget() {
|
|
|
|
this.$store.dispatch('settings/addDeckWidget', {
|
|
|
|
id: this.column.id,
|
|
|
|
widget: {
|
|
|
|
name: this.widgetAdderSelected,
|
|
|
|
id: uuid(),
|
|
|
|
data: {}
|
|
|
|
}
|
|
|
|
});
|
2018-06-17 06:52:52 +02:00
|
|
|
|
|
|
|
this.widgetAdderSelected = null;
|
2018-06-06 12:22:45 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
removeWidget(widget) {
|
|
|
|
this.$store.dispatch('settings/removeDeckWidget', {
|
|
|
|
id: this.column.id,
|
|
|
|
widget
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
saveWidgets() {
|
|
|
|
this.$store.dispatch('settings/saveDeck');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 08:34:34 +02:00
|
|
|
.wtdtxvecapixsepjtcupubtsmometobz
|
2018-06-06 12:22:45 +02:00
|
|
|
.gqpwvtwtprsbmnssnbicggtwqhmylhnq
|
2018-06-12 01:58:50 +02:00
|
|
|
> header
|
|
|
|
padding 16px
|
|
|
|
|
|
|
|
> *
|
|
|
|
width 100%
|
|
|
|
padding 4px
|
|
|
|
|
2018-06-06 12:22:45 +02:00
|
|
|
.widget, .customize-container
|
|
|
|
margin 8px
|
|
|
|
|
|
|
|
&:first-of-type
|
|
|
|
margin-top 0
|
|
|
|
|
|
|
|
.customize-container
|
2018-06-12 01:58:50 +02:00
|
|
|
cursor move
|
|
|
|
|
|
|
|
> *:not(.remove)
|
|
|
|
pointer-events none
|
|
|
|
|
|
|
|
> .remove
|
|
|
|
position absolute
|
|
|
|
z-index 1
|
|
|
|
top 8px
|
|
|
|
right 8px
|
|
|
|
width 32px
|
|
|
|
height 32px
|
|
|
|
color #fff
|
|
|
|
background rgba(#000, 0.7)
|
|
|
|
border-radius 4px
|
2018-06-06 12:22:45 +02:00
|
|
|
|
|
|
|
</style>
|
|
|
|
|