om/public/routes/msgCard.js

61 lines
2.0 KiB
JavaScript
Raw Normal View History

Vue.component('MsgCard', {
template: `<div class="om-card card">
<h6 class="msg-head">
<b>{{ msg.subject }}</b>
<div id="msgid">{{msg._id}}</div>
<img src="favicon.ico" width=20px height=20px>
</h6>
2019-07-21 12:39:33 +00:00
{{ msg.message }}<br>
2019-07-19 10:52:43 +00:00
<a v-for="tag in msg.tag" @click="filterForTag(tag)">#{{ tag }} </a>
2019-07-21 12:39:33 +00:00
<br>
2019-07-02 11:08:11 +00:00
</p>
<div class="om-card-footer"> <div class="om-user-line">
<i class="material-icons">account_circle</i>
Erstellt von {{ msg.user }}</div>
<i class="material-icons" @click="myFilter(msg._id)" v-if="!isActive">bookmark_border</i>
<i class="material-icons" @click="myFilter(msg._id)" v-else="isActive">bookmark</i>
</div></div>`,
props: ['msg'],
data: function () {
return {
isActive: false,
};
},
methods: {
myFilter: function(_messageid) {
//var _messageid = $("#msgid").text();
var _bookmark = auth.bookmarks;
_bookmark.push(_messageid);
console.log("msgid"+_bookmark);
var _userid = "5d360f06b8f3ce67d12ccc92";
this.isActive = !this.isActive;
if(this.isActive){
$.ajax({
url: "api/usr",
data: {
userid: _userid,
bookmark: _bookmark
},
method: "PUT"
}).done(have_result).fail(have_error);
function have_result(res) {
console.log(res);
}
function have_error(err) {
console.log("error: " + err.responseText);
console.log(err);
}
}
},
2019-07-19 10:52:43 +00:00
filterForTag: function(tag) {
console.log("link: " +tag);
searching(tag);
},
}
});