Make custom tags work.
--- a/src_js/iconolab-bundle/src/components/tagform/Typeahead.vue Fri Feb 24 16:56:30 2017 +0100
+++ b/src_js/iconolab-bundle/src/components/tagform/Typeahead.vue Fri Feb 24 17:35:16 2017 +0100
@@ -14,7 +14,8 @@
@input="update" />
<ul v-show="hasItems">
<li v-for="(item, index) in items" :class="activeClass(index)" @mousedown="hit" @mousemove="setActive(index)">
- <span v-text="item.tag_label"></span>
+ <span class="tag-label" v-text="item.tag_label"></span>
+ <span class="pull-right text-muted" v-if="!item.tag_link.startsWith('http')">créer</span>
</li>
</ul>
</div>
@@ -59,7 +60,7 @@
src: autoCompletePath,
limit: 7,
minChars: 2,
- showAddButton: false,
+ selectFirst: true,
datasource: "wikipedia",
selectedTags: "[]",
items: [],
@@ -112,7 +113,6 @@
},
reset () {
- this.showAddButton = false;
parentsMethods.reset.call(this);
},
@@ -147,8 +147,14 @@
responseData = this.prepareWikipediaResponse(responseData);
}
+ // When no tags found, create a custom tag
if (Array.isArray(responseData) && !responseData.length) {
- this.showAddButton = true;
+ return [{
+ tag_label: this.query,
+ tag_link: this.query,
+ accuracy: null,
+ relevancy: null
+ }];
}
return responseData;
},
--- a/src_js/iconolab-bundle/src/components/tagform/typeahead.css Fri Feb 24 16:56:30 2017 +0100
+++ b/src_js/iconolab-bundle/src/components/tagform/typeahead.css Fri Feb 24 17:35:16 2017 +0100
@@ -51,8 +51,7 @@
border-radius: 0 0 4px 4px;
border-bottom: 0;
}
-span {
- display: block;
+span.tag-label {
color: #2c3e50;
}
.active {