Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pb = ObjectUtils.copyDeep(pushButtons);
pb.groups.forEach(group => {
group.title = group.title ? group.title : group.name;
group.enabled = group.enabled ? group.enabled : false;
group.computedButtons = ObjectUtils.copyDeep(pb.bundles.filter(b => group.ids.includes(b.id)));
});
} else if (!pushButtons.groups && pushButtons.bundles) {
pb = ObjectUtils.copyDeep(pushButtons);
pb.groups = [{ title: 'group1', name: 'group1', computedButtons: ObjectUtils.copyDeep(pb.bundles) } as PushButtonGroup];
} else {
pb = {
bundles: pushButtons as OgcPushButtonBundle[],
groups: [
{
title: 'group1', name: 'group1',
computedButtons: ObjectUtils.copyDeep(pushButtons) as OgcPushButtonBundle[]
} as PushButtonGroup]
};
}
if (!pb.groups.find(pbGroup => pbGroup.enabled)) {
pb.groups[0].enabled = true;
}
return pb;
}
private computeIgoPushButton(pushButtons: IgoPushButton): IgoPushButton {
let pb: IgoPushButton;
if (pushButtons.groups && pushButtons.bundles) {
if (!pushButtons.bundles.every(bundle => bundle.id !== undefined)) {
throw new Error('You must set an id for each of your pushButtons bundles');
}
pb = ObjectUtils.copyDeep(pushButtons);
pb.groups.forEach(group => {
group.title = group.title ? group.title : group.name;
group.enabled = group.enabled ? group.enabled : false;
group.computedButtons = ObjectUtils.copyDeep(pb.bundles.filter(b => group.ids.includes(b.id)));
});
} else if (!pushButtons.groups && pushButtons.bundles) {
pb = ObjectUtils.copyDeep(pushButtons);
pb.groups = [{ title: 'group1', name: 'group1', computedButtons: ObjectUtils.copyDeep(pb.bundles) } as PushButtonGroup];
} else {
pb = {
bundles: pushButtons as OgcPushButtonBundle[],
groups: [
{
title: 'group1', name: 'group1',
computedButtons: ObjectUtils.copyDeep(pushButtons) as OgcPushButtonBundle[]
} as PushButtonGroup]
};
}
if (!pb.groups.find(pbGroup => pbGroup.enabled)) {
pb.groups[0].enabled = true;
}
return pb;
}
pb.groups.forEach(group => {
group.title = group.title ? group.title : group.name;
group.enabled = group.enabled ? group.enabled : false;
group.computedButtons = ObjectUtils.copyDeep(pb.bundles.filter(b => group.ids.includes(b.id)));
});
} else if (!pushButtons.groups && pushButtons.bundles) {
private computeIgoPushButton(pushButtons: IgoPushButton): IgoPushButton {
let pb: IgoPushButton;
if (pushButtons.groups && pushButtons.bundles) {
if (!pushButtons.bundles.every(bundle => bundle.id !== undefined)) {
throw new Error('You must set an id for each of your pushButtons bundles');
}
pb = ObjectUtils.copyDeep(pushButtons);
pb.groups.forEach(group => {
group.title = group.title ? group.title : group.name;
group.enabled = group.enabled ? group.enabled : false;
group.computedButtons = ObjectUtils.copyDeep(pb.bundles.filter(b => group.ids.includes(b.id)));
});
} else if (!pushButtons.groups && pushButtons.bundles) {
pb = ObjectUtils.copyDeep(pushButtons);
pb.groups = [{ title: 'group1', name: 'group1', computedButtons: ObjectUtils.copyDeep(pb.bundles) } as PushButtonGroup];
} else {
pb = {
bundles: pushButtons as OgcPushButtonBundle[],
groups: [
{
title: 'group1', name: 'group1',
computedButtons: ObjectUtils.copyDeep(pushButtons) as OgcPushButtonBundle[]
} as PushButtonGroup]