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

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