@mediusinc/mng-commons 0.4.1 → 0.4.4

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 (30) hide show
  1. package/assets/i18n/en.json +24 -19
  2. package/assets/i18n/sl.json +22 -17
  3. package/esm2020/lib/components/action/action.component.mjs +4 -4
  4. package/esm2020/lib/components/action/editor/action-editor.component.mjs +4 -8
  5. package/esm2020/lib/components/form/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +1 -1
  6. package/esm2020/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +1 -1
  7. package/esm2020/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +1 -1
  8. package/esm2020/lib/components/tableview/table/table.component.mjs +7 -3
  9. package/esm2020/lib/components/tableview/tableview.component.mjs +4 -4
  10. package/esm2020/lib/descriptors/action.descriptor.mjs +29 -10
  11. package/esm2020/lib/descriptors/editor.descriptor.mjs +4 -4
  12. package/esm2020/lib/descriptors/field.descriptor.mjs +3 -3
  13. package/esm2020/lib/pipes/i18n-property.pipe.mjs +3 -3
  14. package/esm2020/lib/pipes/link-formatter.pipe.mjs +1 -1
  15. package/esm2020/lib/services/action-executor.service.mjs +13 -14
  16. package/esm2020/lib/services/view-container.component.service.mjs +2 -2
  17. package/esm2020/lib/utils/i18n.util.mjs +212 -144
  18. package/esm2020/lib/utils/notification.util.mjs +16 -17
  19. package/fesm2015/mediusinc-mng-commons.mjs +363 -277
  20. package/fesm2015/mediusinc-mng-commons.mjs.map +1 -1
  21. package/fesm2020/mediusinc-mng-commons.mjs +357 -275
  22. package/fesm2020/mediusinc-mng-commons.mjs.map +1 -1
  23. package/lib/components/tableview/table/table.component.d.ts +4 -1
  24. package/lib/descriptors/action.descriptor.d.ts +13 -6
  25. package/lib/pipes/link-formatter.pipe.d.ts +1 -1
  26. package/lib/services/action-executor.service.d.ts +4 -2
  27. package/lib/services/view-container.component.service.d.ts +1 -1
  28. package/lib/utils/i18n.util.d.ts +52 -21
  29. package/lib/utils/notification.util.d.ts +4 -4
  30. package/package.json +1 -1
@@ -9,6 +9,7 @@ import { MediusQueryResult } from '../../../api/models';
9
9
  import { ITableDataProvider } from '../../../data-providers';
10
10
  import { ColumnDescriptor, TableDescriptor } from '../../../descriptors';
11
11
  import { MngComponentDirective, MngTemplateDirective } from '../../../directives';
12
+ import { IViewContainer } from '../../../models';
12
13
  import { MngViewContainerComponentService } from '../../../services';
13
14
  import { MngTableCellClickEvent, MngTableLoadEvent } from '../models';
14
15
  import * as i0 from "@angular/core";
@@ -29,6 +30,7 @@ export declare class MngTableComponent<T, S> implements OnInit, AfterContentInit
29
30
  selectionMode: string;
30
31
  selectionEnabled: boolean;
31
32
  isColumnClickable: boolean;
33
+ viewContainerInit?: IViewContainer<T, S>;
32
34
  captionComponent?: Type<any>;
33
35
  columnActionComponent?: Type<any>;
34
36
  loadEventEmitter: EventEmitter<MngTableLoadEvent>;
@@ -68,6 +70,7 @@ export declare class MngTableComponent<T, S> implements OnInit, AfterContentInit
68
70
  private isFilterChanged;
69
71
  private isSortChanged;
70
72
  private filterDescriptors;
73
+ private viewContainer?;
71
74
  private subscriptions;
72
75
  constructor(injector: Injector, router: Router, activatedRoute: ActivatedRoute, translate: TranslateService, viewContainerService: MngViewContainerComponentService<T, S> | null);
73
76
  ngOnInit(): void;
@@ -86,5 +89,5 @@ export declare class MngTableComponent<T, S> implements OnInit, AfterContentInit
86
89
  private updatePrimeSortAndFilter;
87
90
  private getDefaultSortMeta;
88
91
  static ɵfac: i0.ɵɵFactoryDeclaration<MngTableComponent<any, any>, [null, null, null, null, { optional: true; }]>;
