2018-12-12 14:34:39 +01:00
|
|
|
const CreateMsgRouter = {
|
2019-04-17 15:58:15 +02:00
|
|
|
template: `
|
2019-07-21 14:22:37 +02:00
|
|
|
<div class="content">
|
2019-07-22 16:22:27 +02:00
|
|
|
<div class="column pull-right-sm is-four-fifths-desktop">
|
|
|
|
<div id="mobile" class="om-card card">
|
2019-07-21 14:22:37 +02:00
|
|
|
<h4>Neue Nachricht erstellen</h4>
|
|
|
|
<b-field>
|
|
|
|
<b-input placeholder="User" id="user"></b-input>
|
|
|
|
</b-field>
|
2019-04-17 15:58:15 +02:00
|
|
|
|
2019-07-21 14:22:37 +02:00
|
|
|
<b-field>
|
|
|
|
<b-input placeholder="Betreff" id="subject"></b-input>
|
|
|
|
</b-field>
|
2019-04-17 15:58:15 +02:00
|
|
|
|
2019-07-21 14:22:37 +02:00
|
|
|
<b-field label="Tags">
|
|
|
|
<b-taginput
|
|
|
|
id="tag"
|
|
|
|
v-model="selected"
|
2019-07-21 15:24:40 +02:00
|
|
|
:data="filteredDataArray"
|
2019-07-21 14:22:37 +02:00
|
|
|
autocomplete
|
|
|
|
allow-new:false
|
|
|
|
icon="label"
|
|
|
|
placeholder="#"
|
2019-07-21 15:24:40 +02:00
|
|
|
|
2019-07-21 14:22:37 +02:00
|
|
|
@input="saveTagsToArray">
|
|
|
|
</b-taginput>
|
|
|
|
</b-field>
|
2019-04-17 15:58:15 +02:00
|
|
|
|
2019-07-21 14:22:37 +02:00
|
|
|
<b-field>
|
|
|
|
<b-input placeholder="Nachricht" id="message" type="textarea"></b-input>
|
|
|
|
</b-field>
|
2019-04-17 15:58:15 +02:00
|
|
|
|
2019-07-21 14:22:37 +02:00
|
|
|
<b-button @click="$router.go(-1)">ABBRECHEN</b-button>
|
|
|
|
<b-button type="is-primary" @click="createMsg">SENDEN</b-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>`,
|
2019-04-17 15:58:15 +02:00
|
|
|
|
|
|
|
data: function () {
|
|
|
|
return {
|
2019-07-21 14:22:37 +02:00
|
|
|
isDisabled: false,
|
2019-06-04 16:32:37 +02:00
|
|
|
selected: [],
|
2019-07-21 15:24:40 +02:00
|
|
|
searchtext : "",
|
2019-06-20 17:17:45 +02:00
|
|
|
taglist: data,
|
2019-04-17 15:58:15 +02:00
|
|
|
};
|
|
|
|
},
|
2019-07-21 15:24:40 +02:00
|
|
|
computed:{
|
|
|
|
filteredDataArray() {
|
|
|
|
return this.taglist.filter((option) => {
|
|
|
|
return option
|
|
|
|
.toString()
|
|
|
|
.toLowerCase()
|
|
|
|
.indexOf(this.searchtext.toLowerCase()) >= 0
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2019-04-17 15:58:15 +02:00
|
|
|
methods: {
|
2019-06-20 23:30:51 +02:00
|
|
|
saveTagsToArray: function() {
|
2019-07-22 14:15:20 +02:00
|
|
|
tagArray = this.selected;
|
2019-06-20 23:30:51 +02:00
|
|
|
console.info(tagArray);
|
|
|
|
},
|
2019-04-17 15:58:15 +02:00
|
|
|
createMsg: function () {
|
2019-06-20 17:17:45 +02:00
|
|
|
var _subject = $("#subject").val();
|
|
|
|
var _message = $("#message").val();
|
2019-06-20 23:30:51 +02:00
|
|
|
var _tag = tagArray;
|
2019-07-22 14:15:20 +02:00
|
|
|
var _user = auth.name != '' ? auth.name : $("#user").val();
|
2019-06-20 17:17:45 +02:00
|
|
|
//console.log("Message Created: " + _tag + " " + _message + " " + _user);
|
2019-04-17 15:58:15 +02:00
|
|
|
$.ajax({
|
2019-06-20 17:17:45 +02:00
|
|
|
url: "api/msg",
|
2019-04-17 15:58:15 +02:00
|
|
|
data: {
|
2019-06-20 17:17:45 +02:00
|
|
|
subject: _subject,
|
|
|
|
message: _message,
|
|
|
|
user: _user,
|
|
|
|
tag: _tag
|
2019-04-17 15:58:15 +02:00
|
|
|
},
|
|
|
|
method: "POST"
|
|
|
|
}).done(have_result).fail(have_error);
|
|
|
|
|
|
|
|
function have_result(res) {
|
2019-06-20 17:17:45 +02:00
|
|
|
//console.log(res);
|
|
|
|
router.push('/home')
|
2019-02-07 12:16:40 +01:00
|
|
|
}
|
2019-04-17 15:58:15 +02:00
|
|
|
|
|
|
|
function have_error(err) {
|
|
|
|
console.log("error: " + err.responseText);
|
|
|
|
console.log(err);
|
2019-02-07 12:16:40 +01:00
|
|
|
}
|
|
|
|
},
|
2019-06-04 16:32:37 +02:00
|
|
|
getFilteredTags(text) {
|
2019-06-20 17:17:45 +02:00
|
|
|
this.taglist = data.filter((option) => {
|
2019-06-04 16:32:37 +02:00
|
|
|
return option
|
|
|
|
.toString()
|
|
|
|
.toLowerCase()
|
|
|
|
.indexOf(text.toLowerCase()) >= 0
|
|
|
|
})
|
2019-06-20 17:17:45 +02:00
|
|
|
},
|
2019-06-25 14:43:33 +02:00
|
|
|
list_tags: function () {
|
|
|
|
$.ajax({url: "api/tag/ids",method: "GET"})
|
|
|
|
.done(jd => {
|
|
|
|
// NICHT SO wg. Vue: _messagelist = jd;
|
2019-07-21 14:12:16 +02:00
|
|
|
console.log("DATA: "+data);
|
|
|
|
if(data == ""){
|
|
|
|
_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]);
|
|
|
|
}
|
2019-06-25 14:43:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}).fail(function (e, f, g) {
|
|
|
|
console.log("err: " + e + f + g);
|
|
|
|
});
|
|
|
|
}
|
2019-04-17 15:58:15 +02:00
|
|
|
},
|
|
|
|
mounted: function () {
|
2019-07-21 14:22:37 +02:00
|
|
|
var userField = $('#user');
|
|
|
|
if (auth != null && auth.mail != '') {
|
|
|
|
// userField.prop('placeholder',auth.name);
|
|
|
|
var authorName = auth.name.split(' ');
|
|
|
|
authorName = authorName[1] + ', ' + authorName[0];
|
|
|
|
userField.val(authorName);
|
|
|
|
userField.prop('disabled',true);
|
|
|
|
} else {
|
|
|
|
userField.prop('placeholder','User');
|
|
|
|
userField.prop('disabled',false);
|
|
|
|
}
|
|
|
|
|
2019-07-21 15:24:40 +02:00
|
|
|
//this.list_tags();
|
2019-04-17 15:58:15 +02:00
|
|
|
if ($(this).bootstrapMaterialDesign)
|
|
|
|
$(this).bootstrapMaterialDesign();
|
|
|
|
},
|
2018-12-12 14:34:39 +01:00
|
|
|
};
|
2019-06-25 14:43:33 +02:00
|
|
|
|