From 52208fbf359b40e211dead74aba08cb2a8c0aba5 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 24 Nov 2017 12:21:05 -0400 Subject: [PATCH 1/8] feat(table): add toggelDetails method to scoped item slots --- src/components/table/table.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/table/table.vue b/src/components/table/table.vue index b2a5c8f3b6f..d5eb992995c 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -18,7 +18,6 @@ } table.b-table>tbody>tr.b-table-details>td { border-top: none; - padding-top: 0; } /* Sort styling */ @@ -233,6 +232,11 @@ // Add the body rows items.forEach((item, index) => { const detailsSlot = $scoped['row-details'] + const toggleDetailsFn = () => { + if (detailsSlot) { + t.$set(item, '_showDetails', !Boolean(item._showDetails)) + } + } // For Each Row const tds = fields.map((field) => { // Foe Each field in the row @@ -248,7 +252,9 @@ item: item, index: index, unformatted: item[field.key], - value: t.getFormattedValue(item, field) + value: t.getFormattedValue(item, field), + toggleDetails: toggleDetailsFn, + detailsShowing: item._showDetails }) ] } else { From 1956deaa0e6bcda3ca6573ffa288760fe9b87c43 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 24 Nov 2017 12:28:53 -0400 Subject: [PATCH 2/8] add toggleDetails to details scoped var --- src/components/table/table.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/table/table.vue b/src/components/table/table.vue index d5eb992995c..af0b4a9e64b 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -254,7 +254,7 @@ unformatted: item[field.key], value: t.getFormattedValue(item, field), toggleDetails: toggleDetailsFn, - detailsShowing: item._showDetails + detailsShowing: Boolean(item._showDetails) }) ] } else { @@ -281,7 +281,7 @@ const details = h( 'td', { attrs: { colspan: String(fields.length) } }, - [ detailsSlot({ item: item, index: index, fields: fields }) ] + [ detailsSlot({ item: item, index: index, fields: fields, toggleDetails: toggleDetailsFn }) ] ) rows.push(h( 'tr', From d95ce26f596288fc5158d57be5ad0050f6524cc8 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 24 Nov 2017 13:58:23 -0400 Subject: [PATCH 3/8] documentation update --- src/components/table/README.md | 105 +++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 44 deletions(-) diff --git a/src/components/table/README.md b/src/components/table/README.md index 0adf3ee7b9f..8e2c44aa0a5 100755 --- a/src/components/table/README.md +++ b/src/components/table/README.md @@ -621,8 +621,10 @@ The slot's scope variable (`data` in the above sample) will have the following p | -------- | ---- | ----------- | `index` | Number | The row number (indexed from zero) relative to the displayed rows | `item` | Object | The entire raw record data (i.e. `items[index]`) for this row (before any formatter is applied) -| `value` | Any | The value for this key in the record (`null` or `undefined` if a virtual column), or the output of thr field's `formatter` function (see below for for information on field `formatter` callback functions) +| `value` | Any | The value for this key in the record (`null` or `undefined` if a virtual column), or the output of the field's `formatter` function (see below for for information on field `formatter` callback functions) | `unformatted` | Any | The raw value for this key in the item record (`null` or `undefined` if a virtual column), before being passed to the field's `formtter` function +| detailsShowing | Boolean | Will be `true` if the row's `row-details` scoped slot is visible. See section [Row details support](#row-details-support) below for additional information +| toggleDetails | Function | Can be called to toggle the visibility of the rows `row-details` scoped slot. See section [Row details support](#row-details-support) below for additional information **Notes:** @@ -631,9 +633,9 @@ computed after pagination and filtering have been applied to the original table data. The `index` value will refer to the **displayed row number**. This number will align with the indexes from the optional `v-model` bound variable.* - When placing inputs, buttons, selects or links within a data cell scoped slot, -be sure to add a `@click.stop` handler (which can be empty) to prevent the -click on the input, button, select, or link, from triggering the `row-clicked` -event: +be sure to add a `@click.stop` (or `@click.native.stop` if needed) handler (which can +be empty) to prevent the click on the input, button, select, or link, from triggering +the `row-clicked` event: ```html