89
- static ɵcmp: i0.ɵɵComponentDeclaration<MngTableComponent<any, any>, "mng-table", never, { "descriptor": "descriptor"; "items": "items"; "queryResult": "queryResult"; "loading": "loading"; "dataProvider": "dataProvider"; "useQueryParams": "useQueryParams"; "selectionMode": "selectionMode"; "selectionEnabled": "selectionEnabled"; "isColumnClickable": "isColumnClickable"; "captionComponent": "captionComponent"; "columnActionComponent": "columnActionComponent"; }, { "loadEventEmitter": "tableLoad"; "cellClickEventEmitter": "cellClick"; "selectionChangeEventEmitter": "selectionChange"; "captionCmpInstEventEmitter": "captionComponentInstance"; "columnActionCmpInstEventEmitter": "columnActionComponentInstance"; }, ["templates"], never>;
92
+ static ɵcmp: i0.ɵɵComponentDeclaration<MngTableComponent<any, any>, "mng-table", never, { "descriptor": "descriptor"; "items": "items"; "queryResult": "queryResult"; "loading": "loading"; "dataProvider": "dataProvider"; "useQueryParams": "useQueryParams"; "selectionMode": "selectionMode"; "selectionEnabled": "selectionEnabled"; "isColumnClickable": "isColumnClickable"; "viewContainerInit": "viewContainer"; "captionComponent": "captionComponent"; "columnActionComponent": "columnActionComponent"; }, { "loadEventEmitter": "tableLoad"; "cellClickEventEmitter": "cellClick"; "selectionChangeEventEmitter": "selectionChange"; "captionCmpInstEventEmitter": "captionComponentInstance"; "columnActionCmpInstEventEmitter": "columnActionComponentInstance"; }, ["templates"], never>;
90
93
  }
@@ -6,12 +6,12 @@ import { IDataProvider, IEditorDataProvider } from '../data-providers';
6
6
  import { ClassType, IdType } from '../types';
7
7
  import { EditorDescriptor, ModelDescriptor } from './';
