Feat(tag): modal for adding keywords to tag

This commit is contained in:
2019-01-30 15:41:27 +01:00
parent d486268921
commit af2330d2fa
4 changed files with 128 additions and 7 deletions

View File

@@ -37,19 +37,22 @@ export default {
},
mutations: {
SET_TAGS: (state, { tags }) => {
// Set tags list
state.tags = Object.keys(tags)
.reduce((c, k) => (c[k.toLowerCase()] = tags[k], c), {})
},
APPEND_TAG: (state, { tag }) => {
// Append or replace et tag
Vue.set(state.tags, tag.name.toLowerCase(), tag)
},
DELETE_TAG: (state, { tagname }) => {
// delete tag by its name
Vue.delete(state.tags, tagname.toLowerCase())
},
SET_CATEGORIES: (state, { categories }) => {
state.categories = Object.keys(categories)
.reduce((c, k) => (c[k.toLowerCase()] = categories[k], c), {})
}
},
},
actions: {
load (context) {
@@ -88,6 +91,11 @@ export default {
// Revome a tag from the config
context.commit('DELETE_TAG', { tagname: tagname })
context.dispatch('save')
},
append_keywords (context, { tagName, keyword }) {
var tag = context.getters.tag(tagName)
tag.words.push(keyword)
context.dispatch('edit_tag', tag)
}
}
}