From 4aa5856fbc1649ac97f41534b720ddd598fbfdda Mon Sep 17 00:00:00 2001 From: senta_mandutz Date: Sun, 21 Jul 2019 15:24:40 +0200 Subject: [PATCH] fixed createMessage/ files Tag autocomplete --- public/routes/createMessage.js | 30 ++++++++++++++++-------------- public/search.js | 14 ++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/public/routes/createMessage.js b/public/routes/createMessage.js index 6a0c8da..8cb167a 100644 --- a/public/routes/createMessage.js +++ b/public/routes/createMessage.js @@ -1,5 +1,4 @@ var tagArray = []; -const data=[]; const CreateMsgRouter = { template: `
@@ -18,12 +17,12 @@ const CreateMsgRouter = { @@ -52,12 +51,12 @@ const CreateMsgRouter = { @@ -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); - }) -} diff --git a/public/search.js b/public/search.js index dd86a98..9aba881 100644 --- a/public/search.js +++ b/public/search.js @@ -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); })