Skip to content

Commit

Permalink
Merge pull request #3050 from sap-labs-france/fix-site-areas-actions-…
Browse files Browse the repository at this point in the history
…not-shown

Fix tabledef creation and init
  • Loading branch information
Claude ROSSI authored Mar 29, 2022
2 parents 77aeb8c + f3f12a0 commit ab4e5b5
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class SiteAreasListTableDataSource extends TableDataSource<SiteArea> {
canCreate: siteAreas.canCreate
};
// Build TableDef using the initialized auth object
this.setTableDef(this.buildTableDefWithAuth());
this.setTableDef(this.buildTableDef());
this.createAction.visible = this.siteAreasAuthorizations.canCreate;
observer.next(siteAreas);
observer.complete();
Expand All @@ -108,9 +108,21 @@ export class SiteAreasListTableDataSource extends TableDataSource<SiteArea> {
});
}

// TableDef build is handled after retrieving site areas authorizations
// This function will be called twice: once in the normal worklow and second with auth
// TODO: Try to refactor so that we have a seperate tabledef init with authorization
public buildTableDef(): TableDef {
return {};
return {
search: {
enabled: true,
},
rowDetails: {
enabled: true,
showDetailsField: 'issuer',
angularComponent: SiteAreaConsumptionChartDetailComponent,
additionalParameters: this.siteAreasAuthorizations
},
hasDynamicRowAction: true,
};
}

public buildTableColumnDefs(): TableColumnDef[] {
Expand Down Expand Up @@ -364,19 +376,4 @@ export class SiteAreasListTableDataSource extends TableDataSource<SiteArea> {
new SiteTableFilter([issuerFilter]).getFilterDef(),
];
}
// Build tableDef using initialized authorizations retrieved from backend (additionalParameters)
private buildTableDefWithAuth(): TableDef {
return {
search: {
enabled: true,
},
rowDetails: {
enabled: true,
showDetailsField: 'issuer',
angularComponent: SiteAreaConsumptionChartDetailComponent,
additionalParameters: this.siteAreasAuthorizations
},
hasDynamicRowAction: true,
};
}
}

0 comments on commit ab4e5b5

Please sign in to comment.