Skip to content

Commit

Permalink
#66 add RNDT fields in advanced editing
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi authored Mar 18, 2021
1 parent 232a2db commit 187de26
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 95 deletions.
23 changes: 23 additions & 0 deletions rndt/templates/layers/layer_metadata_advanced.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "layers/layer_metadata_advanced.html" %}
{% load i18n %}
{% load static %}
{% load floppyforms %}

{% block other_tab %}
<br>
<div class="content">
{% include "rndt/data_constraints_tab.html" %}
</div>
{% endblock other_tab %}


{% block layer_fields %}
{% for field in layer_form %}
{% if field.name != 'use_featureinfo_custom_template' and field.name != 'featureinfo_custom_template' and field.name != 'constraints_other' and field.name != 'restriction_code_type' %}
<div>
<span><label for="{{ field.id }}">{{ field.label }}</label></span>
{{ field }}
</div>
{% endif %}
{% endfor %}
{% endblock layer_fields %}
99 changes: 4 additions & 95 deletions rndt/templates/layouts/panels.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,100 +61,9 @@
</div>
{% endblock edit_progress %}

{% block other_tab %}
{% load rndt_extra %}
{% block other_tab %}
{% load rndt_extra %}
<div id="additionalcontraints" class="tab-pane fade">
<div class="panel-group">
<div class="col-xs-12 col-lg-8">
<div class="panel panel-default">
<div class="panel-heading">{% trans "Data Constraints" %}</div>
<div class="panel-body">
<div id="accessConstraintsInfo">
<!--span><label>{% trans "Access constraints" %}</label></span>
{{ LayerRNDTForm.access_contraints }}-->
<span><label for="id_access_contraints" class="control-label required-field">{% trans "Access constraints" %}</label></span>
<select
title="{% trans "Choose one of the following..." %}"
name="access_contraints"
id="id_access_contraints"
class="selectpicker form-control"
>
{% for item in LayerRNDTForm.access_contraints.field.choices %}
{% if item.0|get_access_contraints:layer.id %}
<option selected value="{{ item.0 }}">
{% else %}
<option value="{{ item.0 }}">
{% endif %}
{{ item.1 }}
</option>
{% endfor %}
</select>
</div>
<div id="useConstraintsInfo">
<span><label for="id_use_constraints" class="control-label required-field">{% trans "Use constraints" %}</label></span>
<select
title="{% trans "Choose one of the following..." %}"
name="use_constraints"
id="id_use_constraints"
class="selectpicker form-control"
>
{% for item in LayerRNDTForm.use_constraints.field.choices %}
{% if item.0|get_other_constraint:layer.id %}
<option selected value="{{ item.0 }}">
{% else %}
<option value="{{ item.0 }}">
{% endif %}
{{ item.1 }}
</option>
{% endfor %}
</select>
</div>
<div id="free_text" hidden>
<span><label>{% trans "Free text" %}</label></span>
{{ LayerRNDTForm.free_text }}
</div>
<script type="text/javascript">
$(document).ready(function() {
$("select[name$='use_constraints']").change(function() {
if ($(this).val() == 'freetext') {
$("#free_text").show();
} else {
$("#free_text").hide();
}
});
var x = $("#id_use_constraints");
if ((x.val() == 'freetext' || x.val() == '') && "{{layer.constraints_other}}"==='None') {
$("select[id$='id_use_constraints']").val("");
$("textarea[id$='free_text']").val("");
}
else if ((x.val() == 'freetext' || x.val() == '') && "{{layer.constraints_other}}") {
$("select[id$='id_use_constraints']").val("freetext");
$("textarea[id$='free_text']").val("{{layer.constraints_other}}");
$("div[id$='free_text']").show();
}
});
</script>
</div>
</div>
</div>
<div class="col-xs-12 col-lg-4">
<div>
<span><label for="id_resolution" class="control-label required-field">{% trans "Resolution" %}</label></span><br>
<div class="custom">
<div class="input-group resolution">
<div class="input-group-addon">mt</div>
{{ LayerRNDTForm.resolution|get_resolution_value:layer.id }}
</div>
</div>
<span><label for="id_accuracy" class="control-label required-field">{% trans "Positional Accuracy" %}</label></span><br>
<div class="custom">
<div class="input-group accuracy">
<div class="input-group-addon">mt</div>
{{ LayerRNDTForm.accuracy|get_accuracy_value:layer.id }}
</div>
</div>
</div>
</div>
</div>
{% include "rndt/data_constraints_tab.html" %}
</div>
{% endblock other_tab %}
{% endblock other_tab %}
97 changes: 97 additions & 0 deletions rndt/templates/rndt/data_constraints_tab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{% load i18n %}
{% load static %}
{% load floppyforms %}
{% load rndt_extra %}

