@sumaris-net/ngx-components 2.4.134 → 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.
Files changed (27) hide show
  1. package/esm2020/public_api.mjs +2 -1
  2. package/esm2020/src/app/admin/users/users.mjs +83 -67
  3. package/esm2020/src/app/core/menu/menu.component.mjs +31 -42
  4. package/esm2020/src/app/core/menu/menu.model.mjs +27 -8
  5. package/esm2020/src/app/core/menu/menu.service.mjs +138 -55
  6. package/esm2020/src/app/core/menu/sub-menu-tab.directive.mjs +15 -11
  7. package/esm2020/src/app/core/menu/testing/menu-other.testing.mjs +3 -3
  8. package/esm2020/src/app/core/menu/testing/menu.testing.mjs +4 -4
  9. package/esm2020/src/app/core/services/config.service.mjs +2 -2
  10. package/esm2020/src/app/core/services/model/entity.model.mjs +17 -34
  11. package/esm2020/src/app/core/services/model/tree-item-entity.model.mjs +197 -0
  12. package/esm2020/src/app/core/services/platform.service.mjs +2 -2
  13. package/esm2020/src/app/shared/services/startable-observable-service.class.mjs +6 -7
  14. package/fesm2015/sumaris-net.ngx-components.mjs +519 -232
  15. package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
  16. package/fesm2020/sumaris-net.ngx-components.mjs +486 -200
  17. package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
  18. package/package.json +1 -1
  19. package/public_api.d.ts +1 -0
  20. package/src/app/admin/users/users.d.ts +4 -2
  21. package/src/app/core/menu/menu.component.d.ts +4 -9
  22. package/src/app/core/menu/menu.model.d.ts +17 -6
  23. package/src/app/core/menu/menu.service.d.ts +24 -6
  24. package/src/app/core/menu/sub-menu-tab.directive.d.ts +1 -1
  25. package/src/app/core/services/model/entity.model.d.ts +4 -8
  26. package/src/app/core/services/model/tree-item-entity.model.d.ts +53 -0
  27. package/src/app/shared/services/startable-observable-service.class.d.ts +2 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sumaris-net/ngx-components",
3
3
  "description": "SUMARiS Angular components",
4
- "version": "2.4.134",
4
+ "version": "2.4.136",
5
5
  "author": "contact@e-is.pro",
6
6
  "license": "AGPL-3.0",
7
7
  "readmeFilename": "README.md",
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';
@@ -10,6 +10,7 @@ import { PersonFilter } from '../services/filter/person.filter';
10
10
  import { ConfigService } from '../../core/services/config.service';
11
11
  import { MatExpansionPanel } from '@angular/material/expansion';
12
12
  import { MessageService } from '../../social/message/message.service';
13
+ import { MenuService } from '../../core/menu/menu.service';
13
14
  import * as i0 from "@angular/core";
