{% extends "user/skeleton.html" %}
{% block content %}
{% raw %}

<h3>
<a class="btn btn-outline-secondary" href="/notes"><i class="fa fa-chevron-left"></i></a>
{{ note.title }}
</h3>

<tags-component v-bind:tags="note.tags" v-bind:resource="{id: note.id, name: 'note'}"></tags-component>

<span v-html="note.body"></span>

<backtotop-component></backtotop-component>

{% endraw %}
{% 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" v-html="note.title"></li>
</ol>
{% endraw %}
{% endblock %}

{% block script %}
<script type="text/javascript" src="/static/components/backtotop.js"></script>
<link rel="stylesheet" href="/static/components/backtotop.css"></link>
<script type="text/javascript" src="/static/components/tags.js"></script>

<script type="text/javascript">
var app = new Vue({
    el: '#app',
    data: {
        note: {{ pagedata['note']|tojson|safe }},
    },
    methods: {
        noteDelete: function() {
            /* Удалить статью в корзину */
            let vm = this;
            axios.post(
                '/api',
                {
                    "jsonrpc": "2.0",
                    "method": 'note.delete',
                    "params": {
                        "id": vm.note.id
                    },
                    "id": 1
                }
            ).then(
                function(response) {
                    if ('result' in response.data) {
                        window.location.href = '/notes';
                    }
                }
            );
        },
        showPanel: function(panel) {
            /* Показать/скрыть панель */
            panel.visible = !panel.visible;
        },
    }
})
</script>
{% endblock %}
