Skip to content

Commit

Permalink
Template formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Nov 16, 2023
1 parent 56c911e commit dd9b592
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 107 deletions.
6 changes: 3 additions & 3 deletions openatlas/templates/entity/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{% block content %}
{% if entity.class_.view not in ['artifact', 'place'] %}
<div class="container">
{{ form|display_form(manual_page='entity/' + entity.class_.view)|safe }}
{{ entity.class_.view|display_citation_example|safe }}
{{ form|display_form(manual_page='entity/' + entity.class_.view)|safe }}
{{ entity.class_.view|display_citation_example|safe }}
</div>
{% else %}
<div class="row">
Expand All @@ -20,7 +20,7 @@
<div id="map" class="map"></div>
</div>
</div>
<link rel="stylesheet" href="/static/node_modules/leaflet-draw/dist/leaflet.draw.css"/>
<link rel="stylesheet" href="/static/node_modules/leaflet-draw/dist/leaflet.draw.css">
<script src="/static/node_modules/leaflet-draw/dist/leaflet.draw.js"></script>
<script src="/static/js/map/map.js"></script>
<script src="/static/js/map/draw.js"></script>
Expand Down
16 changes: 8 additions & 8 deletions openatlas/templates/forms/reference_field.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
name="reference_system_id_{{ field.reference_system_id }}"
type="text"
class="{{ config.CSS.string_field }}"
data-reference-system="{{ field.label.text.replace(' ','-') }}"/>

data-reference-system="{{ field.label.text.replace(' ','-') }}">
</div>
<div class="col-6">
<input value="and" type="hidden"/>
<select value="" id="reference_system_precision_{{ field.reference_system_id }}"
name="reference_system_id_{{ field.reference_system_id }}"
class="{{ config.CSS.string_field }}">
<input value="and" type="hidden">
<select
value=""
id="reference_system_precision_{{ field.reference_system_id }}"
name="reference_system_id_{{ field.reference_system_id }}"
class="{{ config.CSS.string_field }}">
<option value="" disabled selected>{{ _('precision') | uc_first }}</option>
{% for choice in field.choices %}
<option {{ 'selected' if field.data['precision'] == choice[0] }}
value="{{ choice[0] }}">{{ choice[1] }}</option>
<option {{ 'selected' if field.data['precision'] == choice[0] }} value="{{ choice[0] }}">{{ choice[1]}}</option>
{% endfor %}
</select>
</div>
Expand Down
20 changes: 10 additions & 10 deletions openatlas/templates/forms/table_multi_select.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
id="{{ field.id }}-button"
class="{{ config.CSS.button.secondary }}"
onclick="$('#{{ field.id }}-modal').modal('show')"
tabindex="0"
>
tabindex="0">
{{ _('change')|uc_first }}
</span>
</div>
Expand Down Expand Up @@ -59,13 +58,14 @@ <h5 class="modal-title">{{ _(field.id.replace('_', ' '))|uc_first }}</h5>
</div>
</div>
<script>
$('#{{ field.id }}-button')
.on('keydown', function (event) {
if (onActivateKeyInput(event))
$('#{{ field.id }}-modal').modal('show')
});
$('#{{ field.id }}-button').on(
'keydown',
function (event) {
if (onActivateKeyInput(event))
$('#{{ field.id }}-modal').modal('show')
});

$("#{{ field.id }}-modal").on("hidden.bs.modal", function (e) {
selectFromTableMulti('{{ field.id }}');
})
$("#{{ field.id }}-modal").on("hidden.bs.modal", function (e) {
selectFromTableMulti('{{ field.id }}');
})
</script>
28 changes: 14 additions & 14 deletions openatlas/templates/forms/table_select.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
readonly="readonly"
value="{{ selection }}"
onclick="$('#{{ field.id }}-modal').modal('show')"
tabindex="0"
>
tabindex="0">
</div>
<div id="{{ field.id }}-clear-field" class="col-auto" {% if not selection %}style="display: none;"{% endif %}>
<a
Expand Down Expand Up @@ -100,19 +99,20 @@ <h5 class="modal-title">+ {{ _(add_dynamical)|uc_first }}</h5>
</div>

<script>
$("#{{ field.id }}-button")
.on('keydown', function (event) {
if (onActivateKeyInput(event))
$('#{{ field.id }}-modal').modal('show');
});
$("#{{ field.id }}-button").on(
'keydown',
function (event) {
if (onActivateKeyInput(event))
$('#{{ field.id }}-modal').modal('show');
});

