@valtimo/iko 13.28.1 → 13.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fesm2022/valtimo-iko.mjs
CHANGED
|
@@ -428,30 +428,48 @@ class IkoMenuService {
|
|
|
428
428
|
title: this._IKO_MENU_ITEM_TITLE_TRANSLATION_KEY,
|
|
429
429
|
iconClass: 'icon mdi mdi-account',
|
|
430
430
|
show: true,
|
|
431
|
-
sequence: this.getIkoSequenceAfterCases(menuItems),
|
|
432
431
|
children: ikoSubMenu,
|
|
433
432
|
};
|
|
434
|
-
updatedMenuItems =
|
|
433
|
+
updatedMenuItems = this.insertAfterCases(updatedMenuItems, ikoMenu);
|
|
435
434
|
}
|
|
436
435
|
const adminMenuItem = updatedMenuItems.find(item => item.title.toUpperCase().includes('ADMIN') && !item.title.toUpperCase().includes('IKO'));
|
|
437
|
-
if (adminMenuItem && !adminMenuItem.children
|
|
438
|
-
adminMenuItem.children = [
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
sequence: this.getIkoSequenceAfterCases(adminMenuItem.children ?? []),
|
|
444
|
-
link: ['/iko-management'],
|
|
445
|
-
},
|
|
446
|
-
].sort((a, b) => a.sequence - b.sequence);
|
|
436
|
+
if (adminMenuItem && !adminMenuItem.children?.some(item => item.title === 'IKO')) {
|
|
437
|
+
adminMenuItem.children = this.insertAfterCases(adminMenuItem.children ?? [], {
|
|
438
|
+
title: 'IKO',
|
|
439
|
+
show: true,
|
|
440
|
+
link: ['/iko-management'],
|
|
441
|
+
});
|
|
447
442
|
}
|
|
448
443
|
return updatedMenuItems;
|
|
449
444
|
}));
|
|
450
445
|
};
|
|
451
446
|
}
|
|
452
|
-
|
|
453
|
-
const
|
|
454
|
-
|
|
447
|
+
insertAfterCases(menuItems, newItem) {
|
|
448
|
+
const casesIndex = menuItems.findIndex(item => item.title === 'Cases' || item.title === 'Dossiers');
|
|
449
|
+
if (casesIndex === -1) {
|
|
450
|
+
const lastSequence = menuItems[menuItems.length - 1]?.sequence;
|
|
451
|
+
return [
|
|
452
|
+
...menuItems,
|
|
453
|
+
{ ...newItem, sequence: lastSequence !== undefined ? lastSequence + 1 : undefined },
|
|
454
|
+
];
|
|
455
|
+
}
|
|
456
|
+
const itemWithSequence = {
|
|
457
|
+
...newItem,
|
|
458
|
+
sequence: this.sequenceBetween(menuItems[casesIndex], menuItems[casesIndex + 1]),
|
|
459
|
+
};
|
|
460
|
+
return [
|
|
461
|
+
...menuItems.slice(0, casesIndex + 1),
|
|
462
|
+
itemWithSequence,
|
|
463
|
+
...menuItems.slice(casesIndex + 1),
|
|
464
|
+
];
|
|
465
|
+
}
|
|
466
|
+
sequenceBetween(prev, next) {
|
|
467
|
+
if (prev.sequence === undefined)
|
|
468
|
+
return undefined;
|
|
469
|
+
if (next?.sequence !== undefined && next.sequence > prev.sequence) {
|
|
470
|
+
return (prev.sequence + next.sequence) / 2;
|
|
471
|
+
}
|
|
472
|
+
return prev.sequence;
|
|
455
473
|
}
|
|
456
474
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: IkoMenuService, deps: [{ token: IkoApiService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
457
475
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: IkoMenuService, providedIn: 'root' }); }
|