\
\
@@ -135,46 +135,46 @@
* Get popover range template
*/
FilterWidget.prototype.getPopoverRangeTemplate = function () {
- return ' \
-
\
+ return ' \
+
\
'
}
@@ -238,7 +238,7 @@
FilterWidget.prototype.initDatePickers = function (isRange) {
var self = this,
scopeData = this.$activeScope.data('scope-data'),
- $inputs = $('.field-datepicker input', '#controlFilterPopover'),
+ $inputs = $('.field-datepicker input', '#controlFilterPopoverDate'),
data = this.scopeValues[this.activeScopeName]
if (!data) {
@@ -277,7 +277,7 @@
}
FilterWidget.prototype.clearDatePickers = function () {
- var $inputs = $('.field-datepicker input', '#controlFilterPopover')
+ var $inputs = $('.field-datepicker input', '#controlFilterPopoverDate')
$inputs.each(function (index, datepicker) {
var $datepicker = $(datepicker)
@@ -330,7 +330,7 @@
dates = []
if (!isReset) {
- var datepickers = $('.field-datepicker input', '#controlFilterPopover')
+ var datepickers = $('.field-datepicker input', '#controlFilterPopoverDate')
datepickers.each(function (index, datepicker) {
var date = $(datepicker).data('pikaday').toString('YYYY-MM-DD')
diff --git a/modules/system/assets/ui/js/filter.js b/modules/system/assets/ui/js/filter.js
index c875f868f..48de4ead6 100644
--- a/modules/system/assets/ui/js/filter.js
+++ b/modules/system/assets/ui/js/filter.js
@@ -40,41 +40,49 @@
* Get popover template
*/
FilterWidget.prototype.getPopoverTemplate = function() {
- return ' \
-
\
+ return ' \
+
\
'
}
@@ -137,6 +145,16 @@
$(document).on('ajaxDone', '#controlFilterPopover input.filter-search-input', function(event, context, data){
self.filterAvailable(data.scopeName, data.options.available)
})
+
+ $(document).on('click', '#controlFilterPopover [data-trigger="apply"]', function (e) {
+ e.preventDefault()
+ self.filterScope()
+ })
+
+ $(document).on('click', '#controlFilterPopover [data-trigger="clear"]', function (e) {
+ e.preventDefault()
+ self.filterScope(true)
+ })
}
FilterWidget.prototype.focusSearch = function() {
@@ -195,6 +213,7 @@
if (item)
toItems.push(item)
+ this.toggleFilterButtons(items)
this.updateScopeSetting(this.$activeScope, items.active.length)
this.isActiveScopeDirty = true
this.focusSearch()
@@ -210,7 +229,12 @@
data = { loading: true }
isLoaded = false
}
-
+
+ data = $.extend({}, data, {
+ apply_button_text: this.getLang('filter.scopes.apply_button_text', 'Apply'),
+ clear_button_text: this.getLang('filter.scopes.clear_button_text', 'Clear')
+ })
+
data.scopeName = scopeName
data.optionsHandler = self.options.optionsHandler
@@ -224,7 +248,9 @@
closeOnPageClick: true,
placement: 'bottom'
})
-
+
+ this.toggleFilterButtons()
+
// Load options for the first time
if (!isLoaded) {
self.loadOptions(scopeName)
@@ -256,6 +282,7 @@
data: data,
success: function(data) {
self.fillOptions(scopeName, data.options)
+ self.toggleFilterButtons()
}
})
}
@@ -328,6 +355,18 @@
})
}
+ FilterWidget.prototype.toggleFilterButtons = function(data)
+ {
+ var items = $('#controlFilterPopover .filter-active-items > ul'),
+ buttonContainer = $('#controlFilterPopover .filter-buttons')
+
+ if(data) {
+ data.active.length > 0 ? buttonContainer.show() : buttonContainer.hide()
+ } else {
+ items.children().length > 0 ? buttonContainer.show() : buttonContainer.hide()
+ }
+ }
+
/*
* Saves the options to the update handler
*/
@@ -399,6 +438,19 @@
$scope.toggleClass('active', !!switchValue)
}
+ FilterWidget.prototype.filterScope = function (isReset) {
+ var scopeName = this.$activeScope.data('scope-name')
+
+ if (isReset) {
+ this.scopeValues[scopeName] = null
+ this.updateScopeSetting(this.$activeScope, 0)
+ }
+
+ this.pushOptions(scopeName);
+ this.isActiveScopeDirty = true;
+ this.$activeScope.data('oc.popover').hide()
+ }
+
FilterWidget.prototype.getLang = function(name, defaultValue) {
if ($.oc === undefined || $.oc.lang === undefined) {
return defaultValue
@@ -407,7 +459,6 @@
return $.oc.lang.get(name, defaultValue)
}
-
// FILTER WIDGET PLUGIN DEFINITION
// ============================
diff --git a/modules/system/lang/en/client.php b/modules/system/lang/en/client.php
index 173d433ed..fdca0db16 100644
--- a/modules/system/lang/en/client.php
+++ b/modules/system/lang/en/client.php
@@ -63,6 +63,10 @@ return [
'group' => [
'all' => 'all'
],
+ 'scopes' => [
+ 'apply_button_text' => 'Apply',
+ 'clear_button_text' => 'Clear'
+ ],
'dates' => [
'all' => 'all',
'filter_button_text' => 'Filter',