Skip to content

Commit

Permalink
Extend date range filter directive to configure the date field to use.
Browse files Browse the repository at this point in the history
Currently only was supporting the field 'resourceTemporalDateRange'
  • Loading branch information
josegar74 authored and fxprunayre committed Mar 28, 2023
1 parent 2bc09b6 commit 3fe3000
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Expand Up @@ -263,26 +263,24 @@
"../../catalog/views/default/directives/" + "partials/dateRangeFilter.html",
scope: {
label: "@gnDateRangeFilter",
field: "="
field: "=",
fieldName: "="
},
link: function linkFn(scope, element, attr) {
var today = moment();
scope.relations = ["intersects", "within", "contains"];
scope.relation = scope.relations[0];
scope.field = {
range: {
resourceTemporalDateRange: {
gte: null,
lte: null,
relation: scope.relation
}
}
scope.field.range = scope.field.range || {};
scope.field.range[scope.fieldName] = {
gte: null,
lte: null,
relation: scope.relation
};

scope.setRange = function () {
scope.field.range.resourceTemporalDateRange.gte = scope.dateFrom;
scope.field.range.resourceTemporalDateRange.lte = scope.dateTo;
scope.field.range.resourceTemporalDateRange.relation = scope.relation;
scope.field.range[scope.fieldName].gte = scope.dateFrom;
scope.field.range[scope.fieldName].lte = scope.dateTo;
scope.field.range[scope.fieldName].relation = scope.relation;
};

scope.format = "YYYY-MM-DD";
Expand Down
Expand Up @@ -13,6 +13,7 @@
data-ng-if="searchObj.params.resourceTemporalDateRange"
data-gn-date-range-filter="resourceTemporalDateRange"
data-field="searchObj.params.resourceTemporalDateRange"
data-field-name="'resourceTemporalDateRange'"
class="gn-search-filter-datepicker"
></div>
</div>

0 comments on commit 3fe3000

Please sign in to comment.