123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- var tagArray = [];
- const data=[
- 'th',
- 'efi',
- 'wichtig',
- ];
- const CreateMsgRouter = {
- template: `
- <div class="content">
- <div class="is-hidden-desktop">
- <div class="content card om-card">
- <h4>Neue Nachricht erstellen</h4>
- <b-field>
- <b-input placeholder="User" id="user"></b-input>
- </b-field>
-
- <b-field>
- <b-input placeholder="Betreff" id="subject"></b-input>
- </b-field>
-
- <b-field label="Tags">
- <b-taginput
- id="tag"
- v-model="selected"
- :data=taglist
- autocomplete
- allow-new:false
- icon="label"
- placeholder="#"
- @typing="getFilteredTags"
- @input="saveTagsToArray">
- </b-taginput>
- </b-field>
-
- <b-field>
- <b-input placeholder="Nachricht" id="message" type="textarea"></b-input>
- </b-field>
-
- <b-button @click="$router.go(-1)">ABBRECHEN</b-button>
- <b-button type="is-primary" @click="createMsg">SENDEN</b-button>
- </div>
- </div>
-
- <div class=" column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
- <div class="content card om-card">
- <h4>Neue Nachricht erstellen</h4>
- <b-field>
- <b-input placeholder="User" id="user"></b-input>
- </b-field>
-
- <b-field>
- <b-input placeholder="Betreff" id="subject"></b-input>
- </b-field>
-
- <b-field label="Tags">
- <b-taginput
- id="tag"
- v-model="selected"
- :data=taglist
- autocomplete
- allow-new:false
- icon="label"
- placeholder="#"
- @typing="getFilteredTags"
- @input="saveTagsToArray">
- </b-taginput>
- </b-field>
-
- <b-field>
- <b-input placeholder="Nachricht" id="message" type="textarea"></b-input>
- </b-field>
-
- <b-button @click="$router.go(-1)">ABBRECHEN</b-button>
- <b-button type="is-primary" @click="createMsg">SENDEN</b-button>
- </div>
- </div>
- </div>`,
-
- data: function () {
- return {
- selected: [],
- taglist: data,
- };
- },
- methods: {
- saveTagsToArray: function() {
- tagArray = this.selected;
- console.info(tagArray);
- },
- createMsg: function () {
- var _subject = $("#subject").val();
- var _message = $("#message").val();
- var _tag = tagArray;
- var _user = $("#user").val();
- //console.log("Message Created: " + _tag + " " + _message + " " + _user);
- $.ajax({
- url: "api/msg",
- data: {
- subject: _subject,
- message: _message,
- user: _user,
- tag: _tag
- },
- method: "POST"
- }).done(have_result).fail(have_error);
-
- function have_result(res) {
- //console.log(res);
- router.push('/home')
- }
-
- function have_error(err) {
- console.log("error: " + err.responseText);
- console.log(err);
- }
- },
- getFilteredTags(text) {
- this.taglist = data.filter((option) => {
- return option
- .toString()
- .toLowerCase()
- .indexOf(text.toLowerCase()) >= 0
- })
- },
- list_tags: function () {
- $.ajax({url: "api/tag/ids",method: "GET"})
- .done(jd => {
- // NICHT SO wg. Vue: _messagelist = jd;
- _taglist.splice(0, _taglist.length);
- _taglist.push.apply(_taglist, jd);
- console.log("tag: jd: " + jd);
- for (var e in jd) {
- if (!_tags[jd[e]]) {
- get_insert_tag(jd[e]);
- }
- }
- }).fail(function (e, f, g) {
- console.log("err: " + e + f + g);
- });
- }
- },
- mounted: function () {
- this.list_tags();
- if ($(this).bootstrapMaterialDesign)
- $(this).bootstrapMaterialDesign();
- },
- };
-
- function get_insert_tag(id){
- $.ajax({ url: "api/tag/"+id, method: "GET" }).done(function (tag) {
- data.push("#" + tag.name);
- console.log("Array:"+this.data);
- }).fail(function (e, f, g) {
- console.log("cannot load " + id + ".json: " + e + f + g);
- })
- }
|