Skip to content

Commit

Permalink
[Fixes: #7034] Metadata UI freezes on empty mandatory fields (#7035)
Browse files Browse the repository at this point in the history
* [Fixes: #7034] Metadata UI freezes on empty mandatory fields

* [Fixes: #7034] italian translations added

* [Fixes: #7034] Metadata UI freezes on empty mandatory fields
  • Loading branch information
mattiagiupponi authored Mar 9, 2021
1 parent 9d709e8 commit 1c6cafb
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
19 changes: 19 additions & 0 deletions geonode/layers/templates/layers/layer_metadata_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,25 @@ <h2>{% trans "Metadata Provider" %}</h2>
</form>
</div>
</div>

<div class="modal fade" style="width: 100%; height: 100%;" id="error_mandatoryDialog" data-backdrop="static" data-keyboard="false" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content panel-warning">
<div class="modal-header panel-heading">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">{% trans "ERROR" %}</h4>
</div>
<div class="modal-body general_errors">
{% trans "Following items are required:" %}
<p id="general_errors"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>

{% endblock %}

{% block extra_script %}
Expand Down
Binary file modified geonode/locale/it/LC_MESSAGES/django.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions geonode/locale/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6276,6 +6276,9 @@ msgstr "stato dell'elemento sconosciuto: %s"
msgid "error during import: %s"
msgstr "errore durante l'importazione: %s"

msgid "Following items are required:"
msgstr "I seguenti elementi sono obbligatori:"

msgid "Could not find any valid Time Regex for the Mosaic files."
msgstr "Impossibile trovare file kml all'interno del kmz caricato."

Expand Down
18 changes: 18 additions & 0 deletions geonode/templates/metadata_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,24 @@ <h4 class="modal-title">{% trans "ERROR" %}</h4>
</div>
</div>
</div>

<div class="modal fade" style="width: 100%; height: 100%;" id="error_mandatoryDialog" data-backdrop="static" data-keyboard="false" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content panel-warning">
<div class="modal-header panel-heading">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">{% trans "ERROR" %}</h4>
</div>
<div class="modal-body general_errors">
{% trans "Following items are required:" %}
<p id="general_errors"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>
{% block body %}{% endblock body %}
{% block sidebar %}{% endblock sidebar %}
{% endblock body_outer %}
Expand Down
26 changes: 24 additions & 2 deletions geonode/templates/metadata_form_js.html
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@
{{UI_REQUIRED_FIELDS}}.forEach(element => $('#' + element).change(onInputChange).change());
$('#category_form').change(onInputChange).change();
$('#id_resource-group').change(onInputChange).change();

$( ':input[id*="id_tkeywords"][required]:visible').each( function () {
$('#' + this.id).change(onInputChange).change();
});

document.querySelector('select[name="resource-keywords"]').onchange=onInputChange

$('#id_resource-regions').change(onInputChange).change();
Expand Down Expand Up @@ -469,7 +474,7 @@
) {
$('#group_mandatoryDialog').modal();
} else {
$('#preview_pleaseWaitDialog').modal();
validateRequiredInput()
}
});

Expand All @@ -491,9 +496,26 @@
) {
$('#group_mandatoryDialog').modal();
} else {
$('#preview_pleaseWaitDialog').modal();
validateRequiredInput()
}
});

function validateRequiredInput() {
const required_inputs = $(':input[required]:visible')
var errors = []
$( ':input[required]:visible').each( function () {
if ( this.value.trim() == '' ) {
errors.push(this.id)
}
});
if (errors.length > 0) {
console.error("Following items are required: " + errors)
$(".general_errors").find("p").html(errors.join('<br>'));
$('#error_mandatoryDialog').modal();
} else {
$('#preview_pleaseWaitDialog').modal();
}
}

$('#btn_upd_md_done').click(function(){
if
Expand Down

0 comments on commit 1c6cafb

Please sign in to comment.