<div class="panel-group">
<div class="col-xs-12 col-lg-8">
<div class="panel panel-default">
<div class="panel-heading">{% trans "Data Constraints" %}</div>
<div class="panel-body">
<div id="accessConstraintsInfo">
<!--span><label>{% trans "Access constraints" %}</label></span>
{{ LayerRNDTForm.access_contraints }}-->
<span><label for="id_access_contraints" class="control-label required-field">{% trans "Access constraints" %}</label></span>
<select
title="{% trans "Choose one of the following..." %}"
name="access_contraints"
id="id_access_contraints"
class="selectpicker form-control"
>
{% for item in LayerRNDTForm.access_contraints.field.choices %}
{% if item.0|get_access_contraints:layer.id %}
<option selected value="{{ item.0 }}">
{% else %}
<option value="{{ item.0 }}">
{% endif %}
{{ item.1 }}
</option>
{% endfor %}
</select>
</div>
<div id="useConstraintsInfo">
<span><label for="id_use_constraints" class="control-label required-field">{% trans "Use constraints" %}</label></span>
<select
title="{% trans "Choose one of the following..." %}"
name="use_constraints"
id="id_use_constraints"
class="selectpicker form-control"
>
{% for item in LayerRNDTForm.use_constraints.field.choices %}
{% if item.0|get_other_constraint:layer.id %}
<option selected value="{{ item.0 }}">
{% else %}
<option value="{{ item.0 }}">
{% endif %}
{{ item.1 }}
</option>
{% endfor %}
</select>
</div>
<div id="free_text" hidden>
<span><label>{% trans "Free text" %}</label></span>
{{ LayerRNDTForm.free_text }}
</div>
<script type="text/javascript">
$(document).ready(function() {
$("select[name$='use_constraints']").change(function() {
if ($(this).val() == 'freetext') {
$("#free_text").show();
} else {
$("#free_text").hide();
}
});
var x = $("#id_use_constraints");
if ((x.val() == 'freetext' || x.val() == '') && "{{layer.constraints_other}}"==='None') {
$("select[id$='id_use_constraints']").val("");
$("textarea[id$='free_text']").val("");
}
else if ((x.val() == 'freetext' || x.val() == '') && "{{layer.constraints_other}}") {
$("select[id$='id_use_constraints']").val("freetext");
$("textarea[id$='free_text']").val("{{layer.constraints_other}}");
$("div[id$='free_text']").show();
}
});
</script>
</div>
</div>
</div>
<div class="col-xs-12 col-lg-4">
<div>
<span><label for="id_resolution" class="control-label required-field">{% trans "Resolution" %}</label></span><br>
<div class="custom">
<div class="input-group resolution">
<div class="input-group-addon">mt</div>
{{ LayerRNDTForm.resolution|get_resolution_value:layer.id }}
</div>
</div>
<span><label for="id_accuracy" class="control-label required-field">{% trans "Positional Accuracy" %}</label></span><br>
<div class="custom">
<div class="input-group accuracy">
<div class="input-group-addon">mt</div>
{{ LayerRNDTForm.accuracy|get_accuracy_value:layer.id }}
</div>
</div>
</div>
</div>
</div>

0 comments on commit 187de26

Please sign in to comment.