Files
myapp-full/myapp/ns_page/templates/user/page_add.html
2020-07-05 17:52:06 +03:00

83 lines
2.2 KiB
HTML

{% extends "user/skeleton.html" %}
{% block content %}
<h3>
<a class="btn btn-outline-secondary" href="/pages"><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="page.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="page.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="/pages">Статьи</a></li>
<li class="breadcrumb-item active">Новая статья</li>
</ol>
{% endraw %}
{% endblock %}
{% block script %}
{% import 'inc/editor.js' as editor %}
{{ editor.plugin('tinymce') }}
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
page: {
title: '',
body: ''
}
},
methods: {
send: function () {
/* Сохранить */
let vm = this;
{{ editor.getValue('"body"', 'vm.page.body', type='tinymce') }}
axios.post(
'/api',
{
"jsonrpc": "2.0",
"method": "page.add",
"params": {
"title": vm.page.title,
"body": vm.page.body
},
"id": 1
}
).then(
function(response) {
if ('result' in response.data) {
window.location.href = '/page/' + response.data['result'].id;
}
}
);
}
},
mounted: function () {
{{ editor.tinymce('"body"') }}
}
})
</script>
{% endblock %}