From 5485b6490443a740e59353b825aa36176d6a07df Mon Sep 17 00:00:00 2001 From: maxime Date: Sat, 16 Apr 2022 16:56:48 +0100 Subject: [PATCH] fix: remove columns property from DEFAULT_OPTIONS if provided --- .../filterable-table/FilterableTable.vue | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/filterable-table/FilterableTable.vue b/src/components/filterable-table/FilterableTable.vue index da77113..bef2b97 100644 --- a/src/components/filterable-table/FilterableTable.vue +++ b/src/components/filterable-table/FilterableTable.vue @@ -60,7 +60,7 @@ import { createNamespacedHelpers } from 'vuex' import { DEFAULT_OPTIONS, DUMMY_DATA } from './constants.js' import { setAxiosHeaders } from '../../helpers/helpers-axios.js' - +import { merge } from 'lodash' import TableHead from './TableHead.vue' import TableFilters from './TableFilters.vue' import TableModal from './TableModal.vue' @@ -242,14 +242,16 @@ export default { importUserOptions () { const providedOptions = typeof(this.options) == 'object' ? this.options : {} + const defaultOptionsWithoutColumns = JSON.parse(JSON.stringify(DEFAULT_OPTIONS)); + delete defaultOptionsWithoutColumns.columns // remove default columns widths which was messing the vertical alignment + + const defaultOptionsToMerge = Object.prototype.hasOwnProperty.call(providedOptions, 'columns') ? defaultOptionsWithoutColumns : DEFAULT_OPTIONS + + const options = { ...merge(providedOptions, defaultOptionsToMerge) } const obj = { tableId: this.id, - options: { - ...DEFAULT_OPTIONS, - ...providedOptions - } + options } - this.updateOptions(obj) },