document_form.html 8.91 KB
Newer Older
1
{% extends 'core/document_nav.html' %}
2
{% load i18n staticfiles bootstrap %}
3
{% block head_title %}{% if object %}{% trans "Update a Document" %}{% else %}{% trans "Create a new Document" %}{% endif %}{% endblock %}
4

5
{% block nav-doc-active %}active{% endblock %}
6

Robin Tissot's avatar
Robin Tissot committed
7
8
{% block extra_nav %}
{% if object and can_publish %}
9
<div class="ml-auto">
Robin Tissot's avatar
Robin Tissot committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    <button type="button" class="nav-item btn btn-primary mr-1" data-toggle="modal" data-target="#shareModal" title="{% trans "Share" %}"><i class="fas fa-share"></i></button>
    {% comment %}
    {% if not object.is_published %}
    <form method="post" class="inline-form" action="{% url 'document-publish' pk=object.pk %}">{% csrf_token %}
        <input type="hidden" name="workflow_state" value="{{ object.WORKFLOW_STATE_PUBLISHED }}">
        <button type="submit" value="{% trans 'Publish' %}" class="nav-item btn btn-success mr-1" title="{% trans 'Publish' %}">
            <i class="fas fa-globe-europe"></i>
        </button>
    </form>
    {% endif %}
    {% endcomment %}
    <form method="post" class="inline-form" action="{% url 'document-publish' pk=object.pk %}" onsubmit="return confirm('{% trans "Do you really want to delete the document?" %}');">{% csrf_token %}
        <input type="hidden" name="workflow_state" value="{{ object.WORKFLOW_STATE_ARCHIVED }}">
        <button type="submit" value="" class="nav-item btn btn-danger" title="{% trans 'Delete' %}"><i class="fas fa-trash"></i></button>
    </form>
Robin Tissot's avatar
Robin Tissot committed
25
26
27
28
</div>
{% endif %}
{% endblock %}

29
{% block tab_content %}
30
<div class="tab-pane fade show active" id="nav-doc" role="tabpanel" aria-labelledby="nav-doc-tab">
31
    <form id="document-form" method="post">
Robin Tissot's avatar
Robin Tissot committed
32
33
        {% csrf_token %}
        <fieldset>
34
35
36
37
38
39
            <div class="form-group">
                {% for err in form.non_field_errors %}
                <p class="error">{{ err }}</p>
                {% endfor %}
            </div>

Robin Tissot's avatar
Robin Tissot committed
40
41
42
43
44
            {% if object %}
            {% render_field form.name %}
            {% else %}
            {% render_field form.name autofocus=1 %}
            {% endif %}
45

