diff --git a/geonode/context_processors.py b/geonode/context_processors.py index add7156795f..169910e8ef4 100644 --- a/geonode/context_processors.py +++ b/geonode/context_processors.py @@ -192,6 +192,7 @@ def resource_urls(request): GEONODE_APPS_ENABLE=getattr(settings, 'GEONODE_APPS_ENABLE', False), GEONODE_APPS_NAME=getattr(settings, 'GEONODE_APPS_NAME', 'Apps'), GEONODE_APPS_NAV_MENU_ENABLE=getattr(settings, 'GEONODE_APPS_NAV_MENU_ENABLE', False), - CATALOG_METADATA_TEMPLATE=getattr(settings, "CATALOG_METADATA_TEMPLATE", "catalogue/full_metadata.xml") + CATALOG_METADATA_TEMPLATE=getattr(settings, "CATALOG_METADATA_TEMPLATE", "catalogue/full_metadata.xml"), + UI_REQUIRED_FIELDS=getattr(settings, "UI_REQUIRED_FIELDS", []) ) return defaults diff --git a/geonode/layers/templates/layouts/panels.html b/geonode/layers/templates/layouts/panels.html index 3e4cbbb6231..698f493d430 100644 --- a/geonode/layers/templates/layouts/panels.html +++ b/geonode/layers/templates/layouts/panels.html @@ -239,9 +239,19 @@
{% trans "Mandatory" %}
-
- {% trans "Optional" %} -
+ {% if UI_REQUIRED_FIELDS %} +
+ {% trans "Mandatory" %} +
+
+ {% trans "Optional" %} +
+ {% else %} +
+ {% trans "Optional" %} +
+ {% endif %} + {% endblock edit_progress %} {% block breadcrumbs %} @@ -253,7 +263,11 @@ {% trans "Location and Licenses" %}
  • - {% trans "Optional Metadata" %} + {% if UI_REQUIRED_FIELDS %} + {% trans "Required Metadata" %} + {% else %} + {% trans "Optional Metadata" %} + {% endif %}
  • {% trans "Dataset Attributes" %} @@ -448,7 +462,7 @@ {% block ownership %}
    -
    +

    {% trans "Other, Optional, Metadata" %}

    @@ -468,14 +482,14 @@
    -
    +
    {{ layer_form.temporal_extent_start }}
    -
    +
    @@ -498,7 +512,7 @@
    {% trans "Responsible Parties" %}
    -
    +
    {{ layer_form.poc }}
    diff --git a/geonode/templates/metadata_form_js.html b/geonode/templates/metadata_form_js.html index 348d0acf397..9050d165485 100644 --- a/geonode/templates/metadata_form_js.html +++ b/geonode/templates/metadata_form_js.html @@ -91,6 +91,26 @@ } advancedMissing = empty > 0; } + + {% if UI_REQUIRED_FIELDS %} + var advancedMissing = $('#ownership').find('.input-empty').length > 0; + if (advancedMissing) { + var inputs = $('#ownership').find('.input-empty'); + var empty = inputs.length; + for (var i=0; i 0; + } + $('#completeness-hints .metadata-hint') + .toggleClass('progress-bar-danger', mandatoryMissing) + .toggleClass('progress-bar-success', !mandatoryMissing) + .attr('title', mandatoryMissing ? gettext("some schema mandatory fields are missing") : gettext("Metadata Schema mandatory fields completed") ) + .tooltip('fixTitle'); + {% endif %} + $('#completeness-hints .mandatory-hint') .toggleClass('progress-bar-danger', mandatoryMissing) .toggleClass('progress-bar-success', !mandatoryMissing) @@ -224,7 +244,7 @@ {% block target %} if(target.id === 'category_form' || target.id === 'id_resource-regions' || - target.id === 'id_resource-group' + target.id === 'id_resource-group' || {{UI_REQUIRED_FIELDS}}.includes(target.id) ) { // group selector $(target).closest('#basicGroupInfo').toggleClass('has-error', empty); @@ -307,8 +327,11 @@ if(!$(e.target).hasClass("input-empty")){ if(isMandatoryField(this)) { setInputEmpty(e.target, true); - if(!!$(this).closest('#mdinfo').length) { - $(e.target).parent().append(gettext("

       {% trans "* Field declared Mandatory by the Metadata Schema" %}

    ")); + var mandatoryWarning = "

       {% trans "* Field declared Mandatory by the Metadata Schema" %}

    " + if (!!$(this).closest('.check-select').length) { + $(e.target).parent().parent().append(gettext(mandatoryWarning)); + } else if (!!$(this).closest('#mdinfo').length) { + $(e.target).parent().append(gettext(mandatoryWarning)); } empty++; } @@ -337,6 +360,7 @@ }; {% endblock onInputChange %} {% block trigger_onInputChange %} + {{UI_REQUIRED_FIELDS}}.forEach(element => $('#' + element).change(onInputChange).change()); $('#category_form').change(onInputChange).change(); $('#id_resource-group').change(onInputChange).change(); document.querySelector('select[name="resource-keywords"]').onchange=onInputChange