om/public/routes/createMessage.js

52 lines
1.7 KiB
JavaScript
Raw Normal View History

const CreateMsgRouter = {
template: `
<div class="card om-card">
<h4>Neue Nachricht erstellen</h4>
<form class="new-msg-form" @submit.prevent=createMsg>
2019-02-08 15:23:35 +01:00
<div class="form-group">
<label class="bmd-label-floating">User*</label>
<input type="text" class="form-control" id="user">
</div>
<div class="form-group bmd-form-group">
2019-02-08 15:23:35 +01:00
<label class="bmd-label-floating">Betreff*</label>
<input type="text" class="form-control" id="subject">
</div>
<div class="form-group bmd-form-group">
<label class="bmd-label-floating">Tags</label>
<input type="text" class="form-control" id="tag">
</div>
<div class="form-group">
2019-02-08 15:23:35 +01:00
<label class="bmd-label-floating">Nachricht*</label>
<textarea class="form-control" id="message" rows="5"></textarea>
</div>
<button class="btn btn-default"><a @click="$router.go(-1)">ABBRECHEN </a></button>
2019-02-08 14:37:56 +01:00
<button type="submit" class="btn btn-raised om-btn"><a @click="$router.push('/home')">SENDEN</a></button>
</form>
</div>
`,
data: function () {
2018-12-12 15:56:09 +01:00
return {};
},
methods: {
createMsg: function() {
var subject=$("#subject").val();
var message=$("#message").val();
var tag=$("#tag").val();
var user=$("#user").val();
2019-02-08 13:40:21 +01:00
console.log ("Message Created: "+tag+" "+message+" "+user);
2019-02-08 13:52:48 +01:00
$.ajax ({ url: "api/createMsg", data: {sub: subject, mess: message, use: user, ta: tag}, method: "POST" }) .done (have_result) .fail (have_error);
function have_result (res) {
console.log (res);
}
function have_error (err) {
2019-02-08 13:40:21 +01:00
console.log ("error: " + err.responseText);
console.log (err);
}
},
},
2019-01-16 17:38:57 +01:00
mounted: function() {
if ($(this).bootstrapMaterialDesign)
$(this).bootstrapMaterialDesign();
},
};