Browse Source

Merge branch 'develop' into fix/fix_Issue_4379

djhvscf 6 years ago
parent
commit
d24261febe

+ 3 - 0
.stylelintrc

@@ -0,0 +1,3 @@
+{
+  'extends': 'stylelint-config-standard'
+}

+ 24 - 16
.travis.yml

@@ -1,18 +1,26 @@
-language: ruby
-rvm:
-  - 2.4.1
+stages:
+  - test
+  - deploy
 
-script: bash ./deploy.sh
+jobs:
+  include:
+    - stage: test
+      language: node_js
+      node_js:
+        - 10
+      name: "Lint src and check docs"
+      script: npm run pre-commit
+      if: type = pull_request
 
-branches:
-  only:
-  - master
-
-env:
-  global:
-  - ENCRYPTION_LABEL: "5453d0fdf68a"
-  - COMMIT_AUTHOR_EMAIL: "wenzhixin2010@gmail.com"
-
-sudo: false
-
-cache: bundler
+    - stage: deploy
+      name: "Deploy docs"
+      language: ruby
+      rvm:
+        - 2.4.1
+      script: ./deploy.sh
+      if: branch = master AND type = push
+      env:
+        global:
+        - ENCRYPTION_LABEL: "5453d0fdf68a"
+        - COMMIT_AUTHOR_EMAIL: "wenzhixin2010@gmail.com"
+      cache: bundler

+ 15 - 4
package.json

@@ -24,10 +24,22 @@
     "rollup-plugin-node-resolve": "^4.0.1",
     "rollup-plugin-vue": "^5.0.0",
     "sass": "^1.16.1",
