Improve tags settings (#3569)

This commit is contained in:
MeiMei 2018-12-09 14:24:24 +09:00 committed by syuilo
parent fd3f4c37a0
commit 7e1cad3e12
3 changed files with 30 additions and 7 deletions

View file

@ -990,6 +990,12 @@ desktop/views/components/sub-note-content.vue:
media-count: "{}つのメディア" media-count: "{}つのメディア"
poll: "アンケート" poll: "アンケート"
desktop/views/components/settings.tags.vue:
title: "タグ"
query: "クエリ (省略可)"
add: "追加"
save: "保存"
desktop/views/components/taskmanager.vue: desktop/views/components/taskmanager.vue:
title: "タスクマネージャ" title: "タスクマネージャ"

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="ui-textarea" :class="{ focused, filled, tall }"> <div class="ui-textarea" :class="{ focused, filled, tall, pre }">
<div class="input"> <div class="input">
<span class="label" ref="label"><slot></slot></span> <span class="label" ref="label"><slot></slot></span>
<textarea ref="input" <textarea ref="input"
@ -46,6 +46,11 @@ export default Vue.extend({
required: false, required: false,
default: false default: false
}, },
pre: {
type: Boolean,
required: false,
default: false
},
}, },
data() { data() {
return { return {
@ -175,6 +180,11 @@ root(fill)
> textarea > textarea
min-height 200px min-height 200px
&.pre
> .input
> textarea
white-space pre
.ui-textarea.fill .ui-textarea.fill
root(true) root(true)

View file

@ -1,15 +1,15 @@
<template> <template>
<div class="vfcitkilproprqtbnpoertpsziierwzi"> <div class="vfcitkilproprqtbnpoertpsziierwzi">
<div v-for="timeline in timelines" class="timeline"> <div v-for="timeline in timelines" class="timeline" :key="timeline.id">
<ui-input v-model="timeline.title" @change="save"> <ui-input v-model="timeline.title" @change="save">
<span>{{ $t('title') }}</span> <span>{{ $t('title') }}</span>
</ui-input> </ui-input>
<ui-textarea :value="timeline.query ? timeline.query.map(tags => tags.join(' ')).join('\n') : ''" @input="onQueryChange(timeline, $event)"> <ui-textarea :value="timeline.query ? timeline.query.map(tags => tags.join(' ')).join('\n') : ''" :pre="true" @input="onQueryChange(timeline, $event)">
<span>{{ $t('query') }}</span> <span>{{ $t('query') }}</span>
</ui-textarea> </ui-textarea>
<ui-button class="save" @click="save">{{ $t('save') }}</ui-button>
</div> </div>
<ui-button class="add" @click="add">{{ $t('add') }}</ui-button> <ui-button class="add" @click="add">{{ $t('add') }}</ui-button>
<ui-button class="save" @click="save">{{ $t('save') }}</ui-button>
</div> </div>
</template> </template>
@ -33,12 +33,19 @@ export default Vue.extend({
title: '', title: '',
query: '' query: ''
}); });
this.save();
}, },
save() { save() {
this.$store.dispatch('settings/set', { key: 'tagTimelines', value: this.timelines }); 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 });
}, },
onQueryChange(timeline, value) { onQueryChange(timeline, value) {