diff --git a/ckanext/odsh/fanstatic/odsh.js b/ckanext/odsh/fanstatic/odsh.js index af5b78e36c6c2d410c9c79470de60ae6cb9a68eb..49ca4d02fed8fb9651de70cf5dc3831b37241d54 100644 --- a/ckanext/odsh/fanstatic/odsh.js +++ b/ckanext/odsh/fanstatic/odsh.js @@ -1,6 +1,5 @@ $(document).ready(function() { $('.mylabel').click(function() { - console.log($(this).siblings()); window.location = $(this).siblings('a').attr('href'); }); }); diff --git a/ckanext/odsh/fanstatic/odsh_rangesearch.js b/ckanext/odsh/fanstatic/odsh_rangesearch.js new file mode 100644 index 0000000000000000000000000000000000000000..1047d7fb9ae82d745c71571f75794e8767a4692b --- /dev/null +++ b/ckanext/odsh/fanstatic/odsh_rangesearch.js @@ -0,0 +1,32 @@ +ckan.module('odsh_rangesearch', function ($) +{ + return { + initialize: function () + { + var start = $("#ext_startdate") + var end = $("#ext_enddate") + var checkbox = $('#check-rangefilter') + var label = $('#rangesearch-label') + label.click(function () + { + if (label.hasClass('checked')) + { + start.val('') + end.val('') + } + if (!label.hasClass('disabled')) + $('#date-search-form').submit(); + }); + + var updateCheckbox = function () + { + var enable = (start.val() || end.val()) + label.toggleClass('disabled', !enable); + if (!enable) + $('#date-search-form').submit(); + }; + start.change(updateCheckbox) + end.change(updateCheckbox) + } + }; +}); \ No newline at end of file diff --git a/ckanext/odsh/public/odsh.css b/ckanext/odsh/public/odsh.css index f538a1aa387c9bdadedf974c56ac642f3bce4a70..51c2199f8f5c5e1a2efd35635c09c9ad7a261115 100644 --- a/ckanext/odsh/public/odsh.css +++ b/ckanext/odsh/public/odsh.css @@ -260,7 +260,8 @@ input[type=radio], input[type=checkbox] { display:none; } -/* input[type=checkbox] + label.checkbox, */ + +label.rangesearch, input[type=checkbox] + label.mylabel { background: #fff; border: 1px solid black; @@ -271,12 +272,8 @@ input[type=checkbox] + label.mylabel { margin-bottom: 0px; min-height: 8px; } -/* input[type=checkbox] + label.checkbox{ - - border: 1px solid black; -} */ -/* input[type=checkbox]:checked + label.checkbox, */ +label.rangesearch.checked, input[type=checkbox]:checked + label.mylabel { background: url(/base/images/checked.png); background-color: #fff; @@ -290,14 +287,12 @@ input[type=checkbox]:checked + label.mylabel { margin-bottom: 0px; } -/* .checklabel .controls > .checkbox:first-child { - padding-top: 0px; -} */ .checklabel input[type="checkbox"] { float: inherit; } +label.rangesearch, label.mylabel { margin-right: 3px; margin-bottom: 0px; @@ -307,10 +302,37 @@ label.mylabel { user-select: none; /* Standard */ } +label.rangesearch::after, label.mylabel::after { content: ""; } +label.rangesearch.disabled { + cursor: default; + border-color: #999999; +} + +.rangesearch-controls{ + margin-top:10px; +} + +.rangesearch{ + display: inline-block; +} + +.controls input.rangesearch{ + width:155px; + padding: 2px; + font-size: 12px; + line-height: 1.16666667em; +} + +.controls.rangesearch label{ + font-size: 12px; + line-height: 1.16666667em; + color:black +} + /* following makes the secondary span (left side, facets etc.) the same height as the primary span */ /* see: https://scotch.io/bar-talk/different-tricks-on-how-to-make-bootstrap-columns-all-the-same-height */ .is-table-row { diff --git a/ckanext/odsh/templates/package/search.html b/ckanext/odsh/templates/package/search.html index 5daf02958e0caa2d64d7848b78d4dfd37044bc2a..41319b3d220bead15c099f37acc59be51d0fb21f 100644 --- a/ckanext/odsh/templates/package/search.html +++ b/ckanext/odsh/templates/package/search.html @@ -32,15 +32,35 @@ default_extent="{ \"type\": \"Polygon\", \"coordinates\": [[[7.6574,53.1632],[11 </div> {% block datereange_search %} - <form id="date-search-form" method="get" action="{% url_for controller='package', action='search' %}"> - {{ form.input_raw('ext_startdate', id='ext_startdate', value=request.params['ext_startdate'], - classes=['control-full'],type='date',placeholder=_('from')) - }} - {{ form.input_raw('ext_enddate', id='ext_enddate', value=request.params['ext_enddate'], - classes=['control-full'],type='date',placeholder=_('to')) - }} - <a href="javascript:{}" onclick="$('#date-search-form').submit();" class="action">{{_('submit date search') }}</a> - </form> + {% resource 'odsh/odsh_rangesearch.js' %} + {% set has_range_filter = request.params.get('ext_startdate') or request.params.get('ext_enddate') %} +<section class="module module-narrow module-shallow"> + <nav> + <div class="nav-title">{{_('timerange')}}</div> + <div class="rangesearch-controls"> + <form id="date-search-form" method="get" action="{% url_for controller='package', action='search' %}" data-module="odsh_rangesearch"> + <div class='span1'> + <label id="rangesearch-label" class="rangesearch {% if has_range_filter %} checked {%else%} disabled {% endif %}"></label> + </div> + <div class='span1'> + <div class='controls rangesearch'> + {%- set start = request.params['ext_startdate'] -%} + {%- set end = request.params['ext_enddate'] -%} + {%- set typeStart = 'text' if not start else 'date' -%} + {%- set typeEnd = 'text' if not end else 'date' -%} + {%- set onFocus = 'onfocus=(this.type=\'date\')' -%} + <label for="ext_startdate">{{_('from')|title}}</label> + <input id="ext_startdate" name="ext_startdate" type="{{ typeStart }}" value="{{start}}" placeholder="{{ _('Date') }}" + {{ onFocus }} class='rangesearch' /> + <label for="ext_enddate">{{_('to')|title}}</label> + <input id="ext_enddate" name="ext_enddate" type="{{ typeEnd }}" value="{{end}}" placeholder="{{ _('Date') }}" + {{ onFocus }} class='rangesearch' /> + </div> + </div> + </form> + </div> + </nav> +</section> {% endblock %} </div>