From 84bb3397cbc602b3ebb2a32a6ac223911d4f26c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=A5=95?= Date: Fri, 16 Mar 2018 21:42:11 +0800 Subject: [PATCH] Table: add test for selectOnIndeterminate (#10210) --- examples/docs/en-US/menu.md | 2 +- examples/docs/en-US/table.md | 2 +- examples/docs/es/menu.md | 1 + examples/docs/es/table.md | 2 +- examples/docs/zh-CN/table.md | 2 +- test/unit/specs/table.spec.js | 41 +++++++++++++++++++++++++++++++++++ types/table.d.ts | 3 +++ 7 files changed, 49 insertions(+), 4 deletions(-) diff --git a/examples/docs/en-US/menu.md b/examples/docs/en-US/menu.md index 5c9bb2164..a2d27f7fb 100644 --- a/examples/docs/en-US/menu.md +++ b/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 | diff --git a/examples/docs/en-US/table.md b/examples/docs/en-US/table.md index e07d5faa8..085ccd31a 100644 --- a/examples/docs/en-US/table.md +++ b/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 | diff --git a/examples/docs/es/menu.md b/examples/docs/es/menu.md index d6c63e2ed..a3765bca3 100644 --- a/examples/docs/es/menu.md +++ b/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 | diff --git a/examples/docs/es/table.md b/examples/docs/es/table.md index 7ac6ada64..7096f70a4 100644 --- a/examples/docs/es/table.md +++ b/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 | diff --git a/examples/docs/zh-CN/table.md b/examples/docs/zh-CN/table.md index 8edc15b92..90fe87542 100644 --- a/examples/docs/zh-CN/table.md +++ b/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 | 事件名 | 说明 | 参数 | diff --git a/test/unit/specs/table.spec.js b/test/unit/specs/table.spec.js index 29cc5b53a..936eb757c 100644 --- a/test/unit/specs/table.spec.js +++ b/test/unit/specs/table.spec.js @@ -234,6 +234,47 @@ describe('Table', () => { }, DELAY); }, DELAY); }); + + it('select-on-indeterminate', done => { + const vm = createVue({ + template: ` + + + + + + + + `, + + 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', () => { diff --git a/types/table.d.ts b/types/table.d.ts index 0f230e371..e668dbd10 100644 --- a/types/table.d.ts +++ b/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