1 const draggable = require('vuedraggable');
2 const autosuggest = require('./components/autosuggest');
9 const components = {draggable, autosuggest};
10 const directives = {};
17 this.tags.push({name: '', value: '', key: Math.random().toString(36).substring(7)});
21 * When an tag changes check if another empty editable field needs to be added onto the end.
25 let tagPos = this.tags.indexOf(tag);
26 if (tagPos === this.tags.length-1 && (tag.name !== '' || tag.value !== '')) this.addEmptyTag();
30 * When an tag field loses focus check the tag to see if its
31 * empty and therefore could be removed from the list.
35 let isLast = (this.tags.indexOf(tag) === this.tags.length-1);
36 if (tag.name !== '' || tag.value !== '' || isLast) return;
37 let cPos = this.tags.indexOf(tag);
38 this.tags.splice(cPos, 1);
42 let tagPos = this.tags.indexOf(tag);
43 if (tagPos === -1) return;
44 this.tags.splice(tagPos, 1);
47 getTagFieldName(index, key) {
48 return `tags[${index}][${key}]`;
53 this.pageId = Number(this.$el.getAttribute('page-id'));
55 let url = window.baseUrl(`/ajax/tags/get/page/${this.pageId}`);
56 this.$http.get(url).then(response => {
57 let tags = response.data;
58 for (let i = 0, len = tags.length; i < len; i++) {
59 tags[i].key = Math.random().toString(36).substring(7);
67 data, computed, methods, mounted, components, directives