Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

msgCard.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. Vue.component('MsgCard', {
  2. template: `
  3. <div class="om-card card">
  4. <h6 class="msg-head">
  5. <b>{{ msg.subject }}</b>
  6. <div id="msgid" >{{msg._id}}</div>
  7. <img src="favicon.ico" width=20px height=20px>
  8. </h6>
  9. {{ msg.message }}<br>
  10. <a v-for="tag in msg.tag" @click="filterForTag(tag)">#{{ tag }} </a>
  11. <br>
  12. <div class="om-card-footer">
  13. <div class="om-user-line">
  14. <i class="material-icons">account_circle</i>
  15. Erstellt von {{ msg.user }}
  16. </div>
  17. <i id="bockmark-not-active" class="material-icons" :key="vueRender.key" @click="myFilter(msg._id)" v-if="!isActive">bookmark_border</i>
  18. <i id="bockmark-active" class="material-icons" :key="vueRender.key" @click="myFilter(msg._id)" v-else>bookmark</i>
  19. </div>
  20. </div>`,
  21. props: ['msg', 'isBookmark'],
  22. data: function () {
  23. return {
  24. isActive: this.isBookmark,
  25. msgid: this.msg._id,
  26. bookmarkArray: auth.bookmarks,
  27. vueRender: vueRender,
  28. };
  29. },
  30. methods: {
  31. myFilter: function (_messageid) {
  32. //var _messageid = $("#msgid").text();
  33. if (this.isActive == true) {
  34. var index = this.bookmarkArray.indexOf(_messageid);
  35. if (index > -1) {
  36. this.bookmarkArray.splice(index, 1);
  37. }
  38. this.isActive = false;
  39. } else {
  40. console.log("_messsageid: "+_messageid+" bookmarks: "+this.bookmarkArray);
  41. this.bookmarkArray.push(_messageid);
  42. this.isActive =true;
  43. }
  44. /*console.log("msgid"+_bookmark);
  45. var _userid = auth.user;
  46. this.isActive = !this.isActive;
  47. if(this.isActive){
  48. $.ajax({
  49. url: "api/usr",
  50. data: {
  51. userid: _userid,
  52. bookmark: _bookmark
  53. },
  54. method: "PUT"
  55. }).done(have_result).fail(have_error);
  56. function have_result(res) {
  57. console.log(res);
  58. }
  59. function have_error(err) {
  60. console.log("error: " + err.responseText);
  61. console.log(err);
  62. }
  63. }*/
  64. },
  65. filterForTag: function (tag) {
  66. //console.log("link: " + tag);
  67. searching(tag);
  68. var btnString = "#" + tag + " abonnieren";
  69. $("#btn-text").text(btnString);
  70. $("#subscribe-btn").css("visibility", "visible");
  71. },
  72. isBookmarkActive: function (msgid) {
  73. //console.log("isBookmarkActive(): " + msgid);
  74. if (this.bookmarkArray.indexOf(msgid) > -1) {
  75. // $("#bockmark-not-active").css("visibility","hidden");
  76. // $("#bockmark-active").css("visibility","visible");
  77. this.isActive = true;
  78. //console.log("isBookmarkActive(): " + this.isActive);
  79. this.isActive_ = 1;
  80. }
  81. }
  82. },
  83. beforeMount: function () {
  84. //this.isBookmarkActive();
  85. }
  86. });