From b83f0fb52fd2d1bf6a41dd231a48c16f8d1ece35 Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 12 Nov 2021 17:51:27 +0100 Subject: [PATCH] fix(smart-table): load default viewConfig --- .../10380-allsaints/00-defaultViewConfig.sql | 5 ++- front/core/components/smart-table/index.js | 43 +++++++++++++------ front/core/components/smart-table/table.scss | 2 +- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/db/changes/10380-allsaints/00-defaultViewConfig.sql b/db/changes/10380-allsaints/00-defaultViewConfig.sql index 6530fe2268..e4b2f6c3d6 100644 --- a/db/changes/10380-allsaints/00-defaultViewConfig.sql +++ b/db/changes/10380-allsaints/00-defaultViewConfig.sql @@ -7,7 +7,8 @@ comment 'The default configuration of columns for views'; INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns) VALUES - ('itemsIndex', '{"intrastat":false,"stemMultiplier":false}'), - ('latestBuys', '{"intrastat":false,"description":false,"density":false,"isActive":false,"freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":true,"ektFk":false,"weight":false,"id":true,"packing":true,"grouping":true,"quantity":true,"size":false,"name":true,"code":true,"origin":true,"family":true,"entryFk":true,"buyingValue":true,"comissionValue":false,"price3":true,"packageFk":true,"packingOut":true}'); + ('itemsIndex', '{"intrastat":false,"stemMultiplier":false,"landed":false}'), + ('latestBuys', '{"intrastat":false,"description":false,"density":false,"isActive":false,"freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":true,"ektFk":false,"weight":false,"id":true,"packing":true,"grouping":true,"quantity":true,"size":false,"name":true,"code":true,"origin":true,"family":true,"entryFk":true,"buyingValue":true,"comissionValue":false,"price3":true,"packageFk":true,"packingOut":true}'), + ('ticketsMonitor', '{"id":false}'); \ No newline at end of file diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 0365520868..8193791345 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -55,7 +55,7 @@ export default class SmartTable extends Component { set viewConfigId(value) { this._viewConfigId = value; - if (value) { + /* if (value) { this.defaultViewConfig = {}; const url = 'DefaultViewConfigs'; @@ -67,7 +67,18 @@ export default class SmartTable extends Component { this.defaultViewConfig = columns; } }); - } + } */ + } + + getDefaultViewConfig() { + // this.defaultViewConfig = {}; + const url = 'DefaultViewConfigs'; + const filter = {where: {tableCode: this.viewConfigId}}; + return this.$http.get(url, {filter}) + .then(res => { + if (res && res.data.length) + return res.data[0].columns; + }); } get viewConfig() { @@ -80,19 +91,23 @@ export default class SmartTable extends Component { if (!value) return; if (!value.length) { - const userViewModel = this.$.userViewModel; + this.getDefaultViewConfig().then(columns => { + const defaultViewConfig = columns ? columns : {}; - for (const column of this.columns) { - if (this.defaultViewConfig[column.field] == undefined) - this.defaultViewConfig[column.field] = true; - } - userViewModel.insert({ - userFk: this.currentUserId, - tableConfig: this.viewConfigId, - configuration: this.defaultViewConfig ? this.defaultViewConfig : {} - }); - } - this.applyViewConfig(); + const userViewModel = this.$.userViewModel; + for (const column of this.columns) { + if (defaultViewConfig[column.field] == undefined) + defaultViewConfig[column.field] = true; + } + + userViewModel.insert({ + userFk: this.currentUserId, + tableConfig: this.viewConfigId, + configuration: defaultViewConfig + }); + }).finally(() => this.applyViewConfig()); + } else + this.applyViewConfig(); } get checkedRows() { diff --git a/front/core/components/smart-table/table.scss b/front/core/components/smart-table/table.scss index 370027d3e5..e0464465ae 100644 --- a/front/core/components/smart-table/table.scss +++ b/front/core/components/smart-table/table.scss @@ -27,7 +27,7 @@ smart-table table { & > th, & > td { text-align: left; - padding: 9px 8px; + padding: 9px 5px; white-space: nowrap; text-overflow: ellipsis;