Skip to content

Commit 58582f1

Browse files
committed
fix: handle empty config and add ignore_columns support
- Added check for empty config object to prevent errors when config is present but has no properties - Added support for ignore_columns configuration to filter out specified component IDs - Used optional chaining (model?.includes) for safer property access - Improved code clarity by extracting ignore_columns to a dedicated variable This ensures the service time machine handles edge cases properly and allows for more flexible component filtering based on configuration.
1 parent e9c429b commit 58582f1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

core/services/service_time_machine/js/service_time_machine.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ service_time_machine.prototype.build_request_config = function() {
279279

280280
// config. config is an object with basic component/section definitions and preferences (model, tipo, section_tipo, section_id, lang)
281281
const config = self.config
282-
if (!config) {
282+
if (!config || Object.keys(config).length === 0) {
283283
console.error('Error. config is mandatory');
284284
return null
285285
}
@@ -443,7 +443,7 @@ service_time_machine.prototype.build_request_config = function() {
443443
]
444444

445445
// tool view case
446-
if (self.view==='tool' && model.includes('component')) {
446+
if (self.view==='tool' && model?.includes('component')) {
447447
default_ddo_map.push(
448448
// annotations rsc329 (section_tipo "rsc832")
449449
{
@@ -461,8 +461,11 @@ service_time_machine.prototype.build_request_config = function() {
461461
)
462462
}
463463

464+
// ignore_columns
465+
const ignore_columns = config.ignore_columns || []
466+
464467
// Remove ignore_columns by id defined in callers (tool, inspector, etc)
465-
const ddo_map = default_ddo_map.filter( el => !self.config.ignore_columns.includes(el.id) )
468+
const ddo_map = default_ddo_map.filter( el => !ignore_columns.includes(el.id) )
466469

467470
// config_ddo_map. Additional ddo array
468471
if (config_ddo_map) {

0 commit comments

Comments
 (0)