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 2.7KB

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