Browse Source

fixed createMessage/ files Tag autocomplete

master
Senta Mandutz 4 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

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

this.list_tags();
//this.list_tags();
if ($(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

@@ -1,11 +1,7 @@
var isSearchActive = false,
tagArray = ["lorem"];

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

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

Loading…
Cancel
Save