浏览代码

Merge branch 'develop' into dependabot/npm_and_yarn/eslint-8.0.1

文翼 4 年之前
父节点
当前提交
8d205553eb

+ 3 - 4
src/bootstrap-table.js

@@ -1910,9 +1910,8 @@ class BootstrapTable {
       if (this.options.pagination && this.options.sidePagination === 'server') {
         params.offset = this.options.pageSize === this.options.formatAllRows() ?
           0 : this.options.pageSize * (this.options.pageNumber - 1)
-        params.limit = this.options.pageSize === this.options.formatAllRows() ?
-          this.options.totalRows : this.options.pageSize
-        if (params.limit === 0) {
+        params.limit = this.options.pageSize
+        if (params.limit === 0 || this.options.pageSize === this.options.formatAllRows()) {
           delete params.limit
         }
       }
@@ -2569,7 +2568,7 @@ class BootstrapTable {
         id = id.toString()
       } else if (typeof rowUniqueId === 'number') {
         if ((Number(rowUniqueId) === rowUniqueId) && (rowUniqueId % 1 === 0)) {
-          id = parseInt(id)
+          id = parseInt(id, 10)
         } else if ((rowUniqueId === Number(rowUniqueId)) && (rowUniqueId !== 0)) {
           id = parseFloat(id)
         }

+ 46 - 49
src/extensions/export/bootstrap-table-export.js

@@ -92,30 +92,51 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
       this.buttons = Object.assign(this.buttons, {
         export: {
-          html: exportTypes.length === 1 ? `
-            <div class="export ${this.constants.classes.buttonsDropdown}"
-            data-type="${exportTypes[0]}">
-            <button class="${this.constants.buttonsClass}"
-            aria-label="Export"
-            type="button"
-            title="${o.formatExport()}">
-            ${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''}
-            ${o.showButtonText ? o.formatExport() : ''}
-            </button>
-            </div>
-          ` : `
-            <div class="export ${this.constants.classes.buttonsDropdown}">
-            <button class="${this.constants.buttonsClass} dropdown-toggle"
-            aria-label="Export"
-            ${this.constants.dataToggle}="dropdown"
-            type="button"
-            title="${o.formatExport()}">
-            ${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''}
-            ${o.showButtonText ? o.formatExport() : ''}
-            ${this.constants.html.dropdownCaret}
-            </button>
-            </div>
-          `
+          html:
+            (() => {
+              if (exportTypes.length === 1) {
+                return `
+                  <div class="export ${this.constants.classes.buttonsDropdown}"
+                  data-type="${exportTypes[0]}">
+                  <button class="${this.constants.buttonsClass}"
+                  aria-label="Export"
+                  type="button"
+                  title="${o.formatExport()}">
+                  ${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''}
+                  ${o.showButtonText ? o.formatExport() : ''}
+                  </button>
+                  </div>
+                `
+              }
+
+              const html = []
+
+              html.push(`
+                <div class="export ${this.constants.classes.buttonsDropdown}">
+                <button class="${this.constants.buttonsClass} dropdown-toggle"
+                aria-label="Export"
+                ${this.constants.dataToggle}="dropdown"
+                type="button"
+                title="${o.formatExport()}">
+                ${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''}
+                ${o.showButtonText ? o.formatExport() : ''}
+                ${this.constants.html.dropdownCaret}
+                </button>
+                ${this.constants.html.toolbarDropdown[0]}
+              `)
+
+              for (const type of exportTypes) {
+                if (TYPE_NAME.hasOwnProperty(type)) {
+                  const $item = $(Utils.sprintf(this.constants.html.pageDropdownItem, '', TYPE_NAME[type]))
+
+                  $item.attr('data-type', type)
+                  html.push($item.prop('outerHTML'))
+                }
+              }
+
+              html.push(this.constants.html.toolbarDropdown[1], '</div>')
+              return html.join('')
+            })
         }
       })
     }
@@ -127,32 +148,8 @@ $.BootstrapTable = class extends $.BootstrapTable {
       return
     }
 
-    let $menu = $(this.constants.html.toolbarDropdown.join(''))
-    let $items = this.$export
-
-    if (exportTypes.length > 1) {
-      this.$export.append($menu)
-
-      // themes support
-      if ($menu.children().length) {
-        $menu = $menu.children().eq(0)
-      }
-      for (const type of exportTypes) {
-        if (TYPE_NAME.hasOwnProperty(type)) {
-          const $item = $(Utils.sprintf(this.constants.html.pageDropdownItem,
-            '', TYPE_NAME[type]))
-
-          $item.attr('data-type', type)
-          $menu.append($item)
-        }
-      }
-
-      $items = $menu.children()
-    }
-
     this.updateExportButton()
-
-    $items.click(e => {
+    this.$export.find('[data-type]').click(e => {
       e.preventDefault()
 
       const type = $(e.currentTarget).data('type')

+ 1 - 1
src/extensions/pipeline/bootstrap-table-pipeline.js

@@ -105,7 +105,7 @@ BootstrapTable.prototype.onSort = function () {
 BootstrapTable.prototype.onPageListChange = function (event) {
   /* rebuild cache window on page size change */
   const target = $(event.currentTarget)
-  const newPageSize = parseInt(target.text())
+  const newPageSize = parseInt(target.text(), 10)
 
   this.options.pipelineSize = this.calculatePipelineSize(this.options.pipelineSize, newPageSize)
   this.resetCache = true

+ 4 - 2
src/extensions/treegrid/bootstrap-table-treegrid.js

@@ -75,9 +75,11 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
   initRow (item, idx, data, parentDom) {
     if (this.treeEnable) {
+      const parentId = parseInt(item[this.options.parentIdField], 10)
+
       if (
-        this.options.rootParentId === item[this.options.parentIdField] ||
-        !item[this.options.parentIdField]
+        this.options.rootParentId === parentId ||
+        !parentId
       ) {
         if (item._level === undefined) {
           item._level = 0

+ 18 - 17
src/locale/bootstrap-table-es-MX.js

@@ -3,36 +3,37 @@
  * Author: Felix Vera (felix.vera@gmail.com)
  * Copiado: Mauricio Vera (mauricioa.vera@gmail.com)
  * Revisión: J Manuel Corona (jmcg92@gmail.com) (13/Feb/2018).
+ * Revisión: Ricardo González (rickygzz85@gmail.com) (20/Oct/2021)
  */
 
 $.fn.bootstrapTable.locales['es-MX'] = {
   formatCopyRows () {
-    return 'Copy Rows'
+    return 'Copiar Filas'
   },
   formatPrint () {
-    return 'Print'
+    return 'Imprimir'
   },
   formatLoadingMessage () {
     return 'Cargando, espere por favor'
   },
   formatRecordsPerPage (pageNumber) {
-    return `${pageNumber} registros por página`
+    return `${pageNumber} resultados por página`
   },
   formatShowingRows (pageFrom, pageTo, totalRows, totalNotFiltered) {
     if (totalNotFiltered !== undefined && totalNotFiltered > 0 && totalNotFiltered > totalRows) {
-      return `Mostrando ${pageFrom} a ${pageTo} de ${totalRows} filas (filtered from ${totalNotFiltered} total rows)`
+      return `Mostrando ${pageFrom} a ${pageTo} de ${totalRows} filas (filtrado de ${totalNotFiltered} filas totales)`
     }
 
     return `Mostrando ${pageFrom} a ${pageTo} de ${totalRows} filas`
   },
   formatSRPaginationPreText () {
-    return 'previous page'
+    return 'página anterior'
   },
   formatSRPaginationPageText (page) {
-    return `to page ${page}`
+    return `ir a la página ${page}`
   },
   formatSRPaginationNextText () {
-    return 'next page'
+    return 'página siguiente'
   },
   formatDetailPagination (totalRows) {
     return `Mostrando ${totalRows} filas`
@@ -50,10 +51,10 @@ $.fn.bootstrapTable.locales['es-MX'] = {
     return 'Mostrar/ocultar paginación'
   },
   formatPaginationSwitchDown () {
-    return 'Show pagination'
+    return 'Mostrar paginación'
   },
   formatPaginationSwitchUp () {
-    return 'Hide pagination'
+    return 'Ocultar paginación'
   },
   formatRefresh () {
     return 'Actualizar'
@@ -62,16 +63,16 @@ $.fn.bootstrapTable.locales['es-MX'] = {
     return 'Cambiar vista'
   },
   formatToggleOn () {
-    return 'Show card view'
+    return 'Mostrar vista'
   },
   formatToggleOff () {
-    return 'Hide card view'
+    return 'Ocultar vista'
   },
   formatColumns () {
     return 'Columnas'
   },
   formatColumnsToggleAll () {
-    return 'Toggle all'
+    return 'Alternar todo'
   },
   formatFullscreen () {
     return 'Pantalla completa'
@@ -80,19 +81,19 @@ $.fn.bootstrapTable.locales['es-MX'] = {
     return 'Todo'
   },
   formatAutoRefresh () {
-    return 'Auto Refresh'
+    return 'Auto actualizar'
   },
   formatExport () {
-    return 'Export data'
+    return 'Exportar datos'
   },
   formatJumpTo () {
-    return 'GO'
+    return 'IR'
   },
   formatAdvancedSearch () {
-    return 'Advanced search'
+    return 'Búsqueda avanzada'
   },
   formatAdvancedCloseButton () {
-    return 'Close'
+    return 'Cerrar'
   },
   formatFilterControlSwitch () {
     return 'Ocultar/Mostrar controles'