2018-09-17 02:00:20 +02:00
|
|
|
<template>
|
|
|
|
<div class="vfcitkilproprqtbnpoertpsziierwzi">
|
2018-12-09 06:24:24 +01:00
|
|
|
<div v-for="timeline in timelines" class="timeline" :key="timeline.id">
|
2018-09-17 02:00:20 +02:00
|
|
|
<ui-input v-model="timeline.title" @change="save">
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('title') }}</span>
|
2018-09-17 02:00:20 +02:00
|
|
|
</ui-input>
|
2018-12-09 06:24:24 +01:00
|
|
|
<ui-textarea :value="timeline.query ? timeline.query.map(tags => tags.join(' ')).join('\n') : ''" :pre="true" @input="onQueryChange(timeline, $event)">
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('query') }}</span>
|
2018-09-17 02:00:20 +02:00
|
|
|
</ui-textarea>
|
|
|
|
</div>
|
2018-11-08 19:44:35 +01:00
|
|
|
<ui-button class="add" @click="add">{{ $t('add') }}</ui-button>
|
2018-12-09 06:24:24 +01:00
|
|
|
<ui-button class="save" @click="save">{{ $t('save') }}</ui-button>
|
2018-09-17 02:00:20 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2019-03-01 02:42:28 +01:00
|
|
|
import i18n from '../../../../i18n';
|
2018-09-17 02:00:20 +02:00
|
|
|
import * as uuid from 'uuid';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n('desktop/views/components/settings.tags.vue'),
|
2018-09-17 02:00:20 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
timelines: this.$store.state.settings.tagTimelines
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
add() {
|
|
|
|
this.timelines.push({
|
|
|
|
id: uuid(),
|
|
|
|
title: '',
|
|
|
|
query: ''
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
save() {
|
2018-12-09 06:24:24 +01:00
|
|
|
const timelines = this.timelines
|
|
|
|
.filter(timeline => timeline.title)
|
|
|
|
.map(timeline => {
|
|
|
|
if (!(timeline.query && timeline.query[0] && timeline.query[0][0])) {
|
|
|
|
timeline.query = timeline.title.split('\n').map(tags => tags.split(' '));
|
|
|
|
}
|
|
|
|
return timeline;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$store.dispatch('settings/set', { key: 'tagTimelines', value: timelines });
|
2018-09-17 02:00:20 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
onQueryChange(timeline, value) {
|
|
|
|
timeline.query = value.split('\n').map(tags => tags.split(' '));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 12:59:19 +02:00
|
|
|
.vfcitkilproprqtbnpoertpsziierwzi
|
2018-09-17 02:00:20 +02:00
|
|
|
> .timeline
|
|
|
|
padding-bottom 16px
|
|
|
|
border-bottom solid 1px rgba(#000, 0.1)
|
|
|
|
|
|
|
|
> .add
|
|
|
|
margin-top 16px
|
|
|
|
|
|
|
|
</style>
|