Make custom tags work.
authorAlexandre Segura <mex.zktk@gmail.com>
Fri, 24 Feb 2017 17:35:16 +0100
changeset 390 d2187b1af744
parent 389 583a366e298c
child 391 7ab1cc12827e
Make custom tags work.
src_js/iconolab-bundle/src/components/tagform/Typeahead.vue
src_js/iconolab-bundle/src/components/tagform/typeahead.css
--- 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 {