-    "vue-template-compiler": "^2.6.10"
+    "stylelint": "^10.1.0",
+    "stylelint-config-standard": "^18.3.0",
+    "vue-template-compiler": "^2.6.10",
+    "chalk": "^2.4.2",
+    "esm": "^3.2.25",
+    "safe-eval": "^0.4.1"
   },
   "scripts": {
-    "lint": "eslint src",
+    "lint:js": "eslint src",
+    "lint:css": "stylelint src/**/*.scss",
+    "lint": "run-s lint:*",
+    "docs:check:api": "cd tools && node check-api.js",
+    "docs:check:locale": "cd tools && node check-locale.js",
+    "docs:check": "run-s docs:check:*",
+    "docs:serve": "bundle exec jekyll serve",
+    "docs": "bundle exec jekyll build",
     "js:build:base": "rollup -c",
     "js:build:min": "NODE_ENV=production rollup -c",
     "js:build:banner": "find dist -name '*.min.js' -exec headr {} -o {} --version --homepage --author --license \\;",
@@ -39,8 +51,7 @@
     "css:build": "run-s css:build:*",
     "clean": "rm -rf dist",
     "build": "run-s lint clean *:build",
-    "docs": "bundle exec jekyll build",
-    "docs-serve": "bundle exec jekyll serve"
+    "pre-commit": "run-s lint docs:check"
   },
   "peerDependencies": {
     "jquery": "1.9.1 - 3"

+ 2 - 2
site/docs/api/table-options.md

@@ -807,7 +807,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Default:** `false`
 
-- **Example:** [ShowSearchButton](https://examples.bootstrap-table.com/#options/show-search-button.html)
+- **Example:** [Show Search Button](https://examples.bootstrap-table.com/#options/show-search-button.html)
 
 ## showSearchClearButton
 
@@ -821,7 +821,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Default:** `false`
 
-- **Example:** [ShowSearchClearButton](https://examples.bootstrap-table.com/#options/show-search-clear-button.html)
+- **Example:** [Show Search Clear Button](https://examples.bootstrap-table.com/#options/show-search-clear-button.html)
 
 ## trimOnSearch
 

+ 2 - 3
src/bootstrap-table.js

@@ -598,14 +598,13 @@ class BootstrapTable {
     if (o.search) {
       html = []
 
-
       html.push(Utils.sprintf(`
         <div class="${this.constants.classes.pull}-${o.searchAlign} search ${this.constants.classes.inputGroup}">
             %s
         </div>
       `,
       Utils.sprintf(this.constants.html.inputGroup,
-        `<input class="${this.constants.classes.input}${Utils.sprintf(' input-%s', o.iconSize)}" type="text" placeholder="${o.formatSearch()}">`,
+        Utils.sprintf(this.constants.html.searchInput, this.constants.classes.input, Utils.sprintf(' input-%s', o.iconSize), o.formatSearch()),
         (o.showSearchButton ? Utils.sprintf(this.constants.html.searchButton, o.formatSearch(), this.options.iconsPrefix, this.options.icons.search) : '') +
         (o.showSearchClearButton ? Utils.sprintf(this.constants.html.searchClearButton, o.formatClearSearch(), this.options.iconsPrefix, this.options.icons.clearSearch) : ''))
       ))
@@ -1162,7 +1161,7 @@ class BootstrapTable {
       Utils.sprintf(' id="%s"', Array.isArray(item) ? undefined : item._id),
       Utils.sprintf(' class="%s"', style.classes || (Array.isArray(item) ? undefined : item._class)),
       ` data-index="${i}"`,
-      Utils.sprintf(' data-uniqueid="%s"', item[this.options.uniqueId]),
+      Utils.sprintf(' data-uniqueid="%s"', Utils.getItemField(item, this.options.uniqueId, false)),
       Utils.sprintf(' data-has-detail-view="%s"', (!this.options.cardView && this.options.detailView && Utils.calculateObjectValue(null, this.options.detailFilter, [i, item])) ? 'true' : undefined),
       Utils.sprintf('%s', data_),
       '>'

+ 2 - 0
src/constants/index.js

@@ -53,6 +53,7 @@ const CONSTANTS = {
       paginationItem: '<li class="page-item%s"><a class="page-link" href="#">%s</a></li>',
       icon: '<i class="%s %s"></i>',
       inputGroup: '<div class="input-group">%s<span class="input-group-btn">%s</span></div>',
+      searchInput: '<input class="%s%s" type="text" placeholder="%s">',
       searchButton: '<button class="btn btn-default" type="button" name="search" title="%s"><i class="%s %s"></i></button>',
       searchClearButton: '<button class="btn btn-default" type="button" name="clearSearch" title="%s"><i class="%s %s"></i></button>'
     }
@@ -96,6 +97,7 @@ const CONSTANTS = {
       paginationItem: '<li class="page-item%s"><a class="page-link" href="#">%s</a></li>',
       icon: '<i class="%s %s"></i>',
       inputGroup: '<div class="input-group">%s<div class="input-group-append">%s</div></div>',
+      searchInput: '<input class="%s%s" type="text" placeholder="%s">',
       searchButton: '<button class="btn btn-secondary" type="button" name="search" title="%s"><i class="%s %s"></i></button>',
       searchClearButton: '<button class="btn btn-secondary" type="button" name="clearSearch" title="%s"><i class="%s %s"></i></button>'
     }

+ 3 - 2
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -651,10 +651,11 @@ $.BootstrapTable = class extends $.BootstrapTable {
     that.data = fp
       ? that.options.data.filter((item, i) => {
         const itemIsExpected = []
-        Object.keys(item).forEach((key, index) => {
+        Object.keys(item).forEach((x, index) => {
+          const key = that.header.fields[index]
           const thisColumn = that.columns[that.fieldsColumnsIndex[key]]
           const fval = (fp[key] || '').toLowerCase()
-          let value = item[key]
+          let value = Utils.getItemField(item, key, false)
 
           if (fval === '') {
             itemIsExpected.push(true)

+ 5 - 1
src/themes/bulma/bootstrap-table-bulma.js

@@ -30,8 +30,12 @@ $.BootstrapTable = class extends $.BootstrapTable {
     this.constants.html.pageDropdown = ['<div class="dropdown-menu"><div class="dropdown-content">', '</div></div>']
     this.constants.html.pageDropdownItem = '<a class="dropdown-item %s" href="#">%s</a>'
     this.constants.html.dropdownCaret = '<span class="icon is-small"><i class="fas fa-angle-down" aria-hidden="true"></i></span>'
-    this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>'],
+    this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>']
     this.constants.html.paginationItem = '<li><a class="page-item pagination-link%s" href="#">%s</a></li>'
+    this.constants.html.searchInput = '<p class="control"><input class="%s input-%s" type="text" placeholder="%s"></p>'
+    this.constants.html.inputGroup = '<div class="field has-addons has-addons-right">%s%s</div>'
+    this.constants.html.searchButton = '<p class="control"><button class="button" type="button" name="search" title="%s"><i class="%s %s"></i></button></p>'
+    this.constants.html.searchClearButton = '<p class="control"><button class="button" type="button" name="clearSearch" title="%s"><i class="%s %s"></i></button></p>'
   }
 
   initToolbar () {

+ 5 - 1
src/themes/foundation/bootstrap-table-foundation.js

@@ -28,8 +28,12 @@ $.BootstrapTable = class extends $.BootstrapTable {
     this.constants.html.pageDropdown = ['<div class="dropdown-pane" id="pagination-list-id" data-dropdown><ul class="vertical menu">', '</ul></div>']
     this.constants.html.pageDropdownItem = '<li class="dropdown-item %s"><a href="#">%s</a></li>'
     this.constants.html.dropdownCaret = '<i class="fa fa-angle-down"></i>'
-    this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>'],
+    this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>']
     this.constants.html.paginationItem = '<li><a class="page-item%s" href="#">%s</a></li>'
+    this.constants.html.inputGroup = '<div class="input-group">%s <div class="input-group-button">%s</div></div>'
+    this.constants.html.searchInput = '<input class="%s input-%s input-group-field" type="text" placeholder="%s">'
+    this.constants.html.searchButton = '<button class="button" type="button" name="search" title="%s"><i class="%s %s"></i></button>'
+    this.constants.html.searchClearButton = '<button class="button" type="button" name="clearSearch" title="%s"><i class="%s %s"></i></button>'
   }
 
   initToolbar () {

+ 1 - 1
src/themes/materialize/bootstrap-table-materialize.js

@@ -40,7 +40,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
     this.constants.html.pageDropdown = ['<ul id="pagination-list-id" class="dropdown-content">', '</ul>']
     this.constants.html.pageDropdownItem = '<li><a class="%s" href="#">%s</a></li>'
     this.constants.html.dropdownCaret = '<i class="material-icons">arrow_drop_down</i>'
-    this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>'],
+    this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>']
     this.constants.html.paginationItem = '<li class="waves-effect page-item%s"><a href="#">%s</a></li>'
     this.constants.html.icon = '<i class="%s">%s</i>'
   }

+ 4 - 1
src/themes/semantic/bootstrap-table-semantic.js

@@ -26,8 +26,11 @@ $.BootstrapTable = class extends $.BootstrapTable {
     this.constants.html.pageDropdown = ['<div class="menu">', '</div>']
     this.constants.html.pageDropdownItem = '<a class="item %s" href="#">%s</a>'
     this.constants.html.dropdownCaret = '<i class="dropdown icon"></i>'
-    this.constants.html.pagination = ['<div class="ui pagination menu%s">', '</div>'],
+    this.constants.html.pagination = ['<div class="ui pagination menu%s">', '</div>']
     this.constants.html.paginationItem = '<a class="page-item item%s" href="#">%s</a>'
+    this.constants.html.searchButton = '<button class="ui button" type="button" name="search" title="%s"><i class="%s %s"></i></button>'
+    this.constants.html.searchClearButton = '<button class="ui button" type="button" name="clearSearch" title="%s"><i class="%s %s"></i></button>'
+    this.constants.html.inputGroup = '<div class="ui action input">%s%s</div>'
   }
 
   initToolbar () {

+ 110 - 108
src/themes/theme.scss

@@ -1,6 +1,6 @@
 .bootstrap-table {
   .fixed-table-toolbar {
-    &:after {
+    &::after {
       content: "";
       display: block;
       clear: both;
@@ -19,6 +19,10 @@
         display: inline-block;
         margin-left: -1px !important;
 
+        > .btn {
+          border-radius: 0;
+        }
+
         &:first-child > .btn {
           border-top-left-radius: 4px;
           border-bottom-left-radius: 4px;
@@ -28,16 +32,13 @@
           border-top-right-radius: 4px;
           border-bottom-right-radius: 4px;
         }
-
-        > .btn {
-          border-radius: 0;
-        }
       }
 
       .dropdown-menu {
         text-align: left;
         max-height: 300px;
         overflow: auto;
+        -ms-overflow-style: scrollbar;
         z-index: 1001;
       }
 
@@ -53,6 +54,7 @@
     .columns-left {
       margin-right: 5px;
     }
+
     .columns-right {
       margin-left: 5px;
     }
@@ -67,6 +69,92 @@
     position: relative;
     clear: both;
 
+    .table {
+      width: 100%;
+      margin-bottom: 0 !important;
+
+      th,
+      td {
+        vertical-align: middle;
+        box-sizing: border-box;
+      }
+
+      thead th {
+        vertical-align: bottom;
+        padding: 0;
+        margin: 0;
+
+        &:focus {
+          outline: 0 solid transparent;
+        }
+
+        &.detail {
+          width: 30px;
+        }
+
+        .th-inner {
+          padding: 0.75rem;
+          vertical-align: bottom;
+          overflow: hidden;
+          text-overflow: ellipsis;
+          white-space: nowrap;
+        }
+
+        .sortable {
+          cursor: pointer;
+          background-position: right;
+          background-repeat: no-repeat;
+          padding-right: 30px;
+        }
+
+        .both {
+          background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7X QMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC');
+        }
+
+        .asc {
+          background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==');
+        }
+
+        .desc {
+          background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII= ');
+        }
+      }
+
+      tbody tr {
+        &.selected td {
+          background-color: $hover-bg;
+        }
+
+        &.no-records-found {
+          text-align: center;
+        }
+
+        .card-view {
+          display: flex;
+
+          .card-view-title {
+            font-weight: bold;
+            display: inline-block;
+            min-width: 30%;
+            text-align: left !important;
+          }
+        }
+      }
+
+      .bs-checkbox {
+        text-align: center;
+      }
+
+      input[type="radio"],
+      input[type="checkbox"] {
+        margin: 0 auto !important;
+      }
+
+      &.table-sm .th-inner {
+        padding: 0.3rem;
+      }
+    }
+
     &.fixed-height {
       &:not(.has-footer) {
         border-bottom: 1px solid $border-color;
@@ -131,8 +219,8 @@
           }
 
           .animation-dot,
-          .animation-wrap:after,
-          .animation-wrap:before {
+          .animation-wrap::after,
+          .animation-wrap::before {
             content: "";
             animation-duration: 1.5s;
             animation-iteration-count: infinite;
@@ -147,11 +235,11 @@
           }
 
           .animation-dot {
-            animation-delay: .3s;
+            animation-delay: 0.3s;
           }
 
-          .animation-wrap:after{
-            animation-delay:.6s;
+          .animation-wrap::after {
+            animation-delay: 0.6s;
           }
         }
 
@@ -159,107 +247,21 @@
           background: $color;
 
           .animation-dot,
-          .animation-wrap:after,
-          .animation-wrap:before {
+          .animation-wrap::after,
+          .animation-wrap::before {
             background: $background;
           }
         }
       }
     }
 
-    .table {
-      width: 100%;
-      margin-bottom: 0 !important;
-
-      th,
-      td {
-        vertical-align: middle;
-        box-sizing: border-box;
-      }
-
-      thead th {
-        vertical-align: bottom;
-        padding: 0;
-        margin: 0;
-
-        &:focus {
-          outline: 0 solid transparent;
-        }
-
-        &.detail {
-          width: 30px;
-        }
-
-        .th-inner {
-          padding: .75rem;
-          vertical-align: bottom;
-          overflow: hidden;
-          text-overflow: ellipsis;
-          white-space: nowrap;
-        }
-
-        .sortable {
-          cursor: pointer;
-          background-position: right;
-          background-repeat: no-repeat;
-          padding-right: 30px;
-        }
-
-        .both {
-          background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7X QMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC');
-        }
-
-        .asc {
-          background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==');
-        }
-
-        .desc {
-          background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII= ');
-        }
-      }
-
-      tbody tr {
-        &.selected td {
-          background-color: $hover-bg;
-        }
-
-        &.no-records-found {
-          text-align: center;
-        }
-
-        .card-view {
-          display: flex;
-
-          .card-view-title {
-            font-weight: bold;
-            display: inline-block;
-            min-width: 30%;
-            text-align: left !important;
-          }
-        }
-      }
-
-      .bs-checkbox {
-        text-align: center;
-      }
-
-      input[type="radio"],
-      input[type="checkbox"] {
-        margin: 0 auto !important;
-      }
-
-      &.table-sm .th-inner {
-        padding: .3rem;
-      }
-    }
-
     .fixed-table-footer {
       overflow: hidden;
     }
   }
 
   .fixed-table-pagination {
-    &:after {
+    &::after {
       content: "";
       display: block;
       clear: both;
@@ -303,15 +305,15 @@
 
         li.page-intermediate {
           a {
-            &:before {
+            &::before {
               content: '\2B05';
             }
 
-            &:after {
+            &::after {
               content: '\27A1';
             }
 
-            color:#c8c8c8;
+            color: #c8c8c8;
           }
         }
 
@@ -328,8 +330,8 @@
     top: 0;
     left: 0;
     z-index: 1050;
-    width: 100%!important;
-    background: #FFF;
+    width: 100% !important;
+    background: #fff;
   }
 }
 
@@ -348,8 +350,8 @@ div.fixed-table-scroll-outer {
   overflow: hidden;
 }
 
-@keyframes LOADING{
-  0% { opacity:0; }
-  50% { opacity:1; }
-  to { opacity:0; }
+@keyframes LOADING {
+  0% { opacity: 0; }
+  50% { opacity: 1; }
+  to { opacity: 0; }
 }

+ 21 - 5
tools/check-api.js

@@ -3,6 +3,7 @@ require = require('esm')(module)
 const fs = require('fs')
 const chalk = require('chalk')
 const Constants = require('../src/constants/index.js').default
+let errorSum = 0
 
 class API {
   constructor () {
@@ -16,10 +17,7 @@ class API {
     const content = fs.readFileSync(file).toString()
     const lines = content.split('## ')
     const outLines = lines.slice(0, 1)
-
-    console.log('-------------------------')
-    console.log(`Checking file: ${file}`)
-    console.log('-------------------------')
+    const errors = []
 
     for (const item of lines.slice(1)) {
       md[item.split('\n')[0]] = item
@@ -37,7 +35,7 @@ class API {
             continue
           }
           if (!details[i + 1] || details[i + 1].indexOf(`**${name}:**`) === -1) {
-            console.log(chalk.red(`[${key}] missing '${name}'`))
+            errors.push(chalk.red(`[${key}] missing '${name}'`))
           }
         }
       } else {
@@ -45,6 +43,17 @@ class API {
       }
     }
 
+    errorSum += errors.length
+    if (errors.length > 0) {
+      console.log('-------------------------')
+      console.log(`Checking file: ${file}`)
+      console.log('-------------------------')
+
+      errors.forEach((error) => {
+        console.log(error)
+      })
+    }
+
     fs.writeFile(file, outLines.join('## '), () => {})
   }
 }
@@ -104,3 +113,10 @@ new ColumnOptions()
 new Methods()
 new Events()
 new Localizations()
+
+if (errorSum === 0) {
+  console.log('Good job! Anything up to date!')
+  process.exit(0)
+}
+
+process.exit(1)

+ 2 - 2
tools/check-locale.js

@@ -33,8 +33,6 @@ fs.readdir(`${DIR}`, (err, files) => {
       continue
     }
 
-
-
     const text = fs.readFileSync(DIR + file).toString()
     const obj = readString(readObj(text), text)
     const keys = Object.keys(obj)
@@ -64,6 +62,8 @@ fs.readdir(`${DIR}`, (err, files) => {
 
   if (errorSum === 0) {
     console.log('Good job! Anything up to date!')
+    process.exit(0)
   }
 
+  process.exit(1)
 })

+ 0 - 15
tools/package.json

@@ -1,15 +0,0 @@
-{
-  "name": "tools",
-  "version": "1.0.0",
-  "main": "index.js",
-  "license": "MIT",
-  "dependencies": {
-    "chalk": "^2.4.2",
-    "esm": "^3.2.25",
-    "safe-eval": "^0.4.1"
-  },
-  "scripts": {
-    "check-api": "node check-api",
-    "check-locale": "node check-locale"
-  }
-}