Browse Source

fixed createMessage/ files Tag autocomplete

master
Senta Mandutz 5 years ago
parent
commit
4aa5856fbc
2 changed files with 22 additions and 22 deletions
  1. 16
    14
      public/routes/createMessage.js
  2. 6
    8
      public/search.js

+ 16
- 14
public/routes/createMessage.js View File

var tagArray = []; var tagArray = [];
const data=[];
const CreateMsgRouter = { const CreateMsgRouter = {
template: ` template: `
<div class="content"> <div class="content">
<b-taginput <b-taginput
id="tag" id="tag"
v-model="selected" v-model="selected"
:data=taglist
:data="filteredDataArray"
autocomplete autocomplete
allow-new:false allow-new:false
icon="label" icon="label"
placeholder="#" placeholder="#"
@typing="getFilteredTags"
@input="saveTagsToArray"> @input="saveTagsToArray">
</b-taginput> </b-taginput>
</b-field> </b-field>
<b-taginput <b-taginput
id="tag" id="tag"
v-model="selected" v-model="selected"
:data=taglist
:data="filteredDataArray"
autocomplete autocomplete
allow-new:false allow-new:false
icon="label" icon="label"
placeholder="#" placeholder="#"
@typing="getFilteredTags"
@input="saveTagsToArray"> @input="saveTagsToArray">
</b-taginput> </b-taginput>
</b-field> </b-field>
auth: auth, auth: auth,
isDisabled: false, isDisabled: false,
selected: [], selected: [],
searchtext : "",
taglist: data, taglist: data,
}; };
}, },
computed:{
filteredDataArray() {
return this.taglist.filter((option) => {
return option
.toString()
.toLowerCase()
.indexOf(this.searchtext.toLowerCase()) >= 0
})
}
},
methods: { methods: {
saveTagsToArray: function() { saveTagsToArray: function() {
tagArray = this.selected; tagArray = this.selected;
userField.prop('disabled',false); userField.prop('disabled',false);
} }


this.list_tags();
//this.list_tags();
if ($(this).bootstrapMaterialDesign) if ($(this).bootstrapMaterialDesign)
$(this).bootstrapMaterialDesign(); $(this).bootstrapMaterialDesign();
}, },
}; };


function get_insert_tag(id){
$.ajax({ url: "api/tag/id/"+id, method: "GET" }).done(function (tag) {
data.push("#" + tag.name);
console.log("Array:"+this.data);
}).fail(function (e, f, g) {
console.log("cannot load " + id + ".json: " + e + f + g);
})
}

+ 6
- 8
public/search.js View File

var isSearchActive = false, var isSearchActive = false,
tagArray = ["lorem"]; tagArray = ["lorem"];


const dat=[
'th',
'efi',
'wichtig',
],
const data=[],
search_data = []; search_data = [];


Vue.component('search',{ Vue.component('search',{
return{ return{
searchtext: "", searchtext: "",
selected: [], selected: [],
taglist: dat,
taglist: data,
}; };
}, },
computed:{ computed:{
}, },
methods: { methods: {
getFilteredTags(text) { getFilteredTags(text) {
this.taglist = dat.filter((option) => {
this.taglist = data.filter((option) => {
return option return option
.toString() .toString()
.toLowerCase() .toLowerCase()
$.ajax({url: "api/tag/ids", method: "GET"}) $.ajax({url: "api/tag/ids", method: "GET"})
.done(jd => { .done(jd => {
// NICHT SO wg. Vue: _messagelist = jd; // NICHT SO wg. Vue: _messagelist = jd;
if(data == ""){
_taglist.splice(0, _taglist.length); _taglist.splice(0, _taglist.length);
_taglist.push.apply(_taglist, jd); _taglist.push.apply(_taglist, jd);
// console.log("tag: jd: " + jd); // console.log("tag: jd: " + jd);
get_insert_tag(jd[e]); get_insert_tag(jd[e]);
} }
} }
}
}).fail(function (e, f, g) { }).fail(function (e, f, g) {
console.log("err: " + e + f + g); console.log("err: " + e + f + g);
}); });
url: "api/tag/id/" + id, url: "api/tag/id/" + id,
method: "GET" method: "GET"
}).done(function(tag) { }).done(function(tag) {
dat.push("#" + tag.name);
data.push("#" + tag.name);
}).fail(function(e, f, g) { }).fail(function(e, f, g) {
console.log("cannot load " + id + ".json: " + e + f + g); console.log("cannot load " + id + ".json: " + e + f + g);
}) })

Loading…
Cancel
Save