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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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="isActive" @click="myFilter(msg._id)" v-if="!isActive">bookmark_border</i>
  18. <i id="bockmark-active" class="material-icons" :key="isActive" @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. isActive_: 0,
  26. msgid: this.msg._id,
  27. bookmarkArray: auth.bookmarks,
  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. },
  69. isBookmarkActive: function (msgid) {
  70. //console.log("isBookmarkActive(): " + msgid);
  71. if (this.bookmarkArray.indexOf(msgid) > -1) {
  72. // $("#bockmark-not-active").css("visibility","hidden");
  73. // $("#bockmark-active").css("visibility","visible");
  74. this.isActive = true;
  75. //console.log("isBookmarkActive(): " + this.isActive);
  76. this.isActive_ = 1;
  77. }
  78. }
  79. },
  80. beforeMount: function () {
  81. //this.isBookmarkActive();
  82. }
  83. });