Files
myapp-full/myapp/ns_note/templates/note_add.html
2023-02-18 09:22:43 +03:00

80 lines
2.1 KiB
HTML

{% extends "private/skeleton.html" %}
{% block content %}
<h3>
<a class="btn btn-outline-secondary" href="/notes"><i class="fa fa-chevron-left"></i></a>
Новая заметка
</h3>
<hr />
<div class="form-group">
<label class="control-label" for="title">Заголовок</label>
<input class="form-control" id="title" name="title" type="text" v-model="note.title">
</div>
<div class="form-group">
<label class="control-label" for="body">Текст</label>
<textarea class="form-control" cols="40" id="body" name="body" rows="8" v-model="note.body"></textarea>
</div>
<div class="row mt-3">
<div class="col">
<button type="submit" class="btn btn-outline-success pull-right" v-on:click="send"><i class="fa fa-plus"></i> Добавить</button>
</div>
</div>
{% endblock %}
{% block breadcrumb %}
{% raw %}
<ol class="breadcrumb mt-3">
<li class="breadcrumb-item"><a href="/"><i class="fa fa-home"></i></a></li>
<li class="breadcrumb-item"><a href="/notes">Заметки</a></li>
<li class="breadcrumb-item active">Новая заметка</li>
</ol>
{% endraw %}
{% endblock %}
{% block script %}
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
note: {
title: '',
body: ''
}
},
methods: {
send: function () {
/* Сохранить */
let vm = this;
{{ editor.getValue('"body"', 'vm.note.body', type='tinymce') }}
axios.post(
'/api',
{
"jsonrpc": "2.0",
"method": "note.add",
"params": {
"title": vm.note.title,
"body": vm.note.body
},
"id": 1
}
).then(
function(response) {
if ('result' in response.data) {
window.location.href = '/note/' + response.data['result'].id;
}
}
);
}
},
mounted: function () {
{{ editor.tinymce('"body"') }}
}
})
</script>
{% endblock %}