8
8
  export declare class ActionDescriptor<T> {
9
- protected readonly _model: ModelDescriptor<T>;
9
+ protected readonly _model: ModelDescriptor<T> | null;
10
10
  protected readonly _actionName: string;
11
11
  protected readonly _parentType?: ClassType<any>;
12
12
  protected readonly _parentTypeName?: string;
13
13
  protected readonly _parentProperty?: string;
14
- protected readonly _i18nModelActionBaseKey: string;
14
+ protected readonly _i18nModelActionBaseKey?: string;
15
15
  protected _type: ActionTypeEnum;
16
16
  protected _activationTrigger: ActionActivationTriggerEnum;
17
17
  protected _position: ActionPositionEnum;
@@ -41,11 +41,11 @@ export declare class ActionDescriptor<T> {
41
41
  private _hasRunNotificationError;
42
42
  private _runNotificationErrorTitle?;
43
43
  private _runNotificationErrorMessage?;
44
- constructor(model: ModelDescriptor<T>, actionName: string, parentType?: ClassType<any>, parentProperty?: string);
45
- get model(): ModelDescriptor<T>;
44
+ constructor(model: ModelDescriptor<T> | null, actionName: string, parentType?: ClassType<any>, parentProperty?: string);
45
+ get model(): ModelDescriptor<T> | null;
46
46
  get parentTypeName(): string | undefined;
47
47
  get parentProperty(): string | undefined;
48
- get i18nModelActionBaseKey(): string;
48
+ get i18nModelActionBaseKey(): string | undefined;
49
49
  get type(): ActionTypeEnum;
50
50
  get activationTrigger(): ActionActivationTriggerEnum;
51
51
  get position(): ActionPositionEnum;
@@ -116,6 +116,9 @@ export declare namespace ActionDescriptor {
116
116
  ExtraLarge = 4
117
117
  }
118
118
  }
119
+ export declare class ActionSimpleDescriptor<T> extends ActionDescriptor<T> {
120
+ constructor(actionName: string, modelType?: ClassType<T>, idProperty?: string, titleProperty?: string);
121
+ }
119
122
  export declare class ActionEditorDescriptor<T> extends ActionDescriptor<T> {
120
123
  private readonly _editorDescriptor;
121
124
  protected _editorActions: ActionDescriptor<T>[];
@@ -166,21 +169,25 @@ export declare namespace ActionEditorSubmitDescriptor {
166
169
  }
167
170
  }
168
171
  export declare class ActionEditorDetailsDescriptor<T> extends ActionEditorDescriptor<T> {
172
+ static readonly ACTION_NAME = "details";
169
173
  constructor(editorDescriptor: EditorDescriptor<T>);
170
174
  withServiceType<S>(serviceType: Type<S>): this;
171
175
  withServiceFetchFunction<S>(serviceType: Type<S>, fetchFn?: (id: IdType, service?: S) => Observable<T>): this;
172
176
  }
173
177
  export declare class ActionEditorAddDescriptor<T> extends ActionEditorDescriptor<T> {
178
+ static readonly ACTION_NAME = "add";
174
179
  constructor(editorDescriptor: EditorDescriptor<T>);
175
180
  withServiceType<S>(serviceType: Type<S>): this;
176
181
  withServiceSubmitFunction<S>(serviceType: Type<S>, createFn?: (item?: T, service?: S) => Observable<T>, fetchFn?: (id: IdType, service?: S) => Observable<T>): this;
177
182
  }
178
183
  export declare class ActionEditorEditDescriptor<T> extends ActionEditorDescriptor<T> {
184
+ static readonly ACTION_NAME = "edit";
179
185
  constructor(editorDescriptor: EditorDescriptor<T>);
180
186
  withServiceType<S>(serviceType: Type<S>): this;
181
187
  withServiceSubmitFunction<S>(serviceType: Type<S>, updateFn?: (id: IdType, item?: T, service?: S) => Observable<T>, fetchFn?: (id: IdType, service?: S) => Observable<T>): this;
182
188
  }
183
189
  export declare class ActionDeleteDescriptor<T> extends ActionDescriptor<T> {
190
+ static readonly ACTION_NAME = "delete";
184
191
  constructor(model: ModelDescriptor<T>);
185
192
  withServiceType<S>(serviceType: Type<S>): this;
186
193
  withServiceDeleteFunction<S>(serviceType: Type<S>, deleteFn?: (id: IdType, item?: T, service?: S) => Observable<T>): this;
@@ -193,7 +200,7 @@ export declare class ActionLinkDescriptor<T> extends ActionDescriptor<T> {
193
200
  private _replaceUrl;
194
201
  private _target;
195
202
  private _isStyleLink;
196
- constructor(model: ModelDescriptor<T>);
203
+ constructor(model?: ModelDescriptor<T> | null, actionName?: string);
197
204
  get url(): string;
198
205
  get pathSegments(): string[];
199
206
  get queryParams(): Params | undefined;
@@ -5,7 +5,7 @@ import { IdType } from '../types';
5
5
  import * as i0 from "@angular/core";
6
6
  export declare class MngLinkFormatterPipe implements PipeTransform {
7
7
  private parseUrl;
8
- transform(value: string | string[], itemId?: IdType, item?: any, model?: ModelDescriptor<any>, actionData?: ActionData): any;
8
+ transform(value: string | string[], itemId?: IdType, item?: any, model?: ModelDescriptor<any> | null, actionData?: ActionData): any;
9
9
  static ɵfac: i0.ɵɵFactoryDeclaration<MngLinkFormatterPipe, never>;
10
10
  static ɵpipe: i0.ɵɵPipeDeclaration<MngLinkFormatterPipe, "linkFormatter">;
11
11
  }
@@ -7,7 +7,7 @@ import { Observable } from 'rxjs';
7
7
  import { ActionActivationResult, ActionData, ActionExecContext, ActionRunResult, ActionTriggerResult } from '../components/action/models';
8
8
  import { MngTableCellClickEvent } from '../components/tableview/models';
9
9
  import { IDataProvider, IEditorDataProvider } from '../data-providers';
10
- import { ActionDescriptor, ActionEditorDescriptor } from '../descriptors';
10
+ import { ActionDescriptor, ActionEditorDescriptor, TableDescriptor } from '../descriptors';
11
11
  import { IViewContainer, MngError } from '../models';
12
12
  import { MngLinkFormatterPipe } from '../pipes';
13
13
  import { IdType } from '../types';
@@ -85,8 +85,10 @@ export declare class MngActionExecutorService {
85
85
  * @param action Action descriptor.
86
86
  * @param event Target table click event.
87
87
  * @param route Currently activate route.
88
+ * @param tableDescriptor Table descriptor.
89
+ * @param dataKeyProperty Data key property.
88
90
  */
89
- triggerRowClickAction<T>(action: ActionDescriptor<T>, event: MngTableCellClickEvent<T>, route?: ActivatedRoute): Observable<ActionTriggerResult<T, unknown, IDataProvider<T, unknown>>>;
91
+ triggerRowClickAction<T>(action: ActionDescriptor<T>, event: MngTableCellClickEvent<T>, route?: ActivatedRoute, tableDescriptor?: TableDescriptor<T>, dataKeyProperty?: string): Observable<ActionTriggerResult<T, unknown, IDataProvider<T, unknown>>>;
90
92
  /**
91
93
  * Triggers action with optional data (item, itemId, ...) and currently activated route.
92
94
  *
@@ -13,7 +13,7 @@ export declare class MngViewContainerComponentService<T, S> implements IViewCont
13
13
  private _reloadTableSubject;
14
14
  constructor(messageService: MessageService);
15
15
  set dataProvider(dataProvider: IDataProvider<T, S>);
16
- get reloadTable$(): import("rxjs").Observable<any>;
16
+ get reloadTable(): import("rxjs").Observable<any>;
17
17
  triggerTableReload(event: any): void;
18
18
  getMessageService(): MessageService;
19
19
  getDataProvider(): IDataProvider<T, S> | undefined;
@@ -1,25 +1,56 @@
1
1
  import { TranslateService } from '@ngx-translate/core';
2
2
  import { Observable } from 'rxjs';
3
- import { ActionDescriptor, ModelDescriptor } from '../descriptors';
3
+ import { ActionDescriptor, ActionEditorDescriptor, ModelDescriptor } from '../descriptors';
4
4
  import { MngError } from '../models';
5
- export declare class I18nUtil {
6
- static instantModelTranslation(translate: TranslateService, model: ModelDescriptor<any>, keyPath: string, customKey?: string, item?: any, fallbackKey?: string, i18nParams?: any): string | null;
7
- static getModelTabKey(model: ModelDescriptor<any>, tab: string): string;
8
- static getModelGroupKey(model: ModelDescriptor<any>, group: string): string;
9
- static getModelPropertyKey(model: ModelDescriptor<any>, property: string): string;
10
- static instantActionTranslation(translate: TranslateService, action: ActionDescriptor<any>, keyPath: string, customKey?: string, item?: any, fallbackKey?: string, functionNameKey?: string, i18nParams?: any): string | null;
11
- static streamActionTranslation(translate: TranslateService, action: ActionDescriptor<any>, keyPath: string, customKey?: string, item?: any, fallbackKey?: string): Observable<string | null>;
12
- static getActionTranslation(translate: TranslateService, action: ActionDescriptor<any>, keyPath: string, customKey?: string, item?: any, fallbackKey?: string, oneTime?: boolean): Observable<string | null>;
13
- static getModelI18nParams(model: ModelDescriptor<any>, item: any, i18nModelName?: string, i18nParameters?: any): any;
14
- static getActionI18nParams(action: ActionDescriptor<any>, item: any, i18nModelName?: string, i18nParameters?: any, functionTitle?: string): any;
15
- static instantErrorI18nTranslation(translate: TranslateService, error: MngError, i18nParameters?: any): string | null;
16
- static getErrorI18nParams(error: MngError, i18nParameters?: any): any;
17
- static instantModelName(translate: TranslateService, model: ModelDescriptor<any>, singular?: boolean): string | null;
18
- static getModelName(translate: TranslateService, model: ModelDescriptor<any>, oneTime?: boolean, singular?: boolean): Observable<string | null>;
19
- static getModelNameKeys(model: ModelDescriptor<any>, singular?: boolean): string[];
20
- private static getModelKeysByPriority;
21
- private static getModelKeyPath;
22
- private static getActionKeysByPriority;
23
- private static selectKeyByPriority;
24
- private static getFunctionTitle;
5
+ import { ClassType } from '../types';
6
+ export declare namespace I18nUtils {
7
+ class Common {
8
+ static getAsync(translate: TranslateService, params?: any, ...keys: Array<string>): Observable<string | null>;
9
+ static get(translate: TranslateService, params?: any, ...keys: Array<string>): string | null;
10
+ static populateParams(item?: any, params?: any): any;
11
+ static selectI18n(keys: string[], i18n: any): string | null;
12
+ }
13
+ class Type {
14
+ static getClassNameAsync(translate: TranslateService, classType: ClassType<any>, singular?: boolean): Observable<string | null>;
15
+ static getClassName(translate: TranslateService, classType: ClassType<any>, singular?: boolean): string | null;
16
+ static getNameAsync(translate: TranslateService, typeName: string, singular?: boolean): Observable<string | null>;
17
+ static getName(translate: TranslateService, typeName: string, singular?: boolean): string | null;
18
+ static getClassTabKey(classType: ClassType<any>, tab: string): string;
19
+ static getTabKey(typeName: string, tab: string): string;
20
+ static getClassGroupKey(classType: ClassType<any>, group: string): string;
21
+ static getGroupKey(typeName: string, group: string): string;
22
+ static getClassPropertyKey(classType: ClassType<any>, property: string): string;
23
+ static getPropertyKey(typeName: string, property: string): string;
24
+ static getClassPath(classType: ClassType<any>, ...path: Array<string>): string;
25
+ static getPath(typeName: string, ...path: Array<string>): string;
26
+ static getClassParams(translate: TranslateService, classType: ClassType<any>, item: any, params?: any): any;
27
+ static getParams(translate: TranslateService, typeName?: string, item?: any, params?: any): any;
28
+ static getClassParamsAsync(translate: TranslateService, classType: ClassType<any>, item?: any, params?: any): Observable<any>;
29
+ static getParamsAsync(translate: TranslateService, typeName?: string, item?: any, params?: any): Observable<any>;
30
+ static populateParams(i18nTypeName?: string, item?: any, params?: any): any;
31
+ private static getNameKeys;
32
+ }
33
+ class Model {
34
+ static get(translate: TranslateService, model: ModelDescriptor<any>, keyPath: string, customKey?: string, item?: any, fallbackKey?: string, params?: any): string | null;
35
+ static getName(translate: TranslateService, model: ModelDescriptor<any>, singular?: boolean): string | null;
36
+ static getNameAsync(translate: TranslateService, model: ModelDescriptor<any>, singular?: boolean): Observable<string | null>;
37
+ static getParams(translate: TranslateService, model?: ModelDescriptor<any>, item?: any, params?: any): any;
38
+ static getParamsAsync(translate: TranslateService, model?: ModelDescriptor<any>, item?: any, params?: any): Observable<any>;
39
+ static populateParams(idProperty?: string, titleProperty?: string, item?: any, params?: any): any;
40
+ private static getKeysByPriority;
41
+ }
42
+ class Action {
43
+ static get(translate: TranslateService, action: ActionDescriptor<any>, actionPathKeys: string | Array<string>, customKey?: string, item?: any, fallbackKey?: string, params?: any): string | null;
44
+ static getAsync(translate: TranslateService, action: ActionDescriptor<any>, actionPathKeys: string | Array<string>, customKey?: string, item?: any, fallbackKey?: string, params?: any): Observable<string | null>;
45
+ static getTitleAsync(translate: TranslateService, action: ActionDescriptor<any>, item?: any): Observable<string | null>;
46
+ static getEditorTitleAsync(translate: TranslateService, action: ActionEditorDescriptor<any>, item?: any): Observable<string | null>;
47
+ static getParams(translate: TranslateService, action: ActionDescriptor<any>, item?: any, params?: any): any;
48
+ static getParamsAsync(translate: TranslateService, action: ActionDescriptor<any>, item?: any, params?: any): Observable<any>;
49
+ static populateParams(params?: any): any;
50
+ private static getKeysByPriority;
51
+ }
52
+ class Error {
53
+ static get(translate: TranslateService, error: MngError, params?: any): string | null;
54
+ static getParams(error: MngError, params?: any): any;
55
+ }
25
56
  }
@@ -4,8 +4,8 @@ import { ActionDescriptor, TableDescriptor } from '../descriptors';
4
4
  import { IViewContainer, MngError } from '../models';
5
5
  export declare class NotificationUtil {
6
6
  static notification(viewContainer?: IViewContainer<any, any>, title?: string, message?: string, severity?: 'success' | 'warn' | 'error'): Message;
7
- static tableNotificationError(translationService: TranslateService, table: TableDescriptor<any>, error: any, viewContainer?: IViewContainer<any, any>): Message;
8
- static actionNotificationSuccess(translationService: TranslateService, action: ActionDescriptor<any>, functionName: string, customTitleKey?: string, customMessageKey?: string, viewContainer?: IViewContainer<any, any>, item?: any): Message;
9
- static actionNotificationError(translationService: TranslateService, action: ActionDescriptor<any>, error: MngError, functionName: string, viewContainer?: IViewContainer<any, any>, item?: any): Message;
10
- static getFormEditorWarningMessage(translationService: TranslateService, title: string, message: string): Message;
7
+ static tableNotificationError(translate: TranslateService, table: TableDescriptor<any>, error: any, viewContainer?: IViewContainer<any, any>): Message;
8
+ static actionNotificationSuccess(translate: TranslateService, action: ActionDescriptor<any>, functionName: string, customTitleKey?: string, customMessageKey?: string, viewContainer?: IViewContainer<any, any>, item?: any): Message;
9
+ static actionNotificationError(translate: TranslateService, action: ActionDescriptor<any>, error: MngError, functionName: string, viewContainer?: IViewContainer<any, any>, item?: any, severity?: 'warn' | 'error'): Message;
10
+ static getFormEditorWarningMessage(translate: TranslateService, title: string, message: string): Message;
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediusinc/mng-commons",
3
- "version": "0.4.1",
3
+ "version": "0.4.4",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^13.1.0",
6
6
  "@angular/core": "^13.1.0",