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.

files.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. var tagArray = [];
  2. const FileRouter = {
  3. template: `
  4. <div class="content">
  5. <h4>Erweiterte Suche</h4>
  6. <b-field label="Suche nach">
  7. <b-select
  8. placeholder="Wähle eine Suchform"
  9. v-model="selectedOptions">
  10. <option value="freeSearch">Freie Suche</option>
  11. <option value="subject">Betreff</option>
  12. <option value="tags">Tags</option>
  13. <option value="text">Nachrichtentext</option>
  14. <option value="user">User</option>
  15. </b-select>
  16. </b-field>
  17. <b-field v-if="selectedOptions=='freeSearch'||selectedOptions=='subject'|| selectedOptions=='text' || selectedOptions=='user'">
  18. <b-input id="freeSe"></b-input>
  19. </b-field>
  20. <b-field v-if="selectedOptions=='tags'">
  21. <b-autocomplete rounded v-model="searchtext"
  22. :data="filteredDataArray"
  23. placeholder="suche..." icon="magnify"
  24. @select="option => selected = option">
  25. </b-autocomplete>
  26. </b-field>
  27. <b-button type="is-primary" @click="search">SUCHE</b-button>
  28. <div id="om-msg-cards">
  29. <MsgCard
  30. v-for="id in messagelist.slice().reverse()"
  31. :key="id"
  32. :msg="messages[id] || {}"
  33. ></MsgCard>
  34. </div>
  35. </div>
  36. `,
  37. data: function () {
  38. return {
  39. searchtext: "",
  40. selectedOptions: [],
  41. selected: [],
  42. taglist: data,
  43. messagelist: _messagelist,
  44. messages: _messages,
  45. }
  46. },
  47. computed: {
  48. filteredDataArray() {
  49. return this.taglist.filter((option) => {
  50. return option
  51. .toString()
  52. .toLowerCase()
  53. .indexOf(this.searchtext.toLowerCase()) >= 0
  54. })
  55. }
  56. },
  57. methods: {
  58. list_messages: function () {
  59. messages();
  60. },
  61. saveTagsToArray: function () {
  62. tagArray = this.selected;
  63. console.info(tagArray);
  64. },
  65. getFilteredTags(text) {
  66. this.taglist = data.filter((option) => {
  67. return option
  68. .toString()
  69. .toLowerCase()
  70. .indexOf(text.toLowerCase()) >= 0
  71. })
  72. this.search();
  73. },
  74. list_tags: function () {
  75. $.ajax({
  76. url: "api/tag/ids",
  77. method: "GET"
  78. })
  79. .done(jd => {
  80. // NICHT SO wg. Vue: _messagelist = jd;
  81. _taglist.splice(0, _taglist.length);
  82. _taglist.push.apply(_taglist, jd);
  83. console.log("tag: jd: " + jd);
  84. for (var e in jd) {
  85. if (!_tags[jd[e]]) {
  86. get_insert_tag(jd[e]);
  87. }
  88. }
  89. }).fail(function (e, f, g) {
  90. console.log("err: " + e + f + g);
  91. });
  92. },
  93. saveTagsToArray: function () {
  94. tagArray = this.selected;
  95. console.info(tagArray);
  96. },
  97. search: function () {
  98. searching(this.searchtext);
  99. },
  100. list_messages: function () {
  101. messages();
  102. },
  103. },
  104. mounted: function () {
  105. //this.search();
  106. this.list_tags();
  107. //this.list_messages();
  108. },
  109. };