$("#add-{{ add_dynamical }}-modal-{{field.id}} #name_dynamic")
.on('keyup change', function () {
if ($(this).val() === '')
$('#{{field.id}}-add-{{ add_dynamical }}').attr('disabled', '')
else
$('#{{field.id}}-add-{{ add_dynamical }}').removeAttr('disabled')
});
.on('keyup change', function () {
if ($(this).val() === '')
$('#{{field.id}}-add-{{ add_dynamical }}').attr('disabled', '')
else
$('#{{field.id}}-add-{{ add_dynamical }}').removeAttr('disabled')
});

$('#{{field.id}}-add-{{ add_dynamical }}')
.on('click', async function (e) {
Expand All @@ -126,7 +126,7 @@ <h5 class="modal-title">+ {{ _(add_dynamical)|uc_first }}</h5>
const entityId = await ajaxAddEntity(data);
const relatedTables = {{ field.related_tables | safe }};
relatedTables
?.forEach(x => refillTable(x, {{ field.filter_ids }}));
?.forEach(x => refillTable(x, {{ field.filter_ids }}));
await refillTable('{{ field.id }}', {{ field.filter_ids }});
$(this).prop("disabled", false).text('{{ _('insert')|uc_first }}');
$('.modal').modal('hide');
Expand Down
146 changes: 74 additions & 72 deletions openatlas/templates/forms/tree_multi_select.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
<div
id="{{ field.id }}-selection"
class="g-1 row {{ config.CSS.string_field }}"
onclick="$('#{{ field.id }}-modal').modal('show')"
>
onclick="$('#{{ field.id }}-modal').modal('show')">
{% for s in selection %}
<div onclick="event.stopPropagation()" class="badge col-auto bg-gray">
<div class="d-flex align-items-center">
<span class="text-black">{{ g.types[s].name }}</span>
<button
onclick="deselectNode('{{ field.id }}',{{ s }})"
type="button"
class="btn-close p-0 ms-1"
aria-label="Close"
onclick="deselectNode('{{ field.id }}',{{ s }})"
type="button"
class="btn-close p-0 ms-1"
aria-label="Close"
></button>
</div>
</div>
Expand All @@ -22,10 +21,10 @@
</div>
<div class="col-auto">
<span
id="{{ field.id }}-button"
class="{{ config.CSS.button.secondary }} uc-first"
onclick="$('#{{ field.id }}-modal').modal('show')"
tabindex="0">{{ _('change') }}
id="{{ field.id }}-button"
class="{{ config.CSS.button.secondary }} uc-first"
onclick="$('#{{ field.id }}-modal').modal('show')"
tabindex="0">{{ _('change') }}
</span>
</div>
</div>
Expand All @@ -51,15 +50,17 @@ <h5 class="modal-title">{{ root.name|uc_first }}</h5>
<div class="modal-body ">
<div class="d-flex">
<input
class="tree-filter {{ config.CSS.string_field }}"
id="{{ field.id }}-tree-search"
placeholder="{{ _('type to search')|uc_first }}"
type="text">
class="tree-filter {{ config.CSS.string_field }}"
id="{{ field.id }}-tree-search"
placeholder="{{ _('type to search')|uc_first }}"
type="text">
{% if field.form %}
<button type="button" id="add-{{ type }}--{{ field.id }}"
class="btn-outline-primary btn text-nowrap ms-1"
data-bs-toggle="modal"
data-bs-target="#add-type-modal-{{ field.id }}">
<button
type="button"
id="add-{{ type }}--{{ field.id }}"
class="btn-outline-primary btn text-nowrap ms-1"
data-bs-toggle="modal"
data-bs-target="#add-type-modal-{{ field.id }}">
+ {{ root.name }}
</button>
{% endif %}
Expand Down Expand Up @@ -89,77 +90,78 @@ <h5 class="modal-title">{{ root.name|uc_first }}</h5>
<div class="modal-header">
<h5 class="modal-title"> {{ _('Add Type to %(hierarchy)s', hierarchy= root.name|safe) }} </h5>
<button
type="button"
class="{{ config.CSS.button.primary }}"
data-bs-dismiss="modal"
aria-label="Close"><span aria-hidden="true">&times;</span>
type="button"
class="{{ config.CSS.button.primary }}"
data-bs-dismiss="modal"
aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
{{ field.form|display_form()|safe }}
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-outline-secondary btn-sm"
data-bs-dismiss="modal"
onclick="$('#{{ field.id }}-modal').modal('show')">{{ _('back')|uc_first }}</button>
type="button"
class="btn btn-outline-secondary btn-sm"
data-bs-dismiss="modal"
onclick="$('#{{ field.id }}-modal').modal('show')">{{ _('back')|uc_first }}</button>
<button
id="{{ field.id }}-add-type"
disabled type="button"
class="btn btn-outline-primary btn-sm">{{ _('insert')|uc_first }}</button>
id="{{ field.id }}-add-type"
disabled type="button"
class="btn btn-outline-primary btn-sm">{{ _('insert')|uc_first }}</button>
</div>
</div>
</div>
</div>
<script>
$("#add-type-modal-{{field.id}} #name-dynamic").on('keyup change', function () {
if ($(this).val() === '')
$('#{{field.id}}-add-type').attr('disabled', '')
else
$('#{{field.id}}-add-type').removeAttr('disabled')
});
$("#add-type-modal-{{field.id}} #name-dynamic").on('keyup change', function () {
if ($(this).val() === '')
$('#{{field.id}}-add-type').attr('disabled', '')
else
$('#{{field.id}}-add-type').removeAttr('disabled')
});

$('#{{field.id}}-add-type').on('click', async function (e) {
$(this).prop("disabled", true).text('{{ _("in progress") }}');
const name = $("#add-type-modal-{{field.id}} #name-dynamic").val();
const superType = $("#{{field.id}}-dynamic").val() ||{{field.type_id}};
const description = $("#add-type-modal-{{field.id}} #description-dynamic").val();
const data = {name, superType, description};
const typeId = await ajaxAddType(data, {{field.id}}, {{field.type_id}}, true);
$(`#{{field.type_id}}-modal`).modal('show');
$(this).prop("disabled", false).text('{{ _('insert')|uc_first }}');
e.preventDefault();
});
$('#{{field.id}}-add-type').on('click', async function (e) {
$(this).prop("disabled", true).text('{{ _("in progress") }}');
const name = $("#add-type-modal-{{field.id}} #name-dynamic").val();
const superType = $("#{{field.id}}-dynamic").val() ||{{field.type_id}};
const description = $("#add-type-modal-{{field.id}} #description-dynamic").val();
const data = {name, superType, description};
const typeId = await ajaxAddType(data, {{field.id}}, {{field.type_id}}, true);
$(`#{{field.type_id}}-modal`).modal('show');
$(this).prop("disabled", false).text('{{ _('insert')|uc_first }}');
e.preventDefault();
});
</script>
{% endif %}

<script>
$('#{{ field.id }}-button')
.on('keydown', function (event) {
if (onActivateKeyInput(event))
$('#{{ field.id }}-modal').modal('show')
});
$('#{{ field.id }}-button').on('keydown', function (event) {
if (onActivateKeyInput(event))
$('#{{ field.id }}-modal').modal('show')
});

$("#{{ field.id }}-tree").jstree({
"core": {"check_callback": true, "data": {{ data|safe }}},
"plugins": ["search", "checkbox"],
"checkbox": {"three_state": false},
"search": {
"case_insensitive": true,
"show_only_matches": true,
"show_only_matches_children": true
}
});
$("#{{ field.id }}-tree-search").keyup(function () {
if (this.value.length >= {{ g.settings.minimum_jstree_search }}) {
$("#{{ field.id }}-tree").jstree("search", $(this).val());
} else if (this.value.length == 0) {
$("#{{ field.id }}-tree").jstree("search", $(this).val());
$("#{{ field.id }}-tree").jstree(true).show_all();
}
});
$("#{{ field.id }}-tree").jstree({
"core": {"check_callback": true, "data": {{ data|safe }}},
"plugins": ["search", "checkbox"],
"checkbox": {"three_state": false},
"search": {
"case_insensitive": true,
"show_only_matches": true,
"show_only_matches_children": true
}
});

$("#{{ field.id }}-tree-search").keyup(function () {
if (this.value.length >= {{ g.settings.minimum_jstree_search }}) {
$("#{{ field.id }}-tree").jstree("search", $(this).val());
} else if (this.value.length == 0) {
$("#{{ field.id }}-tree").jstree("search", $(this).val());
$("#{{ field.id }}-tree").jstree(true).show_all();
}
});

$("#{{ field.id }}-modal").on("hidden.bs.modal", function (e) {
selectFromTreeMulti({{ field.id }});
})
$("#{{ field.id }}-modal").on("hidden.bs.modal", function (e) {
selectFromTreeMulti({{ field.id }});
})
</script>

0 comments on commit dd9b592

Please sign in to comment.