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.

createMessage.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. const data=[
  2. '#th',
  3. '#efi',
  4. '#wichtig',
  5. ];
  6. const CreateMsgRouter = {
  7. template: `
  8. <div class="content card om-card">
  9. <h4>Neue Nachricht erstellen</h4>
  10. <b-field>
  11. <b-input placeholder="User" id="user"></b-input>
  12. </b-field>
  13. <b-field>
  14. <b-input placeholder="Betreff" id="subject"></b-input>
  15. </b-field>
  16. <b-field label="Tags">
  17. <b-taginput
  18. v-model="selected"
  19. :data=items
  20. autocomplete
  21. allow-new:false
  22. icon="label"
  23. placeholder="#"
  24. @typing="getFilteredTags" id="tag">
  25. </b-taginput>
  26. </b-field>
  27. <b-field>
  28. <b-input placeholder="Nachricht" id="message" type="textarea"></b-input>
  29. </b-field>
  30. <b-button @click="$router.go(-1)">ABBRECHEN</b-button>
  31. <b-button type="is-primary" @click="$router.push('/home')">SENDEN</b-button>
  32. </div>
  33. `,
  34. data: function () {
  35. return {
  36. selected: [],
  37. items: data
  38. };
  39. },
  40. methods: {
  41. createMsg: function () {
  42. var subject = $("#subject").val();
  43. var message = $("#message").val();
  44. var tag = $("#tag").val();
  45. var user = $("#user").val();
  46. console.log("Message Created: " + tag + " " + message + " " + user);
  47. $.ajax({
  48. url: "api/createMsg",
  49. data: {
  50. sub: subject,
  51. mess: message,
  52. use: user,
  53. ta: tag
  54. },
  55. method: "POST"
  56. }).done(have_result).fail(have_error);
  57. function have_result(res) {
  58. console.log(res);
  59. }
  60. function have_error(err) {
  61. console.log("error: " + err.responseText);
  62. console.log(err);
  63. }
  64. },
  65. getFilteredTags(text) {
  66. this.items = data.filter((option) => {
  67. return option
  68. .toString()
  69. .toLowerCase()
  70. .indexOf(text.toLowerCase()) >= 0
  71. })
  72. },
  73. },
  74. mounted: function () {
  75. if ($(this).bootstrapMaterialDesign)
  76. $(this).bootstrapMaterialDesign();
  77. },
  78. };