소스 검색

Table: add test for selectOnIndeterminate (#10210)

杨奕 7 년 전
부모
커밋
84bb3397cb
7개의 변경된 파일49개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      examples/docs/en-US/menu.md
  2. 1 1
      examples/docs/en-US/table.md
  3. 1 0
      examples/docs/es/menu.md
  4. 1 1
      examples/docs/es/table.md
  5. 1 1
      examples/docs/zh-CN/table.md
  6. 41 0
      test/unit/specs/table.spec.js
  7. 3 0
      types/table.d.ts

+ 1 - 1
examples/docs/en-US/menu.md

@@ -308,7 +308,7 @@ Vertical NavMenu could be collapsed.
 | unique-opened  |  whether only one sub-menu can be active  | boolean   | — | false   |
 | menu-trigger | how sub-menus are triggered, only works when `mode` is 'horizontal' | string    | — | hover |
 | router  | whether `vue-router` mode is activated. If true, index will be used as 'path' to activate the route action | boolean   | — | false   |
-| collapse-transition  | whether the menu collapse transition is active | boolean   | — | true   |
+| collapse-transition  | whether to enable the collapse transition | boolean   | — | true   |
 
 ### Menu Methods
 | Event Name | Description | Parameters |

+ 1 - 1
examples/docs/en-US/table.md

@@ -1975,7 +1975,7 @@ You can customize row index in `type=index` columns.
 | sum-text | displayed text for the first column of summary row | String | — | Sum |
 | summary-method | custom summary method | Function({ columns, data }) | — | — |
 | span-method | method that returns rowspan and colspan | Function({ row, column, rowIndex, columnIndex }) | — | — |
-| select-on-indeterminate | Controls the behavior of master checkbox in multi-select tables when only some rows are selected (but not all). If true, all rows will be selected, else deselected. | Boolean | — | false |
+| select-on-indeterminate | controls the behavior of master checkbox in multi-select tables when only some rows are selected (but not all). If true, all rows will be selected, else deselected. | Boolean | — | true |
 
 ### Table Events
 | Event Name | Description | Parameters |

+ 1 - 0
examples/docs/es/menu.md

@@ -310,6 +310,7 @@ NavMenu vertical puede ser colapsado.
 | unique-opened     | si solo un submenu puede ser activo      | boolean | —                     | false       |
 | menu-trigger      | como dispara eventos sub-menus, solo funciona cuando `mode` es 'horizontal' | string  | —                     | hover       |
 | router            | si el modo `vue-router` está activado. Si es verdader, índice será usado como 'path' para activar la ruta | boolean | —                     | false       |
+| collapse-transition  | whether to enable the collapse transition | boolean   | — | true   |
 
 ### Métodos Menu 
 | Nombre de evento | Descripción                   | Parámetros                             |

+ 1 - 1
examples/docs/es/table.md

@@ -1978,7 +1978,7 @@ Puede personalizar el índice de la fila con la propiedad `type=index` de las co
 | sum-text               | texto a mostrar para la primer columna de la fila de resumen | String                                   | —                              | Sum                                      |
 | summary-method         | método personalizado para resumen        | Function({ columns, data })              | —                              | —                                        |
 | span-method            | método que devuelve _rowspan_ y _colspan_ | Function({ row, column, rowIndex, columnIndex }) | —                              | —                                        |
-| select-on-indeterminate | Controls the behavior of master checkbox in multi-select tables when only some rows are selected (but not all). If true, all rows will be selected, else deselected. | Boolean | — | false |
+| select-on-indeterminate | controls the behavior of master checkbox in multi-select tables when only some rows are selected (but not all). If true, all rows will be selected, else deselected. | Boolean | — | true |
 
 ### Eventos de la tabla
 | Nombre del evento  | Descripción                              | Parámetros                        |

+ 1 - 1
examples/docs/zh-CN/table.md

@@ -2035,7 +2035,7 @@
 | sum-text | 合计行第一列的文本 | String | — | 合计 |
 | summary-method | 自定义的合计计算方法 | Function({ columns, data }) | — | — |
 | span-method | 合并行或列的计算方法 | Function({ row, column, rowIndex, columnIndex }) | — | — |
-| select-on-indeterminate | Controls the behavior of master checkbox in multi-select tables when only some rows are selected (but not all). If true, all rows will be selected, else deselected. | Boolean | — | false |
+| select-on-indeterminate | 在多选表格中,当仅有部分行被选中时,点击表头的多选框时的行为。若为 true,则选中所有行;若为 false,则取消选择所有行 | Boolean | — | true |
 
 ### Table Events
 | 事件名 | 说明 | 参数 |

+ 41 - 0
test/unit/specs/table.spec.js

@@ -234,6 +234,47 @@ describe('Table', () => {
         }, DELAY);
       }, DELAY);
     });
+
+    it('select-on-indeterminate', done => {
+      const vm = createVue({
+        template: `
+          <el-table :data="testData" @selection-change="change" :select-on-indeterminate="false" ref="table">
+            <el-table-column type="selection" />
+            <el-table-column prop="name" label="name" />
+            <el-table-column prop="release" label="release" />
+            <el-table-column prop="director" label="director" />
+            <el-table-column prop="runtime" label="runtime" />
+          </el-table>
+        `,
+
+        created() {
+          this.testData = getTestData();
+        },
+
+        mounted() {
+          this.$refs.table.toggleRowSelection(this.testData[0]);
+        },
+
+        data() {
+          return { selected: [] };
+        },
+
+        methods: {
+          change(val) {
+            this.selected = val;
+          }
+        }
+      }, true);
+
+      setTimeout(_ => {
+        vm.$el.querySelector('.el-checkbox').click();
+        setTimeout(_ => {
+          expect(vm.selected).to.length(0);
+          destroyVM(vm);
+          done();
+        }, DELAY);
+      }, DELAY);
+    });
   });
 
   describe('filter', () => {

+ 3 - 0
types/table.d.ts

@@ -79,6 +79,9 @@ export declare class ElTable extends ElementUIComponent {
   /** Custom summary method */
   summaryMethod: (param: SummaryMethodParams) => any[]
 
+  /** Controls the behavior of master checkbox in multi-select tables when only some rows are selected */
+  selectOnIndeterminate: boolean
+
   /** Clear selection. Might be useful when `reserve-selection` is on */
   clearSelection (): void