Merge remote-tracking branch 'origin/developer' into developer

This commit is contained in:
Edwina Barbalan
2019-07-02 14:59:17 +02:00
20 changed files with 989 additions and 287 deletions
+54 -22
View File
@@ -1,7 +1,8 @@
var tagArray = [];
const data=[
'#th',
'#efi',
'#wichtig',
'th',
'efi',
'wichtig',
];
const CreateMsgRouter = {
template: `
@@ -18,13 +19,15 @@ const CreateMsgRouter = {
<b-field label="Tags">
<b-taginput
id="tag"
v-model="selected"
:data=items
:data=taglist
autocomplete
allow-new:false
icon="label"
placeholder="#"
@typing="getFilteredTags" id="tag">
@typing="getFilteredTags"
@input="saveTagsToArray">
</b-taginput>
</b-field>
@@ -33,38 +36,41 @@ const CreateMsgRouter = {
</b-field>
<b-button @click="$router.go(-1)">ABBRECHEN</b-button>
<b-button type="is-primary" @click="$router.push('/home')">SENDEN</b-button>
<b-button type="is-primary" @click="createMsg">SENDEN</b-button>
</div>
`,
data: function () {
return {
selected: [],
items: data
taglist: data,
};
},
methods: {
saveTagsToArray: function() {
tagArray = this.selected;
console.info(tagArray);
},
createMsg: function () {
var subject = $("#subject").val();
var message = $("#message").val();
var tag = $("#tag").val();
var user = $("#user").val();
console.log("Message Created: " + tag + " " + message + " " + user);
var _subject = $("#subject").val();
var _message = $("#message").val();
var _tag = tagArray;
var _user = $("#user").val();
//console.log("Message Created: " + _tag + " " + _message + " " + _user);
$.ajax({
url: "api/createMsg",
url: "api/msg",
data: {
sub: subject,
mess: message,
use: user,
ta: tag
subject: _subject,
message: _message,
user: _user,
tag: _tag
},
method: "POST"
}).done(have_result).fail(have_error);
function have_result(res) {
console.log(res);
//console.log(res);
router.push('/home')
}
function have_error(err) {
@@ -73,16 +79,42 @@ const CreateMsgRouter = {
}
},
getFilteredTags(text) {
this.items = data.filter((option) => {
this.taglist = data.filter((option) => {
return option
.toString()
.toLowerCase()
.indexOf(text.toLowerCase()) >= 0
})
},
},
list_tags: function () {
$.ajax({url: "api/tag/ids",method: "GET"})
.done(jd => {
// NICHT SO wg. Vue: _messagelist = jd;
_taglist.splice(0, _taglist.length);
_taglist.push.apply(_taglist, jd);
console.log("tag: jd: " + jd);
for (var e in jd) {
if (!_tags[jd[e]]) {
get_insert_tag(jd[e]);
}
}
}).fail(function (e, f, g) {
console.log("err: " + e + f + g);
});
}
},
mounted: function () {
this.list_tags();
if ($(this).bootstrapMaterialDesign)
$(this).bootstrapMaterialDesign();
},
};
function get_insert_tag(id){
$.ajax({ url: "api/tag/"+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);
})
}
+4 -4
View File
@@ -24,12 +24,12 @@ const HomeRouter = {
});
},*/
list_messages: function () {
$.ajax({url: "api/ids", method: "GET"})
$.ajax({url: "api/msg/ids", method: "GET"})
.done(jd => {
// NICHT SO wg. Vue: _messagelist = jd;
_messagelist.splice(0, _messagelist.length);
_messagelist.push.apply(_messagelist, jd);
console.log("jd: "+jd);
//console.log("jd: "+jd);
for (var e in jd) {
if (!_messages[jd[e]]) {
get_insert_message(jd[e]);
@@ -49,7 +49,7 @@ const HomeRouter = {
}
}*/
}).fail(function (e, f, g) {
console.log("err: " + e + f + g);
console.log("list_msg: err: " + e + f + g);
});
}
},
@@ -61,7 +61,7 @@ const HomeRouter = {
};
function get_insert_message(id) {
$.ajax({ url: "api/msg/"+id, method: "GET" }).done(function (msg) {
$.ajax({ url: "api/msg/id/"+id, method: "GET" }).done(function (msg) {
Vue.set(_messages, id, msg);
}).fail(function (e, f, g) {
console.log("cannot load " + id + ".json: " + e + f + g);
+2 -1
View File
@@ -5,7 +5,8 @@ Vue.component('MsgCard', {
<img src="favicon.ico" width=20px height=20px>
</h6>
{{ msg.message }}<br><br>
<a href="#">{{ msg.tag }}</a></p>
<a v-for="tag in msg.tag" href="#">#{{ tag }} </a>
</p>
<div class="om-card-footer"> <div class="om-user-line">
<i class="material-icons">account_circle</i>
Erstellt von {{ msg.user }}</div>
+2
View File
@@ -0,0 +1,2 @@
_taglist = [];
_tags = [];