@sumaris-net/ngx-components 2.4.135 → 2.4.136
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/esm2020/public_api.mjs +2 -1
- package/esm2020/src/app/core/menu/menu.component.mjs +3 -3
- package/esm2020/src/app/core/menu/menu.model.mjs +20 -8
- package/esm2020/src/app/core/menu/menu.service.mjs +73 -32
- package/esm2020/src/app/core/menu/sub-menu-tab.directive.mjs +14 -13
- package/esm2020/src/app/core/services/model/entity.model.mjs +17 -34
- package/esm2020/src/app/core/services/model/tree-item-entity.model.mjs +197 -0
- package/esm2020/src/app/core/services/platform.service.mjs +2 -2
- package/fesm2015/sumaris-net.ngx-components.mjs +310 -86
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +314 -84
- package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +1 -0
- package/src/app/core/menu/menu.model.d.ts +16 -7
- package/src/app/core/menu/menu.service.d.ts +14 -7
- package/src/app/core/menu/sub-menu-tab.directive.d.ts +1 -1
- package/src/app/core/services/model/entity.model.d.ts +4 -8
- package/src/app/core/services/model/tree-item-entity.model.d.ts +53 -0
package/package.json
CHANGED
package/public_api.d.ts
CHANGED
|
@@ -131,6 +131,7 @@ export * from './src/app/core/services/model/account.model';
|
|
|
131
131
|
export * from './src/app/core/services/model/config.model';
|
|
132
132
|
export * from './src/app/core/services/model/department.model';
|
|
133
133
|
export * from './src/app/core/services/model/entity.model';
|
|
134
|
+
export * from "./src/app/core/services/model/tree-item-entity.model";
|
|
134
135
|
export * from './src/app/core/services/model/filter.model';
|
|
135
136
|
export * from './src/app/core/services/model/history.model';
|
|
136
137
|
export * from './src/app/core/services/model/model.enum';
|
|
@@ -4,6 +4,8 @@ import { AppColors, IconRef } from '../../shared/types';
|
|
|
4
4
|
import { BehaviorSubject } from 'rxjs';
|
|
5
5
|
import { MenuPathParam } from './menu.service';
|
|
6
6
|
import { Account } from '../services/model/account.model';
|
|
7
|
+
import { Entity, EntityAsObjectOptions } from '../services/model/entity.model';
|
|
8
|
+
import { ITreeItemEntity } from '../services/model/tree-item-entity.model';
|
|
7
9
|
export interface IMenuItem extends IconRef {
|
|
8
10
|
title: string;
|
|
9
11
|
path?: string;
|
|
@@ -31,9 +33,10 @@ export interface IMenuItem extends IconRef {
|
|
|
31
33
|
parent?: IMenuItem;
|
|
32
34
|
children?: IMenuItem[];
|
|
33
35
|
}
|
|
34
|
-
export declare class MenuItem implements IMenuItem {
|
|
35
|
-
id
|
|
36
|
-
parent
|
|
36
|
+
export declare class MenuItem extends Entity<MenuItem> implements IMenuItem, ITreeItemEntity<MenuItem> {
|
|
37
|
+
id: number;
|
|
38
|
+
parent: MenuItem;
|
|
39
|
+
parentId: number;
|
|
37
40
|
$children: BehaviorSubject<MenuItem[]>;
|
|
38
41
|
$title: BehaviorSubject<string>;
|
|
39
42
|
titleProperty?: string;
|
|
@@ -60,15 +63,21 @@ export declare class MenuItem implements IMenuItem {
|
|
|
60
63
|
icon?: string;
|
|
61
64
|
matIcon?: string;
|
|
62
65
|
matSvgIcon?: string;
|
|
63
|
-
static fromObject(source: any
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
static fromObject(source: any, opts?: {
|
|
67
|
+
withChildren?: boolean;
|
|
68
|
+
}): MenuItem;
|
|
69
|
+
fromObject(source: any, opts?: {
|
|
70
|
+
withChildren?: boolean;
|
|
71
|
+
}): void;
|
|
72
|
+
asObject(opts?: {
|
|
73
|
+
withChildren?: boolean;
|
|
74
|
+
} & EntityAsObjectOptions): any;
|
|
66
75
|
get children(): MenuItem[];
|
|
67
76
|
set children(value: MenuItem[]);
|
|
68
77
|
get title(): string;
|
|
69
78
|
set title(value: string);
|
|
70
79
|
get detached(): boolean;
|
|
71
|
-
get ancestor():
|
|
80
|
+
get ancestor(): MenuItem;
|
|
72
81
|
isPinned(): any;
|
|
73
82
|
}
|
|
74
83
|
export declare class MenuItems {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
1
|
+
import { EventEmitter, InjectionToken } from '@angular/core';
|
|
2
2
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
3
|
import { IMenuItem, MenuItem, MenuOptions } from './menu.model';
|
|
4
4
|
import { Router } from '@angular/router';
|
|
5
5
|
import { Environment } from '../../../environments/environment.class';
|
|
6
|
-
import { PlatformService } from '../services/platform.service';
|
|
7
6
|
import { AccountService } from '../services/account.service';
|
|
8
7
|
import { ConfigService } from '../services/config.service';
|
|
9
8
|
import { Account } from '../services/model/account.model';
|
|
10
9
|
import { StartableObservableService } from '../../shared/services/startable-observable-service.class';
|
|
10
|
+
import { LocalSettingsService } from '../services/local-settings.service';
|
|
11
11
|
import * as i0 from "@angular/core";
|
|
12
12
|
export declare type SplitPaneShowWhen = boolean | 'lg';
|
|
13
13
|
export declare const DEFAULT_MENU_SHOW_WHEN: SplitPaneShowWhen;
|
|
@@ -20,13 +20,14 @@ export interface MenuPathParam {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
export declare class MenuService extends StartableObservableService<MenuItem[]> {
|
|
23
|
-
protected platformService: PlatformService;
|
|
24
23
|
protected configService: ConfigService;
|
|
24
|
+
protected settings: LocalSettingsService;
|
|
25
25
|
protected accountService: AccountService;
|
|
26
26
|
protected router: Router;
|
|
27
27
|
protected environment: Environment;
|
|
28
|
-
protected options
|
|
28
|
+
protected options?: MenuOptions;
|
|
29
29
|
readonly accountChanges: BehaviorSubject<Account>;
|
|
30
|
+
readonly pinnedEvent: EventEmitter<MenuItem>;
|
|
30
31
|
private _staticItems;
|
|
31
32
|
private _detachedSubItems;
|
|
32
33
|
private _itemCounter;
|
|
@@ -36,18 +37,24 @@ export declare class MenuService extends StartableObservableService<MenuItem[]>
|
|
|
36
37
|
private readonly _$enabled;
|
|
37
38
|
private readonly _$subMenuEnabled;
|
|
38
39
|
private readonly _$listenRoute;
|
|
39
|
-
constructor(
|
|
40
|
+
constructor(configService: ConfigService, settings: LocalSettingsService, accountService: AccountService, router: Router, environment: Environment, options?: MenuOptions, staticItems?: IMenuItem[]);
|
|
40
41
|
get opened(): Observable<boolean>;
|
|
41
42
|
get splitPaneWhen(): Observable<SplitPaneShowWhen>;
|
|
42
43
|
get enabled(): Observable<boolean>;
|
|
43
44
|
get subMenuEnabled(): boolean;
|
|
44
45
|
get subMenuIconEnabled(): boolean;
|
|
46
|
+
get subItems(): MenuItem[];
|
|
47
|
+
private get _staticSubItems();
|
|
45
48
|
enable(value: boolean): void;
|
|
46
49
|
enableSubMenu(value: boolean): void;
|
|
47
50
|
setSplitPaneShowWhen(value: SplitPaneShowWhen): void;
|
|
48
51
|
toggleSplitPaneWhen(): void;
|
|
49
|
-
fromObject(source: any
|
|
50
|
-
|
|
52
|
+
fromObject(source: any, opts?: {
|
|
53
|
+
withChildren?: boolean;
|
|
54
|
+
computeId?: boolean;
|
|
55
|
+
fillParent?: boolean;
|
|
56
|
+
}): MenuItem;
|
|
57
|
+
createSubMenu(source: Partial<IMenuItem>): MenuItem;
|
|
51
58
|
addSubMenuItems(sources: IMenuItem[], opts?: {
|
|
52
59
|
skipIfExists?: boolean;
|
|
53
60
|
}): Promise<MenuItem[]>;
|
|
@@ -16,7 +16,7 @@ export declare class SubMenuTabDirective implements OnChanges, AfterViewInit {
|
|
|
16
16
|
subMenuTitle: string;
|
|
17
17
|
subMenuIcon: IconRef;
|
|
18
18
|
private _menuItem;
|
|
19
|
-
private
|
|
19
|
+
private readonly _enable;
|
|
20
20
|
constructor(menuService: MenuService, tabGroup: MatTabGroup, tab: MatTab, router: Router);
|
|
21
21
|
ngAfterViewInit(): void;
|
|
22
22
|
ngOnChanges(changes: SimpleChanges): void;
|
|
@@ -3,6 +3,7 @@ import { getPropertyByPath } from '../../../shared/functions';
|
|
|
3
3
|
import { FilterFn } from '../../../shared/services/entity-service.class';
|
|
4
4
|
import { ObjectMap, ObjectMapEntry, PropertiesArray, PropertiesMap } from '../../../shared/types';
|
|
5
5
|
import { StoreObject } from '@apollo/client/core';
|
|
6
|
+
import { TreeItemEntityUtils } from './tree-item-entity.model';
|
|
6
7
|
export declare interface Cloneable<T> {
|
|
7
8
|
clone(): T;
|
|
8
9
|
}
|
|
@@ -22,11 +23,6 @@ export interface IEntity<T, ID = number, AO extends EntityAsObjectOptions = Enti
|
|
|
22
23
|
asObject(opts?: AO): any;
|
|
23
24
|
fromObject(source: any, opts?: FO): any;
|
|
24
25
|
}
|
|
25
|
-
export declare interface ITreeItemEntity<T extends IEntity<T, ID>, ID = number> {
|
|
26
|
-
parentId: ID;
|
|
27
|
-
parent: T;
|
|
28
|
-
children: T[];
|
|
29
|
-
}
|
|
30
26
|
export declare abstract class Entity<T extends Entity<T, ID, AO, FO>, ID = number, AO extends EntityAsObjectOptions = EntityAsObjectOptions, FO = any> implements IEntity<T, ID, AO, FO> {
|
|
31
27
|
static TYPENAME: string;
|
|
32
28
|
id: ID;
|
|
@@ -71,14 +67,14 @@ export declare abstract class EntityUtils {
|
|
|
71
67
|
*
|
|
72
68
|
* @param source
|
|
73
69
|
*/
|
|
74
|
-
static treeToArray
|
|
75
|
-
static listOfTreeToArray
|
|
70
|
+
static treeToArray: typeof TreeItemEntityUtils.treeToArray;
|
|
71
|
+
static listOfTreeToArray: typeof TreeItemEntityUtils.listOfTreeToArray;
|
|
76
72
|
/**
|
|
77
73
|
* Fill parent attribute, of all children found in the tree
|
|
78
74
|
*
|
|
79
75
|
* @param source
|
|
80
76
|
*/
|
|
81
|
-
static treeFillParent
|
|
77
|
+
static treeFillParent: typeof TreeItemEntityUtils.treeFillParent;
|
|
82
78
|
static isLocal(entity: IEntity<any, any> | Entity<any, any>): boolean;
|
|
83
79
|
static isRemote(entity: IEntity<any, any> | Entity<any, any>): boolean;
|
|
84
80
|
static isLocalId(id: number): boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IEntity } from './entity.model';
|
|
2
|
+
import { FilterFn } from '../../../shared/services/entity-service.class';
|
|
3
|
+
import { EntityFilter } from './filter.model';
|
|
4
|
+
export declare interface ITreeItemEntity<T extends IEntity<T, ID>, ID = number> {
|
|
5
|
+
parentId: ID;
|
|
6
|
+
parent: T;
|
|
7
|
+
children: T[];
|
|
8
|
+
}
|
|
9
|
+
export declare class TreeItemEntityUtils {
|
|
10
|
+
static forward<T extends ITreeItemEntity<any>, ID = number>(node: T, filterFn?: FilterFn<T>, loopCount?: number): T;
|
|
11
|
+
static backward<T extends ITreeItemEntity<any>, ID = number>(node: T, filterFn?: FilterFn<T>, loopCount?: number): T;
|
|
12
|
+
static first<T extends ITreeItemEntity<any>>(node: T, filterFn?: FilterFn<T>): T;
|
|
13
|
+
static lastLeaf<T extends ITreeItemEntity<any>>(node: T, filterFn?: FilterFn<T>): T;
|
|
14
|
+
static findByFilter<T extends ITreeItemEntity<T> & IEntity<T>>(node: T, filter: EntityFilter<any, T>): T[];
|
|
15
|
+
/**
|
|
16
|
+
* Delete matches batches
|
|
17
|
+
*
|
|
18
|
+
* @param node
|
|
19
|
+
* @param filter
|
|
20
|
+
*/
|
|
21
|
+
static deleteByFilter<T extends ITreeItemEntity<T> & IEntity<T>>(node: T, filter: EntityFilter<any, T>): T[];
|
|
22
|
+
static filterRecursively<T extends ITreeItemEntity<any>>(node: T, filterFn: (n: T) => boolean): T[];
|
|
23
|
+
static deleteRecursively<T extends ITreeItemEntity<any>>(node: T, filterFn: (n: T) => boolean): T[];
|
|
24
|
+
/**
|
|
25
|
+
* Visit each node, from root to leaf
|
|
26
|
+
*
|
|
27
|
+
* @param node
|
|
28
|
+
* @param action
|
|
29
|
+
*/
|
|
30
|
+
static visit<T extends ITreeItemEntity<any>>(node: T, action: (T: any) => void): void;
|
|
31
|
+
/**
|
|
32
|
+
* Visit each node, from leaf to root
|
|
33
|
+
*
|
|
34
|
+
* @param node
|
|
35
|
+
* @param action
|
|
36
|
+
*/
|
|
37
|
+
static visitInverse<T extends ITreeItemEntity<any>>(node: T, action: (T: any) => void): void;
|
|
38
|
+
/**
|
|
39
|
+
* Transform a batch entity tree into a array list. This method keep links parent/children.
|
|
40
|
+
*
|
|
41
|
+
* Method used to find batch without id (e.g. before local storage)
|
|
42
|
+
*
|
|
43
|
+
* @param source
|
|
44
|
+
*/
|
|
45
|
+
static treeToArray<T extends ITreeItemEntity<any>>(source: T): T[];
|
|
46
|
+
static listOfTreeToArray<T extends ITreeItemEntity<any>>(sources: T[]): T[];
|
|
47
|
+
/**
|
|
48
|
+
* Fill parent attribute, of all children found in the tree
|
|
49
|
+
*
|
|
50
|
+
* @param source
|
|
51
|
+
*/
|
|
52
|
+
static treeFillParent<T extends ITreeItemEntity<any>>(source: T): any;
|
|
53
|
+
}
|