Robin Tissot's avatar
Robin Tissot committed
46
47
48
            {% render_field form.main_script %}
            {% render_field form.read_direction %}
            {# render_field form.typology #}
49

Robin Tissot's avatar
Robin Tissot committed
50
51
52
53
            <div class="row">
                <div id="metadata-form" class="col-xl js-metadata-form">
                    <label class="my-1">{% trans "Metadata" %}</label>
                    {{ metadata_form.management_form }}
Robin Tissot's avatar
Robin Tissot committed
54

Robin Tissot's avatar
Robin Tissot committed
55
56
57
58
59
60
61
62
63
64
65
66
                    {% for subform in metadata_form.forms %}
                    <div class="input-group input-group-sm mb-2 js-metadata-row">
                        {{ subform.id }}  {# hidden #}
                        {{ subform.document }}  {# hidden #}
                        <div class="input-group-sm input-group-prepend">
                            {% render_field subform.key group=True autocomplete="on" list="metadataKeys" class="input-group-text" %}
                        </div>
                        {% render_field subform.value group=True %}
                        <div class="input-group-prepend">
                            <input type="hidden" name="documentmetadata_set-{{forloop.counter0}}-DELETE" id="id_documentmetadata_set-{{forloop.counter0}}-DELETE">
                            <button class="btn btn-outline-secondary js-metadata-delete" type="button" for="id_documentmetadata_set-{{forloop.counter0}}-DELETE"></button>
                        </div>
Robin Tissot's avatar
Robin Tissot committed
67
                    </div>
Robin Tissot's avatar
Robin Tissot committed
68
69
70
71
72
73
74
75
76
77
                    {% for errors in subform.errors.values %}{% for error in errors %}<div class="text-danger mb-2">{{ error }}</div>{% endfor %}{% endfor %}
                    {% endfor %}

                    {% if metadata_form.forms.0.choices %}
                    <datalist id="metadataKeys">
                        {% for md in metadata_form.forms.0.choices %}
                        <option>{{ md.name }}</option>
                        {% endfor %}
                    </datalist>
                    {% endif %}
Robin Tissot's avatar
Robin Tissot committed
78
79
                </div>

Robin Tissot's avatar
Robin Tissot committed
80
81
                <div id="ontology-form" class="col-xl">
                    <label class="my-1">{% trans "Ontology" %}</label>
82
83
84
85
86
87
88
89

                    <button type="button" class="btn help open" aria-label="Help">
                        <span class="fas fa-question"></span>
                    </button>
                    <div id="ontology-help" class="alert alert-primary help-text">
                        <button type="button" class="close" aria-label="Close">
                            <span aria-hidden="true">×</span>
                        </button>
90
                        <p class="form-text text-muted mb-0">{% trans "The default configuration only contains semantic types. <br>It is not recommended to mix semantic, stylistic and layout types.<br><b>It is required to hit 'Update' to add your new types to the document.</b>" %}</p>
91
92
93
                    </div>


Robin Tissot's avatar
Robin Tissot committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
                    <div id="region-types">
                        <div><small>{% trans "Region types" %}</small></div>
                        {% render_field form.valid_block_types group=True %}
                        <!-- free input handleed by js-->
                        <div class="form-row">
                            <div class="col">
                                <input class="form-control form-control-sm"
                                       id="add-region-type-input"
                                       placeholder="{% trans "Add a region type" %}" />
                            </div>
                            <div class="col-auto">
                                <button id="add-region-type-btn"
                                        class="btn btn-success fas fa-plus"></button>
                            </div>
                        </div>
                    </div>
Robin Tissot's avatar
Robin Tissot committed
110

Robin Tissot's avatar
Robin Tissot committed
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
                    <div id="line-types">
                        <div class="mt-2"><small>{% trans "Line types" %}</small></div>
                        {% render_field form.valid_line_types group=True %}
                        <div class="form-row">
                            <div class="col">
                                <input class="form-control form-control-sm"
                                       id="add-line-type-input"
                                       placeholder="{% trans "Add a line type" %}" />
                            </div>
                            <div class="col-auto">
                                <button id="add-line-type-btn"
                                        class="btn btn-success fas fa-plus"></button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
128

Robin Tissot's avatar
Robin Tissot committed
129
130
131
            <input type="submit" value="{% if object %}{% trans 'Update' %}{% else %}{% trans 'Create' %}{% endif %}" class="btn btn-success btn-block my-3" {% if object %}autofocus{% endif %}>
        </fieldset>
    </form>
132
</div>
133
134
{% endblock %}

Robin Tissot's avatar
Robin Tissot committed
135
136
137
138
{% block modals %}
{% if share_form %}
<!-- shareModal -->
<div class="modal fade" id="shareModal" tabindex="-1" role="dialog" aria-labelledby="shareModalLabel" aria-hidden="true">
Robin Tissot's avatar
Robin Tissot committed
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form method="post" action="{% url 'document-share' pk=object.pk %}">
                {% csrf_token %}

                <div class="modal-header">
                    <h3 class="modal-title" id="exampleModalLabel">{% trans "Share with" %}</h3>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <h5>{% trans "Teams" %}</h5>
                    {% render_field share_form.shared_with_groups %}
                    <h5>{% trans "Users" %}</h5>
                    {% render_field share_form.username %}
                    {% render_field share_form.shared_with_users %}
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <input type="submit" value="{% trans 'Share' %}" class="btn btn-primary">
                </div>
            </form>
        </div>
Robin Tissot's avatar
Robin Tissot committed
163
164
165
166
167
    </div>
</div>
{% endif %}
{% endblock %}

Robin Tissot's avatar
Robin Tissot committed
168
169
{% block scripts %}
{{ block.super }}
170
<script src="{% static 'js/document_form.js' %}"></script>
171
<script src="{% static 'js/help.js' %}"></script>
172

173
174
{% if object %}

175
<script type="text/javascript">
176

177
178
179
180
181
182
const onboarding  = "{{ onboarding }}";
if (onboarding== "True" && !onboarding_document)
{

    document_intro.start();
    document_intro.onexit(function() {
EL HASSANE GARGEM's avatar
EL HASSANE GARGEM committed
183
        userProfile.set('onboarding_document',true);
184
        exitonboarding();
185
186
187
188
    });

    document_intro.oncomplete(function() {
        userProfile.set('onboarding_document',true);
189
190
191
        exitonboarding();
        var images_url = "{% url 'document-images' pk=document.pk %}";
        window.location.href = images_url;
192
193
194
195
    });

}
</script>
196
{% endif %}
197

Robin Tissot's avatar
Robin Tissot committed
198
{% endblock %}
199