Browse Source

Merge pull request #1 from wenzhixin/develop

merge upstream repository
dimbslmh 6 years ago
parent
commit
dc44eff4a3

+ 2 - 3
CONTRIBUTING.md

@@ -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"
 
 

+ 12 - 3
site/docs/api/table-options.md

@@ -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]`
 
@@ -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`
 
@@ -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`
 
@@ -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`
 

+ 1 - 1
site/docs/extensions/editable.md

@@ -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)
 

+ 4 - 0
site/docs/extensions/filter-control.md

@@ -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).

+ 1 - 2
site/docs/getting-started/introduction.md

@@ -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">

+ 50 - 9
src/bootstrap-table.js

@@ -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
                 }
               }
@@ -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)
           }
         }
@@ -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')
@@ -2077,6 +2114,10 @@
       this.updateSelected()
       this.resetView()
 
+      if (this.options.sidePagination !== 'server') {
+        this.options.totalRows = data.length
+      }
+
       this.trigger('post-body', data)
     }
 

+ 9 - 9
src/extensions/editable/bootstrap-table-editable.js

@@ -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) {
@@ -114,21 +114,21 @@
         $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)
         })
@@ -136,8 +136,8 @@
         $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)
         })

+ 4 - 0
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -826,6 +826,10 @@
           item.value = ''
         })
 
+        $.each(that.options.filterControls, (i, item) => {
+          item.text = ''
+        })
+
         UtilsFilterControl.setValues(that)
 
         // clear cookies once the filters are clean

+ 1 - 1
src/extensions/multiple-sort/bootstrap-table-multiple-sort.js

@@ -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);