Skip to content

Commit

Permalink
Merge pull request #1 from wenzhixin/develop
Browse files Browse the repository at this point in the history
merge upstream repository
  • Loading branch information
dimbslmh committed Mar 23, 2019
2 parents 3425882 + d3d7986 commit dc44eff
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 28 deletions.
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,8 @@ includes code changes) and under the terms of the
## Code guidelines

- Readability
- Need semicolons
- 4 spaces (no tabs)
- strict mode
- [no semicolons](https://github.com/wenzhixin/bootstrap-table/pull/4218#issuecomment-475822706)
- 2 spaces (no tabs)
- "Attractive"


Expand Down
15 changes: 12 additions & 3 deletions site/docs/api/table-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.

- **Detail:**

When set pagination property, initialize the page size selecting list. If you include the `'All'` or `'Unlimited'` option, all the records will be shown in your table.
When set pagination property, initialize the page size selecting list. If you include the `'all'` or `'unlimited'` option, all the records will be shown in your table.

- **Default:** `[10, 25, 50, 100]`

Expand Down Expand Up @@ -705,6 +705,14 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
- **Detail:**

Enable the search input.

There are 3 ways to search:
- The value contains the search query (Default).
Example: Github contains git.
- The value must be identical to the search query.
Example: Github (value) and Github (search query).
- Comparsions (<, >, <=, =<, >=, =>)
Example: 4 is larger than 3.

- **Default:** `false`

Expand Down Expand Up @@ -732,7 +740,8 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.

- **Detail:**

Enable the strict search.
Enable the strict search.
Disables the comparison checks.

- **Default:** `false`

Expand Down Expand Up @@ -996,7 +1005,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.

- **Detail:**

Indicate which field is an identity field.
Indicate which field will be used as checkbox/radiobox value, its the counterpart to [selectItemName](https://bootstrap-table.com/docs/api/table-options/#selectitemname).

- **Default:** `undefined`

Expand Down
2 changes: 1 addition & 1 deletion site/docs/extensions/editable.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Fired when all columns was initialized by `$().editable()` method.

Fired when an editable cell is saved.

parameters: field, row, oldValue, $el
parameters: field, row, rowIndex, oldValue, $el

### onEditableShown(editable-shown.bs.table)

Expand Down
4 changes: 4 additions & 0 deletions site/docs/extensions/filter-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,7 @@ Dependence if you use the datepicker option: [bootstrap-datepicker](https://gith
### triggerSearch

* Trigger manually the search action

### clearFilterControl

* Clear all the controls added by this plugin (similar to filterShowClear option).
3 changes: 1 addition & 2 deletions site/docs/getting-started/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ Put it all together and your pages should look like this:
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Hello, Bootstrap Table!</title>

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@{{ site.current_version }}/dist/bootstrap-table.min.css">

<title>Hello, Bootstrap Table!</title>
</head>
<body>
<table data-toggle="table">
Expand Down
59 changes: 50 additions & 9 deletions src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,43 @@
return true
}
} else {
if ((`${value}`).toLowerCase().includes(s)) {
const largerSmallerEqualsRegex = /(?:(<=|=>|=<|>=|>|<)(?:\s+)?(\d+)?|(\d+)?(\s+)?(<=|=>|=<|>=|>|<))/gm
const matches = largerSmallerEqualsRegex.exec(s)
let comparisonCheck = false

if (matches) {
const operator = matches[1] || matches[5] + 'l'
const comparisonValue = matches[2] || matches[3]
const int = parseInt(value, 10)
const comparisonInt = parseInt(comparisonValue, 10)

switch (operator) {
case '>':
case '<l':
comparisonCheck = int > comparisonInt
break
case '<':
case '>l':
comparisonCheck = int < comparisonInt
break
case '<=':
case '=<':
case '>=l':
case '=>l':
comparisonCheck = int <= comparisonInt
break
case '>=':
case '=>':
case '<=l':
case '=<l':
comparisonCheck = int >= comparisonInt
break
default:
break
}
}

if (comparisonCheck || (`${value}`).toLowerCase().includes(s)) {
return true
}
}
Expand Down Expand Up @@ -1495,8 +1531,8 @@
pageList = []
for (const value of list) {
pageList.push(
(value.toUpperCase() === o.formatAllRows().toUpperCase() ||
value.toUpperCase() === 'UNLIMITED')
(value.toLowerCase() === o.formatAllRows().toLowerCase() ||
['all', 'unlimited'].includes(value.toLowerCase()))
? o.formatAllRows() : +value)
}
}
Expand Down Expand Up @@ -1625,18 +1661,19 @@
$next = this.$pagination.find('.page-next')
$number = this.$pagination.find('.page-item').not('.page-next, .page-pre')

if (this.totalPages <= 1) {
this.$pagination.find('div.pagination').hide()
}

if (o.smartDisplay) {
if (this.totalPages <= 1) {
this.$pagination.find('div.pagination').hide()
}
if (pageList.length < 2 || o.totalRows <= pageList[0]) {
this.$pagination.find('span.page-list').hide()
}

// when data is empty, hide the pagination
this.$pagination[this.getData().length ? 'show' : 'hide']()
}

// when data is empty, hide the pagination
this.$pagination[this.getData().length ? 'show' : 'hide']()

if (!o.paginationLoop) {
if (o.pageNumber === 1) {
$pre.addClass('disabled')
Expand Down Expand Up @@ -2077,6 +2114,10 @@
this.updateSelected()
this.resetView()

if (this.options.sidePagination !== 'server') {
this.options.totalRows = data.length
}

this.trigger('post-body', data)
}

Expand Down
18 changes: 9 additions & 9 deletions src/extensions/editable/bootstrap-table-editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
onEditableInit () {
return false
},
onEditableSave (field, row, oldValue, $el) {
onEditableSave (field, row, rowIndex, oldValue, $el) {
return false
},
onEditableShown (field, row, $el, editable) {
Expand Down Expand Up @@ -114,30 +114,30 @@
$field.off('save').on('save', ({currentTarget}, {submitValue}) => {
const $this = $(currentTarget)
const data = this.getData()
const index = $this.parents('tr[data-index]').data('index')
const row = data[index]
const rowIndex = $this.parents('tr[data-index]').data('index')
const row = data[rowIndex]
const oldValue = row[column.field]

$this.data('value', submitValue)
row[column.field] = submitValue
this.trigger('editable-save', column.field, row, oldValue, $this)
this.resetFooter()
this.trigger('editable-save', column.field, row, rowIndex, oldValue, $this)
this.initBody()
})

$field.off('shown').on('shown', ({currentTarget}, editable) => {
const $this = $(currentTarget)
const data = this.getData()
const index = $this.parents('tr[data-index]').data('index')
const row = data[index]
const rowIndex = $this.parents('tr[data-index]').data('index')
const row = data[rowIndex]

this.trigger('editable-shown', column.field, row, $this, editable)
})

$field.off('hidden').on('hidden', ({currentTarget}, reason) => {
const $this = $(currentTarget)
const data = this.getData()
const index = $this.parents('tr[data-index]').data('index')
const row = data[index]
const rowIndex = $this.parents('tr[data-index]').data('index')
const row = data[rowIndex]

this.trigger('editable-hidden', column.field, row, $this, reason)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,10 @@
item.value = ''
})

$.each(that.options.filterControls, (i, item) => {
item.text = ''
})

UtilsFilterControl.setValues(that)

// clear cookies once the filters are clean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
var t = that.options.queryParams;
that.options.queryParams = function(params) {
params.multiSort = that.options.sortPriority;
return t(params);
return $.fn.bootstrapTable.utils.calculateObjectValue(that.options, t, [params]);
};
isSingleSort=false;
that.initServer(that.options.silentSort);
Expand Down

0 comments on commit dc44eff

Please sign in to comment.