14
15
  export declare class UsersPage extends AppTable<Person, PersonFilter> implements OnInit {
15
16
  protected accountService: AccountService;
@@ -17,6 +18,7 @@ export declare class UsersPage extends AppTable<Person, PersonFilter> implements
17
18
  protected configService: ConfigService;
18
19
  protected dataService: PersonService;
19
20
  protected messageService: MessageService;
21
+ protected menuService: MenuService;
20
22
  protected cd: ChangeDetectorRef;
21
23
  readonly canEdit: boolean;
22
24
  readonly canSendMessage: boolean;
@@ -29,10 +31,10 @@ export declare class UsersPage extends AppTable<Person, PersonFilter> implements
29
31
  set showUsernameColumn(value: boolean);
30
32
  set showUsernameExtranetColumn(value: boolean);
31
33
  useSticky: boolean;
32
- constructor(injector: Injector, formBuilder: UntypedFormBuilder, accountService: AccountService, validatorService: ValidatorService, configService: ConfigService, dataService: PersonService, messageService: MessageService, cd: ChangeDetectorRef, environment: any);
34
+ constructor(injector: Injector, formBuilder: UntypedFormBuilder, accountService: AccountService, validatorService: ValidatorService, configService: ConfigService, dataService: PersonService, messageService: MessageService, menuService: MenuService, cd: ChangeDetectorRef, environment: any);
33
35
  filterExpansionPanel: MatExpansionPanel;
34
36
  get firstUserColumn(): string;
35
- ngOnInit(): void;
37
+ ngOnInit(): Promise<void>;
36
38
  applyFilterAndClosePanel(event?: Event): void;
37
39
  resetFilter(event?: Event): void;
38
40
  protected restoreFilterOrLoad(): Promise<void>;
@@ -1,16 +1,14 @@
1
- import { ChangeDetectorRef, InjectionToken, OnInit } from '@angular/core';
1
+ import { ChangeDetectorRef, OnInit } from '@angular/core';
2
2
  import { AlertController, IonSplitPane, MenuController, ModalController, NavController } from '@ionic/angular';
3
3
  import { Account } from '../services/model/account.model';
4
4
  import { AccountService } from '../services/account.service';
5
5
  import { TranslateService } from '@ngx-translate/core';
6
6
  import { PlatformService } from '../services/platform.service';
7
7
  import { MenuService, SplitPaneShowWhen } from './menu.service';
8
- import { IMenuItem, MenuOptions } from './menu.model';
8
+ import { IMenuItem } from './menu.model';
9
9
  import { ActivatedRoute, Router } from '@angular/router';
10
10
  import { RxStrategyNames } from '@rx-angular/cdk/render-strategies';
11
11
  import * as i0 from "@angular/core";
12
- export declare const APP_MENU_ITEMS: InjectionToken<IMenuItem[]>;
13
- export declare const APP_MENU_OPTIONS: InjectionToken<MenuOptions>;
14
12
  export declare class MenuComponent implements OnInit {
15
13
  protected platformService: PlatformService;
16
14
  protected accountService: AccountService;
@@ -24,8 +22,6 @@ export declare class MenuComponent implements OnInit {
24
22
  protected router: Router;
25
23
  protected environment: any;
26
24
  protected route: ActivatedRoute;
27
- protected options: MenuOptions;
28
- protected items: IMenuItem[];
29
25
  id: string;
30
26
  menuId: string;
31
27
  side: string;
@@ -42,8 +38,7 @@ export declare class MenuComponent implements OnInit {
42
38
  accountEmail: string;
43
39
  private readonly _debug;
44
40
  private _subscription;
45
- constructor(platformService: PlatformService, accountService: AccountService, navController: NavController, menu: MenuController, modalCtrl: ModalController, alertController: AlertController, translate: TranslateService, cd: ChangeDetectorRef, menuService: MenuService, router: Router, environment: any, route: ActivatedRoute, // Modal editor give 'null'
46
- options: MenuOptions, items: IMenuItem[]);
41
+ constructor(platformService: PlatformService, accountService: AccountService, navController: NavController, menu: MenuController, modalCtrl: ModalController, alertController: AlertController, translate: TranslateService, cd: ChangeDetectorRef, menuService: MenuService, router: Router, environment: any, route: ActivatedRoute);
47
42
  ngOnInit(): Promise<void>;
48
43
  onLogin(account: Account): Promise<void>;
49
44
  onLogout(skipRedirect?: boolean): Promise<void>;
@@ -66,6 +61,6 @@ export declare class MenuComponent implements OnInit {
66
61
  protected detectChanges(): void;
67
62
  protected markForCheck(): void;
68
63
  protected togglePinned(event: Event, item: IMenuItem): void;
69
- static ɵfac: i0.ɵɵFactoryDeclaration<MenuComponent, [null, null, null, null, null, null, null, null, null, null, null, { optional: true; }, { optional: true; }, { optional: true; }]>;
64
+ static ɵfac: i0.ɵɵFactoryDeclaration<MenuComponent, [null, null, null, null, null, null, null, null, null, null, null, { optional: true; }]>;
70
65
  static ɵcmp: i0.ɵɵComponentDeclaration<MenuComponent, "app-menu", never, { "id": "id"; "menuId": "menuId"; "side": "side"; "contentId": "contentId"; "logo": "logo"; "appName": "appName"; "appVersion": "appVersion"; "rxStrategy": "rxStrategy"; }, {}, never, ["*", "[headerBottomRight]"], false>;
71
66
  }
@@ -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?: number;
36
- parent?: MenuItem;
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,14 +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): MenuItem;
64
- fromObject(source: any): void;
65
- asObject(): any;
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;
80
+ get ancestor(): MenuItem;
71
81
  isPinned(): any;
72
82
  }
73
83
  export declare class MenuItems {
@@ -118,4 +128,5 @@ export declare class MenuItems {
118
128
  }
119
129
  export declare class MenuOptions {
120
130
  enableSubMenus?: boolean;
131
+ enableSubMenuIcon?: boolean;
121
132
  }
@@ -1,15 +1,18 @@
1
+ import { EventEmitter, InjectionToken } from '@angular/core';
1
2
  import { BehaviorSubject, Observable } from 'rxjs';
2
- import { IMenuItem, MenuItem } from './menu.model';
3
+ import { IMenuItem, MenuItem, MenuOptions } from './menu.model';
3
4
  import { Router } from '@angular/router';
4
5
  import { Environment } from '../../../environments/environment.class';
5
- import { PlatformService } from '../services/platform.service';
6
6
  import { AccountService } from '../services/account.service';
7
7
  import { ConfigService } from '../services/config.service';
8
8
  import { Account } from '../services/model/account.model';
9
9
  import { StartableObservableService } from '../../shared/services/startable-observable-service.class';
10
+ import { LocalSettingsService } from '../services/local-settings.service';
10
11
  import * as i0 from "@angular/core";
11
12
  export declare type SplitPaneShowWhen = boolean | 'lg';
12
13
  export declare const DEFAULT_MENU_SHOW_WHEN: SplitPaneShowWhen;
14
+ export declare const APP_MENU_ITEMS: InjectionToken<IMenuItem[]>;
15
+ export declare const APP_MENU_OPTIONS: InjectionToken<MenuOptions>;
13
16
  export interface MenuPathParam {
14
17
  path: string;
15
18
  params: {
@@ -17,12 +20,14 @@ export interface MenuPathParam {
17
20
  };
18
21
  }
19
22
  export declare class MenuService extends StartableObservableService<MenuItem[]> {
20
- protected platformService: PlatformService;
21
23
  protected configService: ConfigService;
24
+ protected settings: LocalSettingsService;
22
25
  protected accountService: AccountService;
23
26
  protected router: Router;
24
27
  protected environment: Environment;
28
+ protected options?: MenuOptions;
25
29
  readonly accountChanges: BehaviorSubject<Account>;
30
+ readonly pinnedEvent: EventEmitter<MenuItem>;
26
31
  private _staticItems;
27
32
  private _detachedSubItems;
28
33
  private _itemCounter;
@@ -30,21 +35,33 @@ export declare class MenuService extends StartableObservableService<MenuItem[]>
30
35
  private readonly _$opened;
31
36
  private readonly _$splitPaneWhen;
32
37
  private readonly _$enabled;
38
+ private readonly _$subMenuEnabled;
33
39
  private readonly _$listenRoute;
34
- constructor(platformService: PlatformService, configService: ConfigService, accountService: AccountService, router: Router, environment: Environment, staticItems?: IMenuItem[]);
40
+ constructor(configService: ConfigService, settings: LocalSettingsService, accountService: AccountService, router: Router, environment: Environment, options?: MenuOptions, staticItems?: IMenuItem[]);
35
41
  get opened(): Observable<boolean>;
36
42
  get splitPaneWhen(): Observable<SplitPaneShowWhen>;
37
43
  get enabled(): Observable<boolean>;
44
+ get subMenuEnabled(): boolean;
45
+ get subMenuIconEnabled(): boolean;
46
+ get subItems(): MenuItem[];
47
+ private get _staticSubItems();
38
48
  enable(value: boolean): void;
49
+ enableSubMenu(value: boolean): void;
39
50
  setSplitPaneShowWhen(value: SplitPaneShowWhen): void;
40
51
  toggleSplitPaneWhen(): void;
41
- loadOrCreate(source: Partial<IMenuItem>): MenuItem;
52
+ fromObject(source: any, opts?: {
53
+ withChildren?: boolean;
54
+ computeId?: boolean;
55
+ fillParent?: boolean;
56
+ }): MenuItem;
57
+ createSubMenu(source: Partial<IMenuItem>): MenuItem;
42
58
  addSubMenuItems(sources: IMenuItem[], opts?: {
43
59
  skipIfExists?: boolean;
44
60
  }): Promise<MenuItem[]>;
45
61
  addSubMenuItem(item: IMenuItem, opts?: {
46
62
  skipIfExists?: boolean;
47
63
  }): Promise<MenuItem>;
64
+ removeSubMenuItems(items: IMenuItem[]): Promise<MenuItem[]>;
48
65
  removeSubMenuItem(item: IMenuItem): Promise<MenuItem>;
49
66
  togglePinned(source: IMenuItem): void;
50
67
  _markAsOpened(): void;
@@ -54,11 +71,12 @@ export declare class MenuService extends StartableObservableService<MenuItem[]>
54
71
  private _addSubMenuItems;
55
72
  private _addSubMenuItem;
56
73
  private _computeNewId;
74
+ private _removeSubMenuItem;
57
75
  private _detachSubMenuItems;
58
76
  private _detachToParent;
59
77
  private _findExistingItem;
60
78
  private _findParent;
61
79
  private _attachMenuToParent;
62
- static ɵfac: i0.ɵɵFactoryDeclaration<MenuService, [null, null, null, null, null, { optional: true; }]>;
80
+ static ɵfac: i0.ɵɵFactoryDeclaration<MenuService, [null, null, null, null, null, { optional: true; }, { optional: true; }]>;
63
81
  static ɵprov: i0.ɵɵInjectableDeclaration<MenuService>;
64
82
  }
@@ -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 _debug;
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<T extends ITreeItemEntity<any>>(source: T): T[];
75
- static listOfTreeToArray<T extends ITreeItemEntity<any>>(sources: T[]): T[];
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<T extends ITreeItemEntity<any>>(source: T): T[];
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
+ }
@@ -1,5 +1,5 @@
1
- import { BehaviorSubject, Subject, Subscription } from 'rxjs';
2
- import { IStartableService } from './startable-service.class';
1
+ import { BehaviorSubject, Subject, Subscription } from "rxjs";
2
+ import { IStartableService } from "./startable-service.class";
3
3
  /**
4
4
  * Same as StartableService, but with a dataSubject instead of a simple 'data' property
5
5
  */