|
|
@@ -9,7 +9,12 @@ const UtilsFilterControl = {
|
|
|
getOptionsFromSelectControl (selectControl) {
|
|
|
return selectControl.get(selectControl.length - 1).options
|
|
|
},
|
|
|
+ getSearchControls (scope) {
|
|
|
+ const header = UtilsFilterControl.getCurrentHeader(scope)
|
|
|
+ const searchControls = UtilsFilterControl.getCurrentSearchControls(scope)
|
|
|
|
|
|
+ return header.find(searchControls)
|
|
|
+ },
|
|
|
hideUnusedSelectOptions (selectControl, uniqueValues) {
|
|
|
const options = UtilsFilterControl.getOptionsFromSelectControl(
|
|
|
selectControl
|
|
|
@@ -77,10 +82,10 @@ const UtilsFilterControl = {
|
|
|
// If we get here, the value is valid to add
|
|
|
return false
|
|
|
},
|
|
|
- fixHeaderCSS ({ $tableHeader }) {
|
|
|
+ fixHeaderCSS ({$tableHeader}) {
|
|
|
$tableHeader.css('height', '77px')
|
|
|
},
|
|
|
- getCurrentHeader ({ $header, options, $tableHeader }) {
|
|
|
+ getCurrentHeader ({$header, options, $tableHeader}) {
|
|
|
let header = $header
|
|
|
if (options.height) {
|
|
|
header = $tableHeader
|
|
|
@@ -88,7 +93,7 @@ const UtilsFilterControl = {
|
|
|
|
|
|
return header
|
|
|
},
|
|
|
- getCurrentSearchControls ({ options }) {
|
|
|
+ getCurrentSearchControls ({options}) {
|
|
|
let searchControls = 'select, input'
|
|
|
if (options.height) {
|
|
|
searchControls = 'table select, table input'
|
|
|
@@ -120,12 +125,11 @@ const UtilsFilterControl = {
|
|
|
$(el).val(el.value)
|
|
|
},
|
|
|
copyValues (that) {
|
|
|
- const header = UtilsFilterControl.getCurrentHeader(that)
|
|
|
- const searchControls = UtilsFilterControl.getCurrentSearchControls(that)
|
|
|
+ const searchControls = UtilsFilterControl.getSearchControls(that)
|
|
|
|
|
|
that.options.valuesFilterControl = []
|
|
|
|
|
|
- header.find(searchControls).each(function () {
|
|
|
+ searchControls.each(function () {
|
|
|
that.options.valuesFilterControl.push({
|
|
|
field: $(this)
|
|
|
.closest('[data-field]')
|
|
|
@@ -139,13 +143,12 @@ const UtilsFilterControl = {
|
|
|
setValues (that) {
|
|
|
let field = null
|
|
|
let result = []
|
|
|
- const header = UtilsFilterControl.getCurrentHeader(that)
|
|
|
- const searchControls = UtilsFilterControl.getCurrentSearchControls(that)
|
|
|
+ const searchControls = UtilsFilterControl.getSearchControls(that)
|
|
|
|
|
|
if (that.options.valuesFilterControl.length > 0) {
|
|
|
// Callback to apply after settings fields values
|
|
|
let fieldToFocusCallback = null
|
|
|
- header.find(searchControls).each(function (index, ele) {
|
|
|
+ searchControls.each(function (index, ele) {
|
|
|
field = $(this)
|
|
|
.closest('[data-field]')
|
|
|
.data('field')
|
|
|
@@ -194,12 +197,12 @@ const UtilsFilterControl = {
|
|
|
escapeID (id) {
|
|
|
return String(id).replace(/(:|\.|\[|\]|,)/g, '\\$1')
|
|
|
},
|
|
|
- isColumnSearchableViaSelect ({ filterControl, searchable }) {
|
|
|
+ isColumnSearchableViaSelect ({filterControl, searchable}) {
|
|
|
return filterControl &&
|
|
|
filterControl.toLowerCase() === 'select' &&
|
|
|
searchable
|
|
|
},
|
|
|
- isFilterDataNotGiven ({ filterData }) {
|
|
|
+ isFilterDataNotGiven ({filterData}) {
|
|
|
return filterData === undefined ||
|
|
|
filterData.toLowerCase() === 'column'
|
|
|
},
|
|
|
@@ -446,7 +449,7 @@ const UtilsFilterControl = {
|
|
|
})
|
|
|
|
|
|
if (header.find('.date-filter-control').length > 0) {
|
|
|
- $.each(that.columns, (i, { filterControl, field, filterDatepickerOptions }) => {
|
|
|
+ $.each(that.columns, (i, {filterControl, field, filterDatepickerOptions}) => {
|
|
|
if (
|
|
|
filterControl !== undefined &&
|
|
|
filterControl.toLowerCase() === 'datepicker'
|
|
|
@@ -542,7 +545,7 @@ $.extend($.fn.bootstrapTable.defaults, {
|
|
|
'undefined' === typeof value ? '' : value
|
|
|
)
|
|
|
},
|
|
|
- select ({ options }, field, isVisible) {
|
|
|
+ select ({options}, field, isVisible) {
|
|
|
return Utils.sprintf(
|
|
|
'<select class="form-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s" dir="%s"></select>',
|
|
|
field,
|
|
|
@@ -658,6 +661,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|
|
}
|
|
|
UtilsFilterControl.createControls(this, this.$header)
|
|
|
}
|
|
|
+
|
|
|
initBody () {
|
|
|
super.initBody()
|
|
|
|
|
|
@@ -823,7 +827,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|
|
if (controls.length > 0) {
|
|
|
this.filterColumnsPartial = {}
|
|
|
$(controls[0]).trigger(
|
|
|
- controls[0].tagName === 'INPUT' ? 'keyup' : 'change', { keyCode: 13 }
|
|
|
+ controls[0].tagName === 'INPUT' ? 'keyup' : 'change', {keyCode: 13}
|
|
|
)
|
|
|
} else {
|
|
|
return
|
|
|
@@ -847,7 +851,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|
|
)
|
|
|
)
|
|
|
if (sorter.length > 0) {
|
|
|
- that.onSort({ type: 'keypress', currentTarget: sorter })
|
|
|
+ that.onSort({type: 'keypress', currentTarget: sorter})
|
|
|
$(sorter)
|
|
|
.find('.sortable')
|
|
|
.trigger('click')
|
|
|
@@ -857,10 +861,9 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|
|
}
|
|
|
|
|
|
triggerSearch () {
|
|
|
- const header = UtilsFilterControl.getCurrentHeader(this)
|
|
|
- const searchControls = UtilsFilterControl.getCurrentSearchControls(this)
|
|
|
+ const searchControls = UtilsFilterControl.getSearchControls(this)
|
|
|
|
|
|
- header.find(searchControls).each(function () {
|
|
|
+ searchControls.each(function () {
|
|
|
const el = $(this)
|
|
|
if (el.is('select')) {
|
|
|
el.change()
|
|
|
@@ -875,13 +878,12 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|
|
this.options.disableControlWhenSearch &&
|
|
|
this.options.sidePagination === 'server'
|
|
|
) {
|
|
|
- const header = UtilsFilterControl.getCurrentHeader(this)
|
|
|
- const searchControls = UtilsFilterControl.getCurrentSearchControls(this)
|
|
|
+ const searchControls = UtilsFilterControl.getSearchControls(this)
|
|
|
|
|
|
if (!enable) {
|
|
|
- header.find(searchControls).prop('disabled', 'disabled')
|
|
|
+ searchControls.prop('disabled', 'disabled')
|
|
|
} else {
|
|
|
- header.find(searchControls).removeProp('disabled')
|
|
|
+ searchControls.removeProp('disabled')
|
|
|
}
|
|
|
}
|
|
|
}
|