aboutsummaryrefslogtreecommitdiffstats
path: root/templates/staff/tables/edit.html
blob: b3b9faae163ab9492c3a0588375def8f065b61f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{% extends "main/base.html" %}
{% block title %}Staff | Home{% endblock %}
{% block og_title %}Staff | Home{% endblock %}
{% block og_description %}Landing page for the staff management area{% endblock %}
{% block content %}
    <div class="uk-container uk-section uk-container-small">
        {% if message %}
            <div class="uk-alert uk-alert-warning">
                {{ message }}
            </div>
        {% endif %}
        <form uk-grid class="uk-grid-small" action="{{ url_for("staff.tables.edit", table=table) }}" method="post">
            <div class="uk-width-expand">
                <p>Primary key: <strong>"<span class="fira-code">{{ primary_key }}</span>"</strong></p>
            </div>
            <div class="uk-width-auto">
                <a class="uk-button uk-button-default" href="{{ url_for("staff.tables.table", table=table, page=1) }}"><i class="uk-icon fa-fw fas fa-arrow-left"></i>&nbsp; Back</a>
                <input class="uk-button uk-button-primary" type="submit" id="submit" value="Save" />
            </div>
            <div class="uk-width-1-1">
                <div id="editor" class="uk-textarea">{{ document }}</div>
                <input type="hidden" name="json" id="json" />
            </div>

            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>

            {% if old_primary %}
                <input type="hidden" name="old_primary" value="{{ old_primary }}"/>
            {% endif %}
        </form>

        <script type="application/javascript">
            "use strict";

            window.onload = () => {
                let editor = ace.edit("editor");

                editor.session.setMode("ace/mode/json");
                editor.session.setUseWrapMode(true);

                editor.setTheme("ace/theme/iplastic");
                editor.setShowPrintMargin(false);

                editor.on("input", function () {
                    document.getElementById("json").value = editor.getValue();
                });
            };
        </script>
    </div>
{% endblock %}