om/public/routes/msgCard.js

95 lines
3.3 KiB
JavaScript
Raw Normal View History

Vue.component('MsgCard', {
2019-07-23 17:22:01 +02:00
template: `
<div class="om-card card">
<h6 class="msg-head">
<b>{{ msg.subject }}</b>
<img src="favicon.ico" width=20px height=20px>
2019-07-23 17:22:01 +02:00
</h6>
{{ msg.message }}<br>
<a v-for="tag in msg.tag" @click="filterForTag(tag)">#{{ tag }} </a>
<br>
<div class="om-card-footer">
<div class="om-user-line">
<i class="material-icons">account_circle</i>
Erstellt von {{ msg.user }}
</div>
2019-07-23 21:41:27 +02:00
<i id="bockmark-not-active" class="material-icons" :key="vueRender.key" @click="myFilter(msg._id)" v-if="!isActive">bookmark_border</i>
<i id="bockmark-active" class="material-icons" :key="vueRender.key" @click="myFilter(msg._id)" v-else>bookmark</i>
2019-07-23 17:22:01 +02:00
</div>
</div>`,
2019-07-23 16:07:14 +02:00
props: ['msg', 'isBookmark'],
data: function () {
return {
2019-07-23 16:07:14 +02:00
isActive: this.isBookmark,
2019-07-23 17:22:01 +02:00
msgid: this.msg._id,
bookmarkArray: auth.bookmarks,
2019-07-23 21:41:27 +02:00
vueRender: vueRender,
};
},
methods: {
2019-07-23 16:07:14 +02:00
myFilter: function (_messageid) {
//var _messageid = $("#msgid").text();
2019-07-23 16:07:14 +02:00
if (this.isActive == true) {
2019-07-23 17:22:01 +02:00
var index = this.bookmarkArray.indexOf(_messageid);
2019-07-23 16:07:14 +02:00
if (index > -1) {
2019-07-23 17:22:01 +02:00
this.bookmarkArray.splice(index, 1);
2019-07-23 16:07:14 +02:00
}
this.isActive = false;
} else {
2019-07-23 17:22:01 +02:00
console.log("_messsageid: "+_messageid+" bookmarks: "+this.bookmarkArray);
this.bookmarkArray.push(_messageid);
2019-07-23 16:07:14 +02:00
this.isActive =true;
}
/*console.log("msgid"+_bookmark);
var _userid = auth.user;
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-23 16:07:14 +02:00
}*/
},
2019-07-23 16:07:14 +02:00
filterForTag: function (tag) {
var btnString = "#" + tag + " abonnieren";
2019-07-23 18:39:31 +02:00
$("#btn-text").text(btnString);
$("#subscribe-btn").css("visibility", "visible");
2019-07-23 21:41:27 +02:00
//console.log("link: " + tag);
2019-07-19 12:52:43 +02:00
searching(tag);
2019-07-23 21:41:27 +02:00
var btnString = "#" + tag + " abonnieren";
$("#btn-text").text(btnString);
$("#subscribe-btn").css("visibility", "visible");
2019-07-19 12:52:43 +02:00
},
2019-07-23 16:07:14 +02:00
isBookmarkActive: function (msgid) {
//console.log("isBookmarkActive(): " + msgid);
2019-07-23 17:22:01 +02:00
if (this.bookmarkArray.indexOf(msgid) > -1) {
2019-07-23 16:07:14 +02:00
// $("#bockmark-not-active").css("visibility","hidden");
// $("#bockmark-active").css("visibility","visible");
this.isActive = true;
//console.log("isBookmarkActive(): " + this.isActive);
this.isActive_ = 1;
}
}
},
beforeMount: function () {
//this.isBookmarkActive();
}
});