fix(smart-table): load default viewConfig
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-11-12 17:51:27 +01:00
parent 2e359fd8b7
commit b83f0fb52f
3 changed files with 33 additions and 17 deletions

View File

@ -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}');

View File

@ -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() {

View File

@ -27,7 +27,7 @@ smart-table table {
& > th,
& > td {
text-align: left;
padding: 9px 8px;
padding: 9px 5px;
white-space: nowrap;
text-overflow: ellipsis;