diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index 767fcff4d988d4bf41ac7ab30bf5fc8a0c11e450..de23276c836b57d4ff6495149a66216d60ad00a2 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -105,11 +105,15 @@ def odsh_get_spatial_text(pkg_dict): return None -def odsh_render_datetime(datetime_, date_format='{0.day:02d}.{0.month:02d}.{0.year:4d}'): +def odsh_render_datetime(datetime_, fromIso=True): + date_format='{0.day:02d}.{0.month:02d}.{0.year:4d}' if not datetime_: return '' try: - DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S' + if fromIso: + DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S' + else: + DATETIME_FORMAT = '%Y-%m-%d' dt = datetime.datetime.strptime( datetime_, DATETIME_FORMAT) return dt.strftime('%d.%m.%Y') diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo index fad2be93b305da5ac2ae00cffa567377b95df015..af5ed0c634f28dd2ada0363867e8c0f1f22a8ad6 100644 Binary files a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo and b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo differ diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po index 84f15ec8e0b894373f015fc18c252d999cb7e649..1fc8c021608d0b592163f17ad485d878b8218916 100644 --- a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po +++ b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po @@ -291,7 +291,7 @@ msgid "map" msgstr "Karte" msgid "wrong_start_date_for_search" -msgstr "Das Datum ist ungültig" +msgstr "Das Startdatum ist ungültig" msgid "wrong_end_date_for_search" -msgstr "Das Datum ist ungültig" +msgstr "Das Enddatum ist ungültig" diff --git a/ckanext/odsh/public/odsh.css b/ckanext/odsh/public/odsh.css index ccaa8fc30c3a6ab24d237c4c6464b7c0ccd236fb..9554c8987875742bf83aa4c7133dddd3a3635714 100644 --- a/ckanext/odsh/public/odsh.css +++ b/ckanext/odsh/public/odsh.css @@ -367,6 +367,9 @@ label.rangesearch.disabled { top: -8px; right: -8px; } +.pill.error .remove .fa.fa-times{ + background-color: #d4004b; +} .container-fluid.odsh-dataset-item { padding: 20px 0px 20px 0px; @@ -1349,6 +1352,10 @@ display: none; background-color: #003064; color:white; } +.filtered.pill.error{ + background-color: #d4004b; +} + .site-title{ color:black; /* text-align:center; */ diff --git a/ckanext/odsh/templates/package/search.html b/ckanext/odsh/templates/package/search.html index 14ff1f517d788c6979fca30481165f093588b20b..58e3082df7fdce3fc18c2ca11551f4714e45cf78 100644 --- a/ckanext/odsh/templates/package/search.html +++ b/ckanext/odsh/templates/package/search.html @@ -39,9 +39,9 @@ default_extent="{ \"type\": \"Polygon\", \"coordinates\": [[[7.6574,53.1632],[11 <form id="date-search-form" method="get" action="{% url_for controller='package', action='search' %}"> <div class='controls rangesearch'> {%- set start = request.params['ext_startdate'] -%} - {%- set start_error = h.odsh_render_datetime(start) == '' and start -%} + {%- set start_error = h.odsh_render_datetime(start, False) == '' and start -%} {%- set end = request.params['ext_enddate'] -%} - {%- set end_error = h.odsh_render_datetime(end) == '' and end -%} + {%- set end_error = h.odsh_render_datetime(end, False) == '' and end -%} {%- set typeStart = 'text' if (start_error or not start) else 'date' -%} {%- set typeEnd = 'text' if (end_error or not end) else 'date' -%} {%- set onFocus = 'onfocus=(this.type=\'date\')' -%} diff --git a/ckanext/odsh/templates/snippets/search_form.html b/ckanext/odsh/templates/snippets/search_form.html index 8e3add90ca3e35aaefc6a5ef455729d370296203..b06a845877982ea6f1f9c1be5536767ececf2334 100644 --- a/ckanext/odsh/templates/snippets/search_form.html +++ b/ckanext/odsh/templates/snippets/search_form.html @@ -73,25 +73,37 @@ {% endif %} {% endif %} <div id="datesearch-filter"> - {%set start_date=h.odsh_render_datetime(request.params.get('ext_startdate'))%} - {%set end_date=h.odsh_render_datetime(request.params.get('ext_enddate'))%} + {%set start_date=h.odsh_render_datetime(request.params.get('ext_startdate'), False)%} + {%set end_date=h.odsh_render_datetime(request.params.get('ext_enddate'), False)%} {%- set start_error = start_date == '' and request.params.get('ext_startdate')-%} {%- set end_error = end_date == '' and request.params.get('ext_enddate')-%} - {% if (start_date or end_date) and (not start_error and not end_error)%} + {% if start_date or end_date or start_error or end_error%} <p class="filter-list"> - {% if start_date %} + {% if start_date and not start_error%} <span class="filtered pill"> {{_('daterange')}}: {{_('from')}} {{ start_date}} <a href="{{ h.remove_url_param('ext_startdate') }}" class="remove" title="{{ _('Remove') }}"><i class="fa fa-times"></i></a> </span> {% endif %} + {% if start_error %} + <span class="filtered pill error"> + {{_('daterange')}}: {{_('wrong_start_date_for_search')}} + <a href="{{ h.remove_url_param('ext_startdate') }}" class="remove" title="{{ _('Remove') }}"><i class="fa fa-times"></i></a> + </span> + {% endif %} - {% if end_date %} + {% if end_date and not end_error%} <span class="filtered pill"> {{_('daterange')}}: {{_('to')}} {{ end_date}} <a href="{{ h.remove_url_param('ext_enddate') }}" class="remove" title="{{ _('Remove') }}"><i class="fa fa-times"></i></a> </span> {% endif %} + {% if end_error %} + <span class="filtered pill error"> + {{_('daterange')}}: {{_('wrong_end_date_for_search')}} + <a href="{{ h.remove_url_param('ext_enddate') }}" class="remove" title="{{ _('Remove') }}"><i class="fa fa-times"></i></a> + </span> + {% endif %} </p> {% endif %} </div>