@smartbit4all/ng-client 1.1.42 → 1.1.43

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Optional, Inject, PLATFORM_ID, NgModule, SkipSelf, Component, Pipe, CUSTOM_ELEMENTS_SCHEMA, ViewChild, Input } from '@angular/core';
2
+ import { InjectionToken, Injectable, Optional, Inject, PLATFORM_ID, NgModule, SkipSelf, Component, Pipe, CUSTOM_ELEMENTS_SCHEMA, Input, ViewChild } from '@angular/core';
3
3
  import { Subject, takeUntil, map, catchError, throwError, from } from 'rxjs';
4
4
  import { SmartSubject } from '@smartbit4all/subject';
5
5
  import * as i1 from '@angular/common/http';
@@ -14,25 +14,26 @@ import * as i3$1 from '@smartbit4all/navigation';
14
14
  import * as i4$1 from '@smartbit4all/dialog';
15
15
  import { SmartdialogService, SmartdialogModule } from '@smartbit4all/dialog';
16
16
  import { MatCommonModule } from '@angular/material/core';
17
+ import { BrowserModule } from '@angular/platform-browser';
18
+ import * as i2$2 from '@smartbit4all/expandable-section';
19
+ import { SmartExpandableSectionModule } from '@smartbit4all/expandable-section';
20
+ import * as i1$2 from '@smartbit4all/form';
21
+ import { SmartFormWidgetDirection, SmartFormWidgetType, SmartValidatorName, SmartformModule } from '@smartbit4all/form';
22
+ import * as i3$2 from '@smartbit4all/grid';
23
+ import { SmartLayoutDef, GridUiActionType, SmartGridModule, SmartGridComponent } from '@smartbit4all/grid';
24
+ import * as i4$4 from '@smartbit4all/tree';
25
+ import { SmarttreeModule, SmarttreeGenericService } from '@smartbit4all/tree';
17
26
  import * as i4$3 from '@angular/material/expansion';
18
27
  import { MatExpansionModule } from '@angular/material/expansion';
19
- import { BrowserModule } from '@angular/platform-browser';
20
28
  import * as i4$2 from '@smartbit4all/icon';
21
29
  import { SmartIconModule } from '@smartbit4all/icon';
22
30
  import * as i1$1 from '@angular/material/dialog';
23
31
  import * as i2$1 from '@angular/router';
24
32
  import { catchError as catchError$1, switchMap } from 'rxjs/operators';
25
- import * as i4$4 from '@angular/material/snack-bar';
33
+ import * as i4$5 from '@angular/material/snack-bar';
26
34
  import { MAT_SNACK_BAR_DATA, MatSnackBarModule } from '@angular/material/snack-bar';
27
35
  import { Validators } from '@angular/forms';
28
- import * as i1$2 from '@smartbit4all/form';
29
- import { SmartFormWidgetType, SmartValidatorName, SmartFormWidgetDirection, SmartformModule } from '@smartbit4all/form';
30
- import * as i3$2 from '@smartbit4all/grid';
31
- import { SmartLayoutDef, GridUiActionType, SmartGridModule, SmartGridComponent } from '@smartbit4all/grid';
32
- import * as i2$2 from '@smartbit4all/expandable-section';
33
- import { SmartExpandableSectionModule } from '@smartbit4all/expandable-section';
34
36
  import { __decorate, __param } from 'tslib';
35
- import { SmarttreeGenericService } from '@smartbit4all/tree';
36
37
 
37
38
  /**
38
39
  * Custom HttpParameterCodec
@@ -3441,1453 +3442,1476 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3441
3442
  }]
3442
3443
  }] });
3443
3444
 
3444
- class SmartViewContextErrorDialogService extends SmartdialogService {
3445
- constructor(dialog, router, viewContext) {
3446
- super(dialog, router);
3447
- this.viewContext = viewContext;
3448
- this.dialogRefs = [];
3445
+ /**
3446
+ * Custom HttpParameterCodec
3447
+ * Workaround for https://github.com/angular/angular/issues/18261
3448
+ */
3449
+ class CustomHttpParameterCodec {
3450
+ encodeKey(k) {
3451
+ return encodeURIComponent(k);
3449
3452
  }
3450
- handleAfterClosed(result) { }
3451
- openDialog() {
3452
- const dialogData = {
3453
- content: {
3454
- title: '',
3455
- },
3456
- size: {},
3457
- customComponent: SmartViewContextErrorDialogComponent,
3458
- };
3459
- this.dialogRefs.push(this.createDialogRef(dialogData, SmartViewContextErrorDialogComponent));
3453
+ encodeValue(v) {
3454
+ return encodeURIComponent(v);
3460
3455
  }
3461
- async closeDialog() {
3462
- let dialogRef = this.dialogRefs.pop();
3463
- dialogRef?.close();
3456
+ decodeKey(k) {
3457
+ return decodeURIComponent(k);
3464
3458
  }
3465
- async getSmartViewContextApiError() {
3466
- if (this.viewApiError?.code) {
3467
- return await this.viewContext.getSmartViewContextApiErrorByCode(this.viewApiError.code);
3459
+ decodeValue(v) {
3460
+ return decodeURIComponent(v);
3461
+ }
3462
+ }
3463
+
3464
+ const BASE_PATH = new InjectionToken('basePath');
3465
+ const COLLECTION_FORMATS = {
3466
+ 'csv': ',',
3467
+ 'tsv': ' ',
3468
+ 'ssv': ' ',
3469
+ 'pipes': '|'
3470
+ };
3471
+
3472
+ class Configuration {
3473
+ constructor(configurationParameters = {}) {
3474
+ this.apiKeys = configurationParameters.apiKeys;
3475
+ this.username = configurationParameters.username;
3476
+ this.password = configurationParameters.password;
3477
+ this.accessToken = configurationParameters.accessToken;
3478
+ this.basePath = configurationParameters.basePath;
3479
+ this.withCredentials = configurationParameters.withCredentials;
3480
+ this.encoder = configurationParameters.encoder;
3481
+ if (configurationParameters.encodeParam) {
3482
+ this.encodeParam = configurationParameters.encodeParam;
3468
3483
  }
3469
- let dialogTitle;
3470
- let buttonLabel;
3471
- let message;
3472
- if (this.viewContext.translateService) {
3473
- dialogTitle = await this.viewContext.translateService
3474
- .get(SmartViewContextErrorDialogTitle)
3475
- .toPromise();
3476
- buttonLabel = await this.viewContext.translateService
3477
- .get(SmartViewContextErrorDialogButtonLabel)
3478
- .toPromise();
3479
- message = await this.viewContext.translateService
3480
- .get(SmartViewContextErrorDialogMessage)
3481
- .toPromise();
3484
+ else {
3485
+ this.encodeParam = param => this.defaultEncodeParam(param);
3486
+ }
3487
+ if (configurationParameters.credentials) {
3488
+ this.credentials = configurationParameters.credentials;
3482
3489
  }
3483
3490
  else {
3484
- buttonLabel = 'Ok';
3485
- dialogTitle = 'Hiba';
3486
- message = 'An error has occured.';
3491
+ this.credentials = {};
3487
3492
  }
3488
- return {
3489
- code: this.viewApiError?.code ?? '',
3490
- message: this.viewApiError?.message ?? message,
3491
- buttonLabel,
3492
- dialogTitle,
3493
- };
3494
3493
  }
3495
- }
3496
- SmartViewContextErrorDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }, { token: SmartViewContextService }], target: i0.ɵɵFactoryTarget.Injectable });
3497
- SmartViewContextErrorDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogService, providedIn: 'root' });
3498
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogService, decorators: [{
3499
- type: Injectable,
3500
- args: [{
3501
- providedIn: 'root',
3502
- }]
3503
- }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }, { type: SmartViewContextService }]; } });
3504
-
3505
- class SmartViewContextErrorDialogComponent {
3506
- constructor(service) {
3507
- this.service = service;
3508
- this.service
3509
- .getSmartViewContextApiError()
3510
- .then((smartViewContextApiError) => {
3511
- this.smartViewContextApiError = smartViewContextApiError;
3512
- });
3494
+ /**
3495
+ * Select the correct content-type to use for a request.
3496
+ * Uses {@link Configuration#isJsonMime} to determine the correct content-type.
3497
+ * If no content type is found return the first found type if the contentTypes is not empty
3498
+ * @param contentTypes - the array of content types that are available for selection
3499
+ * @returns the selected content-type or <code>undefined</code> if no selection could be made.
3500
+ */
3501
+ selectHeaderContentType(contentTypes) {
3502
+ if (contentTypes.length === 0) {
3503
+ return undefined;
3504
+ }
3505
+ const type = contentTypes.find((x) => this.isJsonMime(x));
3506
+ if (type === undefined) {
3507
+ return contentTypes[0];
3508
+ }
3509
+ return type;
3513
3510
  }
3514
- ngOnInit() { }
3515
- onActionClick() {
3516
- if (this.smartViewContextApiError?.customAction) {
3517
- this.smartViewContextApiError.customAction();
3511
+ /**
3512
+ * Select the correct accept content-type to use for a request.
3513
+ * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
3514
+ * If no content type is found return the first found type if the contentTypes is not empty
3515
+ * @param accepts - the array of content types that are available for selection.
3516
+ * @returns the selected content-type or <code>undefined</code> if no selection could be made.
3517
+ */
3518
+ selectHeaderAccept(accepts) {
3519
+ if (accepts.length === 0) {
3520
+ return undefined;
3518
3521
  }
3519
- this.service.closeDialog();
3522
+ const type = accepts.find((x) => this.isJsonMime(x));
3523
+ if (type === undefined) {
3524
+ return accepts[0];
3525
+ }
3526
+ return type;
3520
3527
  }
3521
- }
3522
- SmartViewContextErrorDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogComponent, deps: [{ token: SmartViewContextErrorDialogService }], target: i0.ɵɵFactoryTarget.Component });
3523
- SmartViewContextErrorDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartViewContextErrorDialogComponent, selector: "lib-smart-view-context-error-dialog", ngImport: i0, template: "<div *ngIf=\"smartViewContextApiError\" class=\"container\">\n <h3 class=\"color-accent-700\">\n {{ smartViewContextApiError.dialogTitle }}\n </h3>\n <div class=\"content\">\n <p>\n {{ smartViewContextApiError.message }}\n </p>\n </div>\n <div class=\"buttonContainer\">\n <button mat-raised-button color=\"primary\" (click)=\"onActionClick()\">\n {{ smartViewContextApiError.buttonLabel }}\n </button>\n </div>\n</div>\n", styles: [".container{display:flex;flex-direction:column;gap:1em;min-width:25rem;max-width:50vw;height:auto;max-height:75vh}.content{flex:1;overflow:auto}.buttonContainer{display:flex;flex-direction:row;justify-content:flex-end}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3524
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogComponent, decorators: [{
3525
- type: Component,
3526
- args: [{ selector: 'lib-smart-view-context-error-dialog', template: "<div *ngIf=\"smartViewContextApiError\" class=\"container\">\n <h3 class=\"color-accent-700\">\n {{ smartViewContextApiError.dialogTitle }}\n </h3>\n <div class=\"content\">\n <p>\n {{ smartViewContextApiError.message }}\n </p>\n </div>\n <div class=\"buttonContainer\">\n <button mat-raised-button color=\"primary\" (click)=\"onActionClick()\">\n {{ smartViewContextApiError.buttonLabel }}\n </button>\n </div>\n</div>\n", styles: [".container{display:flex;flex-direction:column;gap:1em;min-width:25rem;max-width:50vw;height:auto;max-height:75vh}.content{flex:1;overflow:auto}.buttonContainer{display:flex;flex-direction:row;justify-content:flex-end}\n"] }]
3527
- }], ctorParameters: function () { return [{ type: SmartViewContextErrorDialogService }]; } });
3528
-
3529
- class SmartViewContextInterceptor {
3530
- constructor(viewContextErrorDialog) {
3531
- this.viewContextErrorDialog = viewContextErrorDialog;
3528
+ /**
3529
+ * Check if the given MIME is a JSON MIME.
3530
+ * JSON MIME examples:
3531
+ * application/json
3532
+ * application/json; charset=UTF8
3533
+ * APPLICATION/JSON
3534
+ * application/vnd.company+json
3535
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
3536
+ * @return True if the given MIME is JSON, false otherwise.
3537
+ */
3538
+ isJsonMime(mime) {
3539
+ const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
3540
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
3532
3541
  }
3533
- intercept(request, next) {
3534
- // parameter: async: True -> don't throw/open error (dialog)
3535
- if (request.body) {
3536
- try {
3537
- let body = request.body;
3538
- if (body.params[IS_ASYNC_PARAM_NAME]) {
3539
- return next.handle(request);
3540
- }
3541
- }
3542
- catch (error) { }
3543
- }
3544
- return next.handle(request).pipe(catchError((error) => {
3545
- if (error.status === 409 &&
3546
- (error.error.code || error.error.message)) {
3547
- this.openErrorDialog(error.error);
3548
- }
3549
- return throwError(error);
3550
- }));
3542
+ lookupCredential(key) {
3543
+ const value = this.credentials[key];
3544
+ return typeof value === 'function'
3545
+ ? value()
3546
+ : value;
3551
3547
  }
3552
- openErrorDialog(viewApiError) {
3553
- this.viewContextErrorDialog.viewApiError = viewApiError;
3554
- this.viewContextErrorDialog.openDialog();
3548
+ defaultEncodeParam(param) {
3549
+ // This implementation exists as fallback for missing configuration
3550
+ // and for backwards compatibility to older typescript-angular generator versions.
3551
+ // It only works for the 'simple' parameter style.
3552
+ // Date-handling only works for the 'date-time' format.
3553
+ // All other styles and Date-formats are probably handled incorrectly.
3554
+ //
3555
+ // But: if that's all you need (i.e.: the most common use-case): no need for customization!
3556
+ const value = param.dataFormat === 'date-time' && param.value instanceof Date
3557
+ ? param.value.toISOString()
3558
+ : param.value;
3559
+ return encodeURIComponent(String(value));
3555
3560
  }
3556
3561
  }
3557
- SmartViewContextInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextInterceptor, deps: [{ token: SmartViewContextErrorDialogService }], target: i0.ɵɵFactoryTarget.Injectable });
3558
- SmartViewContextInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextInterceptor });
3559
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextInterceptor, decorators: [{
3560
- type: Injectable
3561
- }], ctorParameters: function () { return [{ type: SmartViewContextErrorDialogService }]; } });
3562
3562
 
3563
- class SmartViewRedirect {
3564
- constructor(service, navigation, route) {
3565
- this.service = service;
3566
- this.navigation = navigation;
3567
- this.route = route;
3568
- this.navigation.route = this.route;
3569
- this.navigation.subscribeToUrlChange((url) => {
3570
- let channel = this.route.snapshot.paramMap.get(SmartLinkChannelVariableInPath);
3571
- let uuid = this.route.snapshot.paramMap.get(SmartLinkUuidVariableInPath);
3572
- if (!channel || !uuid) {
3573
- throw new Error("channel or uuid is not reachable from the url!");
3563
+ /**
3564
+ * Form layout definition
3565
+ * Contains form layout definition objects.
3566
+ *
3567
+ * The version of the OpenAPI document: 1.0.0
3568
+ * Contact: info@it4all.hu
3569
+ *
3570
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
3571
+ * https://openapi-generator.tech
3572
+ * Do not edit the class manually.
3573
+ */
3574
+ class DefaultService {
3575
+ constructor(httpClient, basePath, configuration) {
3576
+ this.httpClient = httpClient;
3577
+ this.basePath = 'http://localhost';
3578
+ this.defaultHeaders = new HttpHeaders();
3579
+ this.configuration = new Configuration();
3580
+ if (configuration) {
3581
+ this.configuration = configuration;
3582
+ }
3583
+ if (typeof this.configuration.basePath !== 'string') {
3584
+ if (Array.isArray(basePath) && basePath.length > 0) {
3585
+ basePath = basePath[0];
3574
3586
  }
3575
- this.service.showPublishedView(channel, uuid);
3576
- });
3577
- }
3578
- }
3579
- SmartViewRedirect.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewRedirect, deps: [{ token: SmartViewContextService }, { token: i3$1.SmartNavigationService }, { token: i2$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component });
3580
- SmartViewRedirect.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartViewRedirect, selector: "app-redirect", ngImport: i0, template: "<div>Smart redirect</div>", isInline: true });
3581
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewRedirect, decorators: [{
3582
- type: Component,
3583
- args: [{
3584
- selector: "app-redirect",
3585
- template: "<div>Smart redirect</div>",
3586
- }]
3587
- }], ctorParameters: function () { return [{ type: SmartViewContextService }, { type: i3$1.SmartNavigationService }, { type: i2$1.ActivatedRoute }]; } });
3588
- const SmartLinkChannelVariableInPath = "channel";
3589
- const SmartLinkUuidVariableInPath = "uuid";
3590
-
3591
- class UiActionDescriptorService {
3592
- constructor(viewContext) {
3593
- this.viewContext = viewContext;
3594
- this._destroy$ = new Subject();
3595
- this.languageChanged = new SmartSubject(this._destroy$);
3596
- this.keysToTranslate = ['title', 'text', 'placeholder', 'caption', 'feedbackText'];
3597
- this.basicActionDescriptors = new Map([
3598
- [
3599
- 'UNKOWN',
3600
- {
3601
- title: '',
3602
- type: UiActionButtonType.Normal,
3603
- color: 'accent',
3604
- icon: 'Question',
3605
- iconColor: `text-primary`,
3606
- iconPosition: UiActionButtonIconPos.Post,
3607
- dialog: {
3608
- title: '',
3609
- placeholder: 'placeholder',
3610
- actionButton: {
3611
- caption: '',
3612
- color: 'accent',
3613
- },
3614
- cancelButton: {
3615
- caption: 'Mégse',
3616
- color: '',
3617
- },
3618
- },
3619
- },
3620
- ],
3621
- ]);
3622
- if (this.viewContext.translateService) {
3623
- this.subscribeToTranslateService();
3587
+ if (typeof basePath !== 'string') {
3588
+ basePath = this.basePath;
3589
+ }
3590
+ this.configuration.basePath = basePath;
3591
+ }
3592
+ this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
3593
+ }
3594
+ // @ts-ignore
3595
+ addToHttpParams(httpParams, value, key) {
3596
+ if (typeof value === "object" && value instanceof Date === false) {
3597
+ httpParams = this.addToHttpParamsRecursive(httpParams, value);
3624
3598
  }
3625
3599
  else {
3626
- this.viewContext.translateServiceChanged.pipe(takeUntil(this._destroy$)).subscribe(() => {
3627
- this.subscribeToTranslateService();
3628
- });
3600
+ httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
3629
3601
  }
3602
+ return httpParams;
3630
3603
  }
3631
- ngOnDestroy() {
3632
- this._destroy$.next();
3633
- this._destroy$.complete();
3634
- }
3635
- subscribeToTranslateService() {
3636
- this.viewContext
3637
- .translateService.onLangChange.pipe(takeUntil(this._destroy$))
3638
- .subscribe(() => {
3639
- this.languageChanged.next();
3640
- });
3641
- }
3642
- async getActionDescriptor(uiAction) {
3643
- let code = uiAction.code;
3644
- let actionDescriptorFromDescriptors = this.viewContext.getActionDescriptors()?.get(code);
3645
- let isUnkown = false;
3646
- let actionDescriptor;
3647
- if (actionDescriptorFromDescriptors) {
3648
- actionDescriptor = JSON.parse(JSON.stringify(actionDescriptorFromDescriptors));
3649
- }
3650
- if (!actionDescriptor) {
3651
- isUnkown = true;
3652
- let unkownActionDescriptor = this.basicActionDescriptors.get('UNKOWN');
3653
- actionDescriptor = { ...unkownActionDescriptor };
3654
- actionDescriptor.title = code;
3604
+ addToHttpParamsRecursive(httpParams, value, key) {
3605
+ if (value == null) {
3606
+ return httpParams;
3655
3607
  }
3656
- if (!actionDescriptor.dialog) {
3657
- actionDescriptor = this.setUpUnkownDialogDescriptor(code, actionDescriptor, 'dialog');
3608
+ if (typeof value === "object") {
3609
+ if (Array.isArray(value)) {
3610
+ value.forEach(elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
3611
+ }
3612
+ else if (value instanceof Date) {
3613
+ if (key != null) {
3614
+ httpParams = httpParams.append(key, value.toISOString().substr(0, 10));
3615
+ }
3616
+ else {
3617
+ throw Error("key may not be null if value is Date");
3618
+ }
3619
+ }
3620
+ else {
3621
+ Object.keys(value).forEach(k => httpParams = this.addToHttpParamsRecursive(httpParams, value[k], key != null ? `${key}.${k}` : k));
3622
+ }
3658
3623
  }
3659
- if (!actionDescriptor.feedbackType && uiAction.submit) {
3660
- actionDescriptor.feedbackType = UiActionFeedbackType.Snackbar;
3624
+ else if (key != null) {
3625
+ httpParams = httpParams.append(key, value);
3661
3626
  }
3662
- if (this.viewContext.translateService && actionDescriptor && !isUnkown) {
3663
- actionDescriptor = await this.translateUiActionDescriptor(actionDescriptor);
3627
+ else {
3628
+ throw Error("key may not be null if value is not object or array");
3664
3629
  }
3665
- return actionDescriptor;
3666
- }
3667
- async translateUiActionDescriptor(uiActionDescriptor) {
3668
- uiActionDescriptor = await this.deepTranslate(uiActionDescriptor);
3669
- return uiActionDescriptor;
3630
+ return httpParams;
3670
3631
  }
3671
- async deepTranslate(_model) {
3672
- let model = { ..._model };
3673
- await Promise.all(Object.keys(model).map(async (key) => {
3674
- if (model[key] !== undefined &&
3675
- typeof model[key] === 'string' &&
3676
- model[key].length &&
3677
- this.keysToTranslate.includes(key)) {
3678
- model[key] = await this.viewContext.translateService.get(model[key]).toPromise();
3679
- }
3680
- else if (model[key] !== undefined && typeof model[key] === 'object') {
3681
- model[key] = await this.deepTranslate(model[key]);
3632
+ nopePost(observe = 'body', reportProgress = false, options) {
3633
+ let localVarHeaders = this.defaultHeaders;
3634
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
3635
+ if (localVarHttpHeaderAcceptSelected === undefined) {
3636
+ // to determine the Accept header
3637
+ const httpHeaderAccepts = [];
3638
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
3639
+ }
3640
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
3641
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
3642
+ }
3643
+ let localVarHttpContext = options && options.context;
3644
+ if (localVarHttpContext === undefined) {
3645
+ localVarHttpContext = new HttpContext();
3646
+ }
3647
+ let responseType_ = 'json';
3648
+ if (localVarHttpHeaderAcceptSelected) {
3649
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
3650
+ responseType_ = 'text';
3682
3651
  }
3683
- return model;
3684
- }));
3685
- return model;
3686
- }
3687
- setUpUnkownDialogDescriptor(code, uiActionDescriptor, dialogType) {
3688
- let unkownDescriptor = this.basicActionDescriptors.get('UNKOWN');
3689
- uiActionDescriptor[dialogType] = unkownDescriptor.dialog;
3690
- uiActionDescriptor[dialogType].title = code;
3691
- uiActionDescriptor[dialogType].actionButton.caption = code;
3692
- return uiActionDescriptor;
3693
- }
3694
- }
3695
- UiActionDescriptorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionDescriptorService, deps: [{ token: SmartViewContextService }], target: i0.ɵɵFactoryTarget.Injectable });
3696
- UiActionDescriptorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionDescriptorService, providedIn: 'root' });
3697
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionDescriptorService, decorators: [{
3698
- type: Injectable,
3699
- args: [{
3700
- providedIn: 'root',
3701
- }]
3702
- }], ctorParameters: function () { return [{ type: SmartViewContextService }]; } });
3703
-
3704
- class SuccessSnackBarComponent {
3705
- constructor(data, viewContext, manager) {
3706
- this.data = data;
3707
- this.viewContext = viewContext;
3708
- this.manager = manager;
3709
- this.manager.getActionDescriptor(data).then((descriptor) => {
3710
- if (descriptor.feedbackText) {
3711
- this.text = descriptor.feedbackText;
3652
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
3653
+ responseType_ = 'json';
3712
3654
  }
3713
3655
  else {
3714
- this.text = this.viewContext.commonFeedbackText ?? "A mentés sikeres volt!";
3656
+ responseType_ = 'blob';
3715
3657
  }
3658
+ }
3659
+ let localVarPath = `/nope`;
3660
+ return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, {
3661
+ context: localVarHttpContext,
3662
+ responseType: responseType_,
3663
+ withCredentials: this.configuration.withCredentials,
3664
+ headers: localVarHeaders,
3665
+ observe: observe,
3666
+ reportProgress: reportProgress
3716
3667
  });
3717
3668
  }
3718
3669
  }
3719
- SuccessSnackBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SuccessSnackBarComponent, deps: [{ token: MAT_SNACK_BAR_DATA }, { token: SmartViewContextService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
3720
- SuccessSnackBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SuccessSnackBarComponent, selector: "app-success-snack-bar", ngImport: i0, template: "<span class=\"successSnakBarContainer\" matSnackBarLabel> {{ text }} </span>\n", styles: ["::ng-deep .mat-snack-bar-container{text-align:center;border-radius:2rem}.successSnakBarContainer{color:#fff}\n"] });
3721
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SuccessSnackBarComponent, decorators: [{
3722
- type: Component,
3723
- args: [{ selector: "app-success-snack-bar", template: "<span class=\"successSnakBarContainer\" matSnackBarLabel> {{ text }} </span>\n", styles: ["::ng-deep .mat-snack-bar-container{text-align:center;border-radius:2rem}.successSnakBarContainer{color:#fff}\n"] }]
3724
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
3670
+ DefaultService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DefaultService, deps: [{ token: i1.HttpClient }, { token: BASE_PATH, optional: true }, { token: Configuration, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
3671
+ DefaultService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DefaultService, providedIn: 'root' });
3672
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DefaultService, decorators: [{
3673
+ type: Injectable,
3674
+ args: [{
3675
+ providedIn: 'root'
3676
+ }]
3677
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
3678
+ type: Optional
3679
+ }, {
3725
3680
  type: Inject,
3726
- args: [MAT_SNACK_BAR_DATA]
3727
- }] }, { type: SmartViewContextService }, { type: UiActionDescriptorService }]; } });
3681
+ args: [BASE_PATH]
3682
+ }] }, { type: Configuration, decorators: [{
3683
+ type: Optional
3684
+ }] }]; } });
3728
3685
 
3729
- class UiActionConfirmDialogComponent {
3730
- constructor(service, manager) {
3731
- this.service = service;
3732
- this.manager = manager;
3733
- this.code = this.service.action.code;
3734
- this.setUp();
3735
- }
3736
- async setUp() {
3737
- this.descriptor = await this.manager.getActionDescriptor(this.service.action);
3738
- this.dialogType = this.descriptor.confirmDialog ? "confirmDialog" : "dialog";
3739
- }
3740
- ngOnDestroy() {
3741
- this.service._destroy$.next();
3742
- this.cancel();
3743
- }
3744
- getTitle() {
3745
- return this.descriptor[this.dialogType].title;
3746
- }
3747
- getText() {
3748
- return this.descriptor[this.dialogType].text ?? "";
3749
- }
3750
- getActionButtonLabel() {
3751
- return this.descriptor[this.dialogType].actionButton.caption;
3752
- }
3753
- getActionButtonColor() {
3754
- return this.descriptor[this.dialogType].actionButton.color;
3755
- }
3756
- getCancelButtonLabel() {
3757
- return this.descriptor[this.dialogType].cancelButton.caption;
3758
- }
3759
- getCancelButtonColor() {
3760
- return this.descriptor[this.dialogType].cancelButton.color;
3761
- }
3762
- doAction() {
3763
- this.service.doAction();
3764
- }
3765
- cancel() {
3766
- this.service.cancel();
3767
- }
3768
- }
3769
- UiActionConfirmDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogComponent, deps: [{ token: UiActionConfirmDialogService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
3770
- UiActionConfirmDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionConfirmDialogComponent, selector: "app-ui-action-confirm-dialog", ngImport: i0, template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"doAction()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$2.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }] });
3771
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogComponent, decorators: [{
3772
- type: Component,
3773
- args: [{ selector: "app-ui-action-confirm-dialog", template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"doAction()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"] }]
3774
- }], ctorParameters: function () { return [{ type: UiActionConfirmDialogService }, { type: UiActionDescriptorService }]; } });
3686
+ const APIS = [DefaultService];
3775
3687
 
3776
- class UiActionConfirmDialogService extends SmartdialogService {
3777
- constructor(dialog, router) {
3778
- super(dialog, router);
3779
- this._destroy$ = new Subject();
3780
- this.onAction = new SmartSubject(this._destroy$);
3781
- this.shouldDoAction = false;
3688
+ /**
3689
+ * Form layout definition
3690
+ * Contains form layout definition objects.
3691
+ *
3692
+ * The version of the OpenAPI document: 1.0.0
3693
+ * Contact: info@it4all.hu
3694
+ *
3695
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
3696
+ * https://openapi-generator.tech
3697
+ * Do not edit the class manually.
3698
+ */
3699
+ const ComponentType = {
3700
+ Container: 'container',
3701
+ Form: 'form',
3702
+ Widget: 'widget'
3703
+ };
3704
+
3705
+ /**
3706
+ * Form layout definition
3707
+ * Contains form layout definition objects.
3708
+ *
3709
+ * The version of the OpenAPI document: 1.0.0
3710
+ * Contact: info@it4all.hu
3711
+ *
3712
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
3713
+ * https://openapi-generator.tech
3714
+ * Do not edit the class manually.
3715
+ */
3716
+ const ComponentWidgetType = {
3717
+ Grid: 'grid',
3718
+ Filter: 'filter',
3719
+ Tree: 'tree'
3720
+ };
3721
+
3722
+ /**
3723
+ * Form layout definition
3724
+ * Contains form layout definition objects.
3725
+ *
3726
+ * The version of the OpenAPI document: 1.0.0
3727
+ * Contact: info@it4all.hu
3728
+ *
3729
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
3730
+ * https://openapi-generator.tech
3731
+ * Do not edit the class manually.
3732
+ */
3733
+ const LayoutDirection = {
3734
+ Horizontal: 'horizontal',
3735
+ Vertical: 'vertical'
3736
+ };
3737
+
3738
+ class ApiModule {
3739
+ constructor(parentModule, http) {
3740
+ if (parentModule) {
3741
+ throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
3742
+ }
3743
+ if (!http) {
3744
+ throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
3745
+ 'See also https://github.com/angular/angular/issues/20575');
3746
+ }
3782
3747
  }
3783
- openDialog() {
3784
- this.shouldDoAction = false;
3785
- this.onAction = new SmartSubject(this._destroy$);
3786
- const dialogData = {
3787
- content: {
3788
- title: '',
3789
- },
3790
- size: {},
3791
- customComponent: UiActionConfirmDialogComponent,
3748
+ static forRoot(configurationFactory) {
3749
+ return {
3750
+ ngModule: ApiModule,
3751
+ providers: [{ provide: Configuration, useFactory: configurationFactory }]
3792
3752
  };
3793
- this.createDialog(dialogData, UiActionConfirmDialogComponent);
3794
- }
3795
- doAction() {
3796
- this.shouldDoAction = true;
3797
- this.onAction.complete();
3798
- this.closeDialog();
3799
- this.onAction = new SmartSubject(this._destroy$);
3800
- }
3801
- cancel() {
3802
- this.onAction.complete();
3803
- this.closeDialog();
3804
- this.onAction = new SmartSubject(this._destroy$);
3805
3753
  }
3806
3754
  }
3807
- UiActionConfirmDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
3808
- UiActionConfirmDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogService, providedIn: 'root' });
3809
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogService, decorators: [{
3810
- type: Injectable,
3755
+ ApiModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiModule, deps: [{ token: ApiModule, optional: true, skipSelf: true }, { token: i1.HttpClient, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
3756
+ ApiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiModule });
3757
+ ApiModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiModule, providers: [], imports: [[]] });
3758
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiModule, decorators: [{
3759
+ type: NgModule,
3811
3760
  args: [{
3812
- providedIn: 'root',
3761
+ imports: [],
3762
+ declarations: [],
3763
+ exports: [],
3764
+ providers: []
3813
3765
  }]
3814
- }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }]; } });
3766
+ }], ctorParameters: function () { return [{ type: ApiModule, decorators: [{
3767
+ type: Optional
3768
+ }, {
3769
+ type: SkipSelf
3770
+ }] }, { type: i1.HttpClient, decorators: [{
3771
+ type: Optional
3772
+ }] }]; } });
3815
3773
 
3816
- class UiActionInputDialogComponent {
3817
- constructor(service, manager) {
3818
- this.service = service;
3819
- this.manager = manager;
3820
- this.code = this.service.action.code;
3821
- this.setUp();
3822
- }
3823
- ngOnDestroy() {
3824
- this.service._destroy$.next();
3825
- this.cancel();
3774
+ // import { SmartFilter, SmartFilterComponent } from '@smartbit4all/filter';
3775
+ class SmartComponentLayoutComponent {
3776
+ constructor(layoutService) {
3777
+ this.layoutService = layoutService;
3826
3778
  }
3827
- async setUp() {
3828
- this.descriptor = await this.manager.getActionDescriptor(this.service.action);
3829
- if (this.descriptor[this.service.inputTypeName]) {
3830
- this.dialogType = this.service.inputTypeName;
3831
- }
3832
- else {
3833
- this.dialogType = this.descriptor.inputDialog ? 'inputDialog' : 'dialog';
3779
+ ngOnInit() {
3780
+ if (this.smartComponentLayout) {
3781
+ this.setUp();
3834
3782
  }
3835
- this.constructForm();
3836
3783
  }
3837
- getTitle() {
3838
- return this.descriptor[this.dialogType].title;
3839
- }
3840
- getText() {
3841
- return this.descriptor[this.dialogType].text ?? '';
3842
- }
3843
- getActionButtonLabel() {
3844
- return this.descriptor[this.dialogType].actionButton.caption;
3784
+ ngOnChanges(changes) {
3785
+ this.smartComponentLayout = changes['smartComponentLayout'].currentValue;
3786
+ if (this.smartComponentLayout) {
3787
+ this.setUp();
3788
+ }
3845
3789
  }
3846
- getActionButtonColor() {
3847
- return this.descriptor[this.dialogType].actionButton.color;
3790
+ setUp() {
3791
+ this.parent = this.smartComponentLayout?.parentComponent;
3792
+ this.uuid = this.parent.uuid;
3793
+ this.treeService = this.parent.smartTreeService;
3794
+ if (this.smartComponentLayout?.expandable) {
3795
+ this.constructExpandableSection();
3796
+ }
3797
+ else if (this.smartComponentLayout?.type === ComponentType.Form) {
3798
+ this.constructForm();
3799
+ }
3800
+ else if (this.smartComponentLayout?.type === ComponentType.Widget) {
3801
+ if (this.smartComponentLayout.widget?.type === ComponentWidgetType.Grid) {
3802
+ this.constructGrid();
3803
+ }
3804
+ else if (this.smartComponentLayout.widget?.type === ComponentWidgetType.Filter) {
3805
+ this.constructFilter();
3806
+ }
3807
+ else if (this.smartComponentLayout.widget?.type === ComponentWidgetType.Tree) {
3808
+ this.constructTree();
3809
+ }
3810
+ }
3848
3811
  }
3849
- getCancelButtonLabel() {
3850
- return this.descriptor[this.dialogType].cancelButton.caption;
3812
+ type() {
3813
+ return ComponentType;
3851
3814
  }
3852
- getCancelButtonColor() {
3853
- return this.descriptor[this.dialogType].cancelButton.color;
3815
+ constructExpandableSection() {
3816
+ let data = { ...this.smartComponentLayout };
3817
+ data.expandable = false;
3818
+ this.expandableSection = {
3819
+ title: this.smartComponentLayout?.expandableSectionLabel ?? '',
3820
+ data,
3821
+ inputName: 'smartComponentLayout',
3822
+ customComponent: SmartComponentLayoutComponent,
3823
+ };
3854
3824
  }
3855
3825
  constructForm() {
3856
- let model = {};
3857
- let inputName;
3858
- if (this.service.inputTypeName === 'inputDialog') {
3859
- inputName = 'input';
3860
- }
3861
- else {
3862
- inputName = 'input2';
3863
- }
3864
- if (this.service.nodeName) {
3865
- model[inputName] = this.service.nodeName;
3866
- }
3867
- else {
3868
- model[inputName] = '';
3869
- }
3870
- let type;
3871
- let inputType = `${inputName}Type`;
3872
- if (this.service.action[inputType] === UiActionInputType.Textfield) {
3873
- type = SmartFormWidgetType.TEXT_FIELD;
3874
- }
3875
- else {
3876
- type = SmartFormWidgetType.TEXT_BOX;
3877
- }
3878
- let widgets = [
3879
- {
3880
- key: inputName,
3881
- label: '',
3882
- type,
3883
- value: '',
3884
- validators: [
3885
- {
3886
- validator: Validators.required,
3887
- name: SmartValidatorName.required,
3888
- errorMessage: 'Ez a mező kötelező',
3889
- },
3890
- ],
3891
- placeholder: this.descriptor[this.dialogType].placeholder ?? '',
3892
- showLabel: true,
3893
- },
3894
- ];
3895
- if (widgets[0].type === SmartFormWidgetType.TEXT_FIELD && this.descriptor[this.dialogType]?.mask) {
3896
- widgets[0].mask = this.descriptor[this.dialogType]?.mask;
3897
- }
3898
- this.folderForm = {
3826
+ const widgets = this.layoutService.render({
3827
+ layoutDefinitions: this.smartComponentLayout?.form,
3828
+ });
3829
+ this.smartForm = {
3899
3830
  direction: SmartFormWidgetDirection.COL,
3900
- model,
3831
+ model: this.parent?.model,
3832
+ constraints: this.parent?.model?.constraints,
3901
3833
  widgets,
3902
3834
  };
3835
+ this.parent?.addForm(
3836
+ // unique identifier for the form
3837
+ `form_${this.makeid(5)}`, this.smartForm, this.formChild);
3903
3838
  }
3904
- save() {
3905
- let form = this.folderFormChild.submitForm();
3906
- if (form.invalidFields) {
3907
- throw new Error('The form is invalid!');
3839
+ makeid(length) {
3840
+ let result = '';
3841
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
3842
+ const charactersLength = characters.length;
3843
+ let counter = 0;
3844
+ while (counter < length) {
3845
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
3846
+ counter += 1;
3908
3847
  }
3909
- this.service.onSave(form.model);
3848
+ return result;
3910
3849
  }
3911
- cancel() {
3912
- this.service.cancel();
3850
+ constructGrid() {
3851
+ this.smartGrid = {
3852
+ gridIdentifier: this.smartComponentLayout?.widget?.gridIdentifier,
3853
+ gridModel: {
3854
+ page: {},
3855
+ },
3856
+ layoutDef: SmartLayoutDef.TABLE,
3857
+ };
3858
+ this.smartGrid = this.parent?.addGrid(this.smartGrid, {
3859
+ rowUiActionType: GridUiActionType.POPUP_MENU,
3860
+ }, false, this.gridChild);
3861
+ }
3862
+ constructFilter() {
3863
+ // this.smartFilter = (this.smartComponentLayout!.parentComponent as any).addFilter(
3864
+ // `filter_${this.makeid(5)}`,
3865
+ // this.smartComponentLayout?.widget?.filterExpressionFieldList,
3866
+ // this.smartComponentLayout?.widget?.filterType,
3867
+ // this.filterChild
3868
+ // );
3869
+ }
3870
+ constructTree() {
3871
+ this.parent.setUpDefaultTree(this.smartComponentLayout?.widget?.treeIdentifier);
3872
+ this.treeService?.initialize();
3913
3873
  }
3914
3874
  }
3915
- UiActionInputDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogComponent, deps: [{ token: UiActionInputDialogService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
3916
- UiActionInputDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionInputDialogComponent, selector: "smart-ui-action-input-dialog", viewQueries: [{ propertyName: "folderFormChild", first: true, predicate: ["form"], descendants: true }], ngImport: i0, template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<smartform #form [smartForm]=\"folderForm\"></smartform>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"save()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$2.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }, { type: i1$2.SmartformComponent, selector: "smartform", inputs: ["smartForm"] }] });
3917
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogComponent, decorators: [{
3875
+ SmartComponentLayoutComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartComponentLayoutComponent, deps: [{ token: i1$2.SmartformLayoutDefinitionService }], target: i0.ɵɵFactoryTarget.Component });
3876
+ SmartComponentLayoutComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartComponentLayoutComponent, selector: "smart-component-layout", inputs: { smartComponentLayout: "smartComponentLayout" }, viewQueries: [{ propertyName: "formChild", first: true, predicate: ["form"], descendants: true }, { propertyName: "gridChild", first: true, predicate: ["grid"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div *ngIf=\"smartComponentLayout?.expandable; then expandable; else normal\"> </div>\n\n<ng-template #expandable>\n <smart-expandable-section\n *ngIf=\"expandableSection\"\n [data]=\"expandableSection\"\n ></smart-expandable-section>\n</ng-template>\n\n<ng-template #normal>\n <div\n *ngIf=\"smartComponentLayout?.type === type().Container\"\n [ngClass]=\"smartComponentLayout?.direction ?? 'vertical'\"\n >\n <smart-component-layout\n [smartComponentLayout]=\"layout\"\n *ngFor=\"let layout of smartComponentLayout?.components\"\n ></smart-component-layout>\n </div>\n <smartform #form [smartForm]=\"smartForm\"></smartform>\n <smart-grid #grid [smartGrid]=\"smartGrid\" [uuid]=\"uuid!\"></smart-grid>\n <!-- <smart-filter #filter [filter]=\"smartFilter\"></smart-filter> -->\n <smart-tree [treeService]=\"treeService!\"></smart-tree>\n</ng-template>\n", styles: [".horizontal{display:flex;flex-direction:row}.vertical{display:flex;flex-direction:column}\n"], components: [{ type: i2$2.ExpandableSectionComponent, selector: "smart-expandable-section", inputs: ["data", "index"] }, { type: SmartComponentLayoutComponent, selector: "smart-component-layout", inputs: ["smartComponentLayout"] }, { type: i1$2.SmartformComponent, selector: "smartform", inputs: ["smartForm"] }, { type: i3$2.SmartGridComponent, selector: "smart-grid", inputs: ["smartGrid", "uuid", "dev"] }, { type: i4$4.SmartTreeComponent, selector: "smart-tree", inputs: ["treeStyle", "treeService"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
3877
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartComponentLayoutComponent, decorators: [{
3918
3878
  type: Component,
3919
- args: [{ selector: 'smart-ui-action-input-dialog', template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<smartform #form [smartForm]=\"folderForm\"></smartform>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"save()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"] }]
3920
- }], ctorParameters: function () { return [{ type: UiActionInputDialogService }, { type: UiActionDescriptorService }]; }, propDecorators: { folderFormChild: [{
3879
+ args: [{ selector: 'smart-component-layout', template: "<div *ngIf=\"smartComponentLayout?.expandable; then expandable; else normal\"> </div>\n\n<ng-template #expandable>\n <smart-expandable-section\n *ngIf=\"expandableSection\"\n [data]=\"expandableSection\"\n ></smart-expandable-section>\n</ng-template>\n\n<ng-template #normal>\n <div\n *ngIf=\"smartComponentLayout?.type === type().Container\"\n [ngClass]=\"smartComponentLayout?.direction ?? 'vertical'\"\n >\n <smart-component-layout\n [smartComponentLayout]=\"layout\"\n *ngFor=\"let layout of smartComponentLayout?.components\"\n ></smart-component-layout>\n </div>\n <smartform #form [smartForm]=\"smartForm\"></smartform>\n <smart-grid #grid [smartGrid]=\"smartGrid\" [uuid]=\"uuid!\"></smart-grid>\n <!-- <smart-filter #filter [filter]=\"smartFilter\"></smart-filter> -->\n <smart-tree [treeService]=\"treeService!\"></smart-tree>\n</ng-template>\n", styles: [".horizontal{display:flex;flex-direction:row}.vertical{display:flex;flex-direction:column}\n"] }]
3880
+ }], ctorParameters: function () { return [{ type: i1$2.SmartformLayoutDefinitionService }]; }, propDecorators: { smartComponentLayout: [{
3881
+ type: Input
3882
+ }], formChild: [{
3921
3883
  type: ViewChild,
3922
3884
  args: ['form']
3885
+ }], gridChild: [{
3886
+ type: ViewChild,
3887
+ args: ['grid']
3923
3888
  }] } });
3924
3889
 
3925
- class UiActionInputDialogService extends SmartdialogService {
3926
- constructor(dialog, router) {
3890
+ class SmartViewContextErrorDialogService extends SmartdialogService {
3891
+ constructor(dialog, router, viewContext) {
3927
3892
  super(dialog, router);
3928
- this._destroy$ = new Subject();
3929
- this.onAction = new SmartSubject(this._destroy$);
3930
- }
3931
- setDataAndOpenDialog(action, nodeName) {
3932
- this.action = action;
3933
- this.nodeName = nodeName;
3934
- this.openDialog();
3893
+ this.viewContext = viewContext;
3894
+ this.dialogRefs = [];
3935
3895
  }
3896
+ handleAfterClosed(result) { }
3936
3897
  openDialog() {
3937
- this.params = undefined;
3938
- this.onAction = new SmartSubject(this._destroy$);
3939
3898
  const dialogData = {
3940
3899
  content: {
3941
3900
  title: '',
3942
3901
  },
3943
3902
  size: {},
3944
- customComponent: UiActionInputDialogComponent,
3903
+ customComponent: SmartViewContextErrorDialogComponent,
3945
3904
  };
3946
- this.createDialog(dialogData, UiActionInputDialogComponent);
3905
+ this.dialogRefs.push(this.createDialogRef(dialogData, SmartViewContextErrorDialogComponent));
3947
3906
  }
3948
- async onSave(params) {
3949
- this.params = params;
3950
- this.onAction.complete();
3951
- this.closeDialog();
3952
- this.onAction = new SmartSubject(this._destroy$);
3907
+ async closeDialog() {
3908
+ let dialogRef = this.dialogRefs.pop();
3909
+ dialogRef?.close();
3953
3910
  }
3954
- cancel() {
3955
- this.onAction.complete();
3956
- this.closeDialog();
3957
- this.onAction = new SmartSubject(this._destroy$);
3911
+ async getSmartViewContextApiError() {
3912
+ if (this.viewApiError?.code) {
3913
+ return await this.viewContext.getSmartViewContextApiErrorByCode(this.viewApiError.code);
3914
+ }
3915
+ let dialogTitle;
3916
+ let buttonLabel;
3917
+ let message;
3918
+ if (this.viewContext.translateService) {
3919
+ dialogTitle = await this.viewContext.translateService
3920
+ .get(SmartViewContextErrorDialogTitle)
3921
+ .toPromise();
3922
+ buttonLabel = await this.viewContext.translateService
3923
+ .get(SmartViewContextErrorDialogButtonLabel)
3924
+ .toPromise();
3925
+ message = await this.viewContext.translateService
3926
+ .get(SmartViewContextErrorDialogMessage)
3927
+ .toPromise();
3928
+ }
3929
+ else {
3930
+ buttonLabel = 'Ok';
3931
+ dialogTitle = 'Hiba';
3932
+ message = 'An error has occured.';
3933
+ }
3934
+ return {
3935
+ code: this.viewApiError?.code ?? '',
3936
+ message: this.viewApiError?.message ?? message,
3937
+ buttonLabel,
3938
+ dialogTitle,
3939
+ };
3958
3940
  }
3959
3941
  }
3960
- UiActionInputDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
3961
- UiActionInputDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogService, providedIn: 'root' });
3962
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogService, decorators: [{
3942
+ SmartViewContextErrorDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }, { token: SmartViewContextService }], target: i0.ɵɵFactoryTarget.Injectable });
3943
+ SmartViewContextErrorDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogService, providedIn: 'root' });
3944
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogService, decorators: [{
3963
3945
  type: Injectable,
3964
3946
  args: [{
3965
3947
  providedIn: 'root',
3966
3948
  }]
3967
- }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }]; } });
3949
+ }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }, { type: SmartViewContextService }]; } });
3968
3950
 
3969
- class UiActionFileUploadDialogComponent {
3970
- constructor(service, manager) {
3951
+ class SmartViewContextErrorDialogComponent {
3952
+ constructor(service) {
3971
3953
  this.service = service;
3972
- this.manager = manager;
3973
- this.code = this.service.action.code;
3974
- this.setUp();
3975
- }
3976
- ngOnDestroy() {
3977
- this.service._destroy$.next();
3978
- this.cancel();
3954
+ this.service
3955
+ .getSmartViewContextApiError()
3956
+ .then((smartViewContextApiError) => {
3957
+ this.smartViewContextApiError = smartViewContextApiError;
3958
+ });
3979
3959
  }
3980
- async setUp() {
3981
- this.descriptor = await this.manager.getActionDescriptor(this.service.action);
3982
- this.isMultiple = this.service.isMultiple;
3983
- this.i18n = {
3984
- addFile: this.descriptor.upload?.title ?? 'dokumentum hozzáadása',
3985
- browseOrDrag: this.descriptor.upload?.description ?? 'tallózás vagy behúzás',
3986
- formats: this.descriptor.upload?.formats ?? '',
3987
- maxSize: this.descriptor.upload?.maxSize ?? '',
3988
- upload: this.descriptor.upload?.uploadButtonTitle,
3989
- };
3990
- // TODO set max size and file formats by UiAction.params
3991
- if (this.descriptor[this.service.inputTypeName]) {
3992
- this.dialogType = this.service.inputTypeName;
3993
- }
3994
- else {
3995
- this.dialogType = this.descriptor.inputDialog ? 'inputDialog' : 'dialog';
3960
+ ngOnInit() { }
3961
+ onActionClick() {
3962
+ if (this.smartViewContextApiError?.customAction) {
3963
+ this.smartViewContextApiError.customAction();
3996
3964
  }
3997
- }
3998
- getTitle() {
3999
- return this.descriptor[this.dialogType].title;
4000
- }
4001
- getText() {
4002
- return this.descriptor[this.dialogType].text ?? '';
4003
- }
4004
- getActionButtonLabel() {
4005
- return this.descriptor[this.dialogType].actionButton.caption;
4006
- }
4007
- getActionButtonColor() {
4008
- return this.descriptor[this.dialogType].actionButton.color;
4009
- }
4010
- getCancelButtonLabel() {
4011
- return this.descriptor[this.dialogType].cancelButton.caption;
4012
- }
4013
- getCancelButtonColor() {
4014
- return this.descriptor[this.dialogType].cancelButton.color;
4015
- }
4016
- upload(files) {
4017
- this.service.onSave(files);
4018
- }
4019
- cancel() {
4020
- this.service.cancel();
3965
+ this.service.closeDialog();
4021
3966
  }
4022
3967
  }
4023
- UiActionFileUploadDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogComponent, deps: [{ token: UiActionFileUploadDialogService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
4024
- UiActionFileUploadDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionFileUploadDialogComponent, selector: "lib-ui-action-file-upload-dialog", ngImport: i0, template: "<div class=\"folderNameDialogContainer\">\n <div class=\"headerContainer\">\n <h3 class=\"color-accent-700\">\n {{ getTitle() }}\n </h3>\n <button mat-icon-button title=\"close\" (click)=\"cancel()\">\n <smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n </button>\n </div>\n <p>\n {{ getText() }}\n </p>\n <smartfileuploader\n [i18n]=\"i18n\"\n [fileFormats]=\"fileFormats\"\n [maxSizeMb]=\"maxSizeMb\"\n [uploadCallback]=\"upload.bind(this)\"\n [isMultiple]=\"isMultiple\"\n ></smartfileuploader>\n <div class=\"folderNameDialogButtonsContainer\">\n <button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n {{ getCancelButtonLabel() }}\n </button>\n <!-- <button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"upload()\">\n {{ getActionButtonLabel() }}\n </button> -->\n </div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$2.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }, { type: i1$2.SmartfileuploaderComponent, selector: "smartfileuploader", inputs: ["uploadCallback", "fileFormats", "maxSizeMb", "i18n", "useIconButton", "isMultiple"] }] });
4025
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogComponent, decorators: [{
3968
+ SmartViewContextErrorDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogComponent, deps: [{ token: SmartViewContextErrorDialogService }], target: i0.ɵɵFactoryTarget.Component });
3969
+ SmartViewContextErrorDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartViewContextErrorDialogComponent, selector: "lib-smart-view-context-error-dialog", ngImport: i0, template: "<div *ngIf=\"smartViewContextApiError\" class=\"container\">\n <h3 class=\"color-accent-700\">\n {{ smartViewContextApiError.dialogTitle }}\n </h3>\n <div class=\"content\">\n <p>\n {{ smartViewContextApiError.message }}\n </p>\n </div>\n <div class=\"buttonContainer\">\n <button mat-raised-button color=\"primary\" (click)=\"onActionClick()\">\n {{ smartViewContextApiError.buttonLabel }}\n </button>\n </div>\n</div>\n", styles: [".container{display:flex;flex-direction:column;gap:1em;min-width:25rem;max-width:50vw;height:auto;max-height:75vh}.content{flex:1;overflow:auto}.buttonContainer{display:flex;flex-direction:row;justify-content:flex-end}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3970
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogComponent, decorators: [{
4026
3971
  type: Component,
4027
- args: [{ selector: 'lib-ui-action-file-upload-dialog', template: "<div class=\"folderNameDialogContainer\">\n <div class=\"headerContainer\">\n <h3 class=\"color-accent-700\">\n {{ getTitle() }}\n </h3>\n <button mat-icon-button title=\"close\" (click)=\"cancel()\">\n <smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n </button>\n </div>\n <p>\n {{ getText() }}\n </p>\n <smartfileuploader\n [i18n]=\"i18n\"\n [fileFormats]=\"fileFormats\"\n [maxSizeMb]=\"maxSizeMb\"\n [uploadCallback]=\"upload.bind(this)\"\n [isMultiple]=\"isMultiple\"\n ></smartfileuploader>\n <div class=\"folderNameDialogButtonsContainer\">\n <button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n {{ getCancelButtonLabel() }}\n </button>\n <!-- <button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"upload()\">\n {{ getActionButtonLabel() }}\n </button> -->\n </div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"] }]
4028
- }], ctorParameters: function () { return [{ type: UiActionFileUploadDialogService }, { type: UiActionDescriptorService }]; } });
3972
+ args: [{ selector: 'lib-smart-view-context-error-dialog', template: "<div *ngIf=\"smartViewContextApiError\" class=\"container\">\n <h3 class=\"color-accent-700\">\n {{ smartViewContextApiError.dialogTitle }}\n </h3>\n <div class=\"content\">\n <p>\n {{ smartViewContextApiError.message }}\n </p>\n </div>\n <div class=\"buttonContainer\">\n <button mat-raised-button color=\"primary\" (click)=\"onActionClick()\">\n {{ smartViewContextApiError.buttonLabel }}\n </button>\n </div>\n</div>\n", styles: [".container{display:flex;flex-direction:column;gap:1em;min-width:25rem;max-width:50vw;height:auto;max-height:75vh}.content{flex:1;overflow:auto}.buttonContainer{display:flex;flex-direction:row;justify-content:flex-end}\n"] }]
3973
+ }], ctorParameters: function () { return [{ type: SmartViewContextErrorDialogService }]; } });
4029
3974
 
4030
- class UiActionFileUploadDialogService extends SmartdialogService {
4031
- constructor(dialog, router) {
4032
- super(dialog, router);
4033
- this._destroy$ = new Subject();
4034
- this.onAction = new SmartSubject(this._destroy$);
4035
- this.isMultiple = false;
4036
- }
4037
- setDataAndOpenDialog(action, nodeName) {
4038
- this.action = action;
4039
- this.nodeName = nodeName;
4040
- this.openDialog();
3975
+ class SmartViewContextInterceptor {
3976
+ constructor(viewContextErrorDialog) {
3977
+ this.viewContextErrorDialog = viewContextErrorDialog;
4041
3978
  }
4042
- openDialog() {
4043
- this.files = undefined;
4044
- this.onAction = new SmartSubject(this._destroy$);
4045
- const dialogData = {
4046
- content: {
4047
- title: '',
4048
- },
4049
- size: {},
4050
- customComponent: UiActionFileUploadDialogComponent,
4051
- };
4052
- this.createDialog(dialogData, UiActionFileUploadDialogComponent);
3979
+ intercept(request, next) {
3980
+ // parameter: async: True -> don't throw/open error (dialog)
3981
+ if (request.body) {
3982
+ try {
3983
+ let body = request.body;
3984
+ if (body.params[IS_ASYNC_PARAM_NAME]) {
3985
+ return next.handle(request);
3986
+ }
3987
+ }
3988
+ catch (error) { }
3989
+ }
3990
+ return next.handle(request).pipe(catchError((error) => {
3991
+ if (error.status === 409 &&
3992
+ (error.error.code || error.error.message)) {
3993
+ this.openErrorDialog(error.error);
3994
+ }
3995
+ return throwError(error);
3996
+ }));
4053
3997
  }
4054
- async onSave(files) {
4055
- this.files = files;
4056
- this.onAction.complete();
4057
- this.closeDialog();
4058
- this.onAction = new SmartSubject(this._destroy$);
3998
+ openErrorDialog(viewApiError) {
3999
+ this.viewContextErrorDialog.viewApiError = viewApiError;
4000
+ this.viewContextErrorDialog.openDialog();
4059
4001
  }
4060
- cancel() {
4061
- this.onAction.complete();
4062
- this.closeDialog();
4063
- this.onAction = new SmartSubject(this._destroy$);
4002
+ }
4003
+ SmartViewContextInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextInterceptor, deps: [{ token: SmartViewContextErrorDialogService }], target: i0.ɵɵFactoryTarget.Injectable });
4004
+ SmartViewContextInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextInterceptor });
4005
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextInterceptor, decorators: [{
4006
+ type: Injectable
4007
+ }], ctorParameters: function () { return [{ type: SmartViewContextErrorDialogService }]; } });
4008
+
4009
+ class SmartViewRedirect {
4010
+ constructor(service, navigation, route) {
4011
+ this.service = service;
4012
+ this.navigation = navigation;
4013
+ this.route = route;
4014
+ this.navigation.route = this.route;
4015
+ this.navigation.subscribeToUrlChange((url) => {
4016
+ let channel = this.route.snapshot.paramMap.get(SmartLinkChannelVariableInPath);
4017
+ let uuid = this.route.snapshot.paramMap.get(SmartLinkUuidVariableInPath);
4018
+ if (!channel || !uuid) {
4019
+ throw new Error("channel or uuid is not reachable from the url!");
4020
+ }
4021
+ this.service.showPublishedView(channel, uuid);
4022
+ });
4064
4023
  }
4065
4024
  }
4066
- UiActionFileUploadDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
4067
- UiActionFileUploadDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogService, providedIn: 'root' });
4068
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogService, decorators: [{
4069
- type: Injectable,
4025
+ SmartViewRedirect.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewRedirect, deps: [{ token: SmartViewContextService }, { token: i3$1.SmartNavigationService }, { token: i2$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component });
4026
+ SmartViewRedirect.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartViewRedirect, selector: "app-redirect", ngImport: i0, template: "<div>Smart redirect</div>", isInline: true });
4027
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewRedirect, decorators: [{
4028
+ type: Component,
4070
4029
  args: [{
4071
- providedIn: 'root',
4030
+ selector: "app-redirect",
4031
+ template: "<div>Smart redirect</div>",
4072
4032
  }]
4073
- }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }]; } });
4033
+ }], ctorParameters: function () { return [{ type: SmartViewContextService }, { type: i3$1.SmartNavigationService }, { type: i2$1.ActivatedRoute }]; } });
4034
+ const SmartLinkChannelVariableInPath = "channel";
4035
+ const SmartLinkUuidVariableInPath = "uuid";
4074
4036
 
4075
- class UiActionService {
4076
- constructor(confirmDialogService, textFieldDialogService, fileUploadDialogService, _snackBar) {
4077
- this.confirmDialogService = confirmDialogService;
4078
- this.textFieldDialogService = textFieldDialogService;
4079
- this.fileUploadDialogService = fileUploadDialogService;
4080
- this._snackBar = _snackBar;
4037
+ class UiActionDescriptorService {
4038
+ constructor(viewContext) {
4039
+ this.viewContext = viewContext;
4081
4040
  this._destroy$ = new Subject();
4041
+ this.languageChanged = new SmartSubject(this._destroy$);
4042
+ this.keysToTranslate = ['title', 'text', 'placeholder', 'caption', 'feedbackText'];
4043
+ this.basicActionDescriptors = new Map([
4044
+ [
4045
+ 'UNKOWN',
4046
+ {
4047
+ title: '',
4048
+ type: UiActionButtonType.Normal,
4049
+ color: 'accent',
4050
+ icon: 'Question',
4051
+ iconColor: `text-primary`,
4052
+ iconPosition: UiActionButtonIconPos.Post,
4053
+ dialog: {
4054
+ title: '',
4055
+ placeholder: 'placeholder',
4056
+ actionButton: {
4057
+ caption: '',
4058
+ color: 'accent',
4059
+ },
4060
+ cancelButton: {
4061
+ caption: 'Mégse',
4062
+ color: '',
4063
+ },
4064
+ },
4065
+ },
4066
+ ],
4067
+ ]);
4068
+ if (this.viewContext.translateService) {
4069
+ this.subscribeToTranslateService();
4070
+ }
4071
+ else {
4072
+ this.viewContext.translateServiceChanged.pipe(takeUntil(this._destroy$)).subscribe(() => {
4073
+ this.subscribeToTranslateService();
4074
+ });
4075
+ }
4082
4076
  }
4083
4077
  ngOnDestroy() {
4084
4078
  this._destroy$.next();
4085
4079
  this._destroy$.complete();
4086
4080
  }
4087
- async execute(uiAction, options) {
4088
- let uiActionRequest;
4089
- uiActionRequest = {
4090
- code: uiAction.code,
4091
- identifier: uiAction.identifier,
4092
- params: uiAction.params ?? {},
4093
- };
4094
- if (uiAction.submit) {
4095
- this.uiActionModel.serviceToUse.submit.next();
4096
- try {
4097
- await this.uiActionModel.serviceToUse.submit.toPromise();
4098
- this.uiActionModel.serviceToUse.submit = new SmartSubject(this._destroy$);
4099
- this.uiActionModel.serviceToUse.reSubscribeToChange.next();
4100
- }
4101
- catch (error) {
4102
- console.error(error);
4103
- this.uiActionModel.serviceToUse.submit = new SmartSubject(this._destroy$);
4104
- this.uiActionModel.serviceToUse.reSubscribeToChange.next();
4105
- return;
4106
- }
4107
- }
4108
- if (uiAction.confirm) {
4109
- this.confirmDialogService.action = uiAction;
4110
- this.confirmDialogService.openDialog();
4111
- await this.confirmDialogService.onAction.toPromise();
4112
- if (!this.confirmDialogService.shouldDoAction) {
4113
- return;
4114
- }
4115
- }
4116
- // InputType
4117
- if (uiAction.inputType) {
4118
- uiActionRequest = await this.handleInputType(uiAction.inputType, uiAction, uiActionRequest, 'inputDialog');
4119
- if (!uiActionRequest) {
4120
- return;
4121
- }
4122
- await new Promise((resolve) => setTimeout(resolve, 250));
4123
- }
4124
- // Input2Type
4125
- if (uiAction.input2Type) {
4126
- uiActionRequest = await this.handleInputType(uiAction.input2Type, uiAction, uiActionRequest, 'input2Dialog');
4127
- if (!uiActionRequest) {
4128
- return;
4129
- }
4130
- }
4131
- if (this.uiActionModel.exception) {
4132
- let response = await this.uiActionModel.serviceToUse.handleSpecificDemandsAsynchronously(uiAction, uiActionRequest);
4133
- if (!response.shouldPerformAction || !response.uiActionRequest) {
4134
- return;
4135
- }
4136
- uiActionRequest = response.uiActionRequest;
4137
- }
4138
- await this.performAction(uiAction, uiActionRequest, options);
4081
+ subscribeToTranslateService() {
4082
+ this.viewContext
4083
+ .translateService.onLangChange.pipe(takeUntil(this._destroy$))
4084
+ .subscribe(() => {
4085
+ this.languageChanged.next();
4086
+ });
4139
4087
  }
4140
- async handleInputType(inputType, uiAction, uiActionRequest, inputTypeName) {
4141
- switch (inputType) {
4142
- case UiActionInputType.None:
4143
- return uiActionRequest;
4144
- case UiActionInputType.Textarea:
4145
- case UiActionInputType.Textfield:
4146
- return await this.handleInputTypeTextField(inputTypeName, uiAction, uiActionRequest);
4147
- case UiActionInputType.UserSelect:
4148
- return await this.handleInputTypeUserSelect(inputTypeName, uiAction, uiActionRequest);
4149
- case UiActionInputType.File:
4150
- return await this.handleInputTypeUpload(inputTypeName, uiAction, uiActionRequest, false);
4151
- case UiActionInputType.MultipleFiles:
4152
- return await this.handleInputTypeUpload(inputTypeName, uiAction, uiActionRequest, true);
4153
- default:
4154
- return uiActionRequest;
4088
+ async getActionDescriptor(uiAction) {
4089
+ let code = uiAction.code;
4090
+ let actionDescriptorFromDescriptors = this.viewContext.getActionDescriptors()?.get(code);
4091
+ let isUnkown = false;
4092
+ let actionDescriptor;
4093
+ if (actionDescriptorFromDescriptors) {
4094
+ actionDescriptor = JSON.parse(JSON.stringify(actionDescriptorFromDescriptors));
4155
4095
  }
4156
- }
4157
- async handleInputTypeTextField(inputTypeName, uiAction, uiActionRequest) {
4158
- let additionalParams = this.uiActionModel.serviceToUse.getAdditionalParams(uiAction);
4159
- let inputType = inputTypeName === 'inputDialog' ? 'inputType' : 'input2Type';
4160
- if (uiAction[inputType] === UiActionInputType.Textfield) {
4161
- this.textFieldDialogService.nodeName = additionalParams.forTextField;
4096
+ if (!actionDescriptor) {
4097
+ isUnkown = true;
4098
+ let unkownActionDescriptor = this.basicActionDescriptors.get('UNKOWN');
4099
+ actionDescriptor = { ...unkownActionDescriptor };
4100
+ actionDescriptor.title = code;
4162
4101
  }
4163
- else if (uiAction[inputType] === UiActionInputType.Textarea) {
4164
- this.textFieldDialogService.nodeName = additionalParams.forTextArea;
4102
+ if (!actionDescriptor.dialog) {
4103
+ actionDescriptor = this.setUpUnkownDialogDescriptor(code, actionDescriptor, 'dialog');
4165
4104
  }
4166
- this.textFieldDialogService.inputTypeName = inputTypeName;
4167
- this.textFieldDialogService.action = uiAction;
4168
- this.textFieldDialogService.openDialog();
4169
- await this.textFieldDialogService.onAction.toPromise();
4170
- let params = this.textFieldDialogService.params;
4171
- if (!params) {
4172
- console.error('There was no response from InputDialog');
4173
- return;
4105
+ if (!actionDescriptor.feedbackType && uiAction.submit) {
4106
+ actionDescriptor.feedbackType = UiActionFeedbackType.Snackbar;
4174
4107
  }
4175
- uiActionRequest.params = {
4176
- ...uiActionRequest.params,
4177
- ...params,
4178
- };
4179
- return uiActionRequest;
4180
- }
4181
- async handleInputTypeUpload(inputTypeName, uiAction, uiActionRequest, isMultiple) {
4182
- this.fileUploadDialogService.inputTypeName = inputTypeName;
4183
- this.fileUploadDialogService.action = uiAction;
4184
- this.fileUploadDialogService.isMultiple = isMultiple;
4185
- this.fileUploadDialogService.openDialog();
4186
- await this.fileUploadDialogService.onAction.toPromise();
4187
- let files = this.fileUploadDialogService.files;
4188
- if (!files || !files.length) {
4189
- console.error('There was no response from InputDialog');
4190
- return;
4108
+ if (this.viewContext.translateService && actionDescriptor && !isUnkown) {
4109
+ actionDescriptor = await this.translateUiActionDescriptor(actionDescriptor);
4191
4110
  }
4192
- uiActionRequest.params = {
4193
- ...uiActionRequest.params,
4194
- _files: files,
4195
- isMultiple,
4196
- param: uiAction.inputType === 'file' || uiAction.inputType === 'multiple_files'
4197
- ? 'INPUT'
4198
- : 'INPUT2',
4199
- };
4200
- return uiActionRequest;
4111
+ return actionDescriptor;
4201
4112
  }
4202
- async handleInputTypeUserSelect(inputTypeName, uiAction, uiActionRequest) {
4203
- let response = await this.uiActionModel.serviceToUse.handleSpecificDemandsAsynchronously(uiAction, uiActionRequest);
4204
- if (!response.shouldPerformAction || !response.uiActionRequest) {
4205
- return;
4206
- }
4207
- uiActionRequest = response.uiActionRequest;
4208
- return uiActionRequest;
4113
+ async translateUiActionDescriptor(uiActionDescriptor) {
4114
+ uiActionDescriptor = await this.deepTranslate(uiActionDescriptor);
4115
+ return uiActionDescriptor;
4209
4116
  }
4210
- async performAction(uiAction, uiActionRequest, options) {
4211
- if (!uiActionRequest.params ||
4212
- (uiActionRequest.params && !Object.keys(uiActionRequest.params).length)) {
4213
- uiActionRequest.params = {
4214
- model: this.uiActionModel.serviceToUse.getModel(),
4215
- };
4216
- }
4217
- else if (uiAction.submit) {
4218
- uiActionRequest.params['model'] = this.uiActionModel.serviceToUse.getModel();
4219
- }
4220
- try {
4221
- await this.uiActionModel.serviceToUse.performUiActionRequest(uiActionRequest, options?.widgetId, options?.nodeId);
4222
- if (this.uiActionModel.descriptor?.feedbackType === UiActionFeedbackType.Snackbar) {
4223
- this.showSavedSnackbar(uiAction);
4117
+ async deepTranslate(_model) {
4118
+ let model = { ..._model };
4119
+ await Promise.all(Object.keys(model).map(async (key) => {
4120
+ if (model[key] !== undefined &&
4121
+ typeof model[key] === 'string' &&
4122
+ model[key].length &&
4123
+ this.keysToTranslate.includes(key)) {
4124
+ model[key] = await this.viewContext.translateService.get(model[key]).toPromise();
4224
4125
  }
4225
- }
4226
- catch (error) {
4227
- console.error(error);
4228
- }
4126
+ else if (model[key] !== undefined && typeof model[key] === 'object') {
4127
+ model[key] = await this.deepTranslate(model[key]);
4128
+ }
4129
+ return model;
4130
+ }));
4131
+ return model;
4229
4132
  }
4230
- showSavedSnackbar(uiAction) {
4231
- this._snackBar.openFromComponent(SuccessSnackBarComponent, {
4232
- duration: 5 * 1000,
4233
- panelClass: ['backgroundColor-accent'],
4234
- data: uiAction,
4235
- });
4133
+ setUpUnkownDialogDescriptor(code, uiActionDescriptor, dialogType) {
4134
+ let unkownDescriptor = this.basicActionDescriptors.get('UNKOWN');
4135
+ uiActionDescriptor[dialogType] = unkownDescriptor.dialog;
4136
+ uiActionDescriptor[dialogType].title = code;
4137
+ uiActionDescriptor[dialogType].actionButton.caption = code;
4138
+ return uiActionDescriptor;
4236
4139
  }
4237
4140
  }
4238
- UiActionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionService, deps: [{ token: UiActionConfirmDialogService }, { token: UiActionInputDialogService }, { token: UiActionFileUploadDialogService }, { token: i4$4.MatSnackBar }], target: i0.ɵɵFactoryTarget.Injectable });
4239
- UiActionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionService, providedIn: 'root' });
4240
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionService, decorators: [{
4141
+ UiActionDescriptorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionDescriptorService, deps: [{ token: SmartViewContextService }], target: i0.ɵɵFactoryTarget.Injectable });
4142
+ UiActionDescriptorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionDescriptorService, providedIn: 'root' });
4143
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionDescriptorService, decorators: [{
4241
4144
  type: Injectable,
4242
4145
  args: [{
4243
4146
  providedIn: 'root',
4244
4147
  }]
4245
- }], ctorParameters: function () { return [{ type: UiActionConfirmDialogService }, { type: UiActionInputDialogService }, { type: UiActionFileUploadDialogService }, { type: i4$4.MatSnackBar }]; } });
4148
+ }], ctorParameters: function () { return [{ type: SmartViewContextService }]; } });
4246
4149
 
4247
- class UiActionToolbarComponent {
4248
- constructor(service, inject) {
4249
- this.service = service;
4250
- this.inject = inject;
4251
- this._destroy$ = new Subject();
4252
- this.pressedButtonActive = true;
4253
- // Injects the basic UiActionDescriptorService provided by the AppModule
4254
- this.manager = inject.get(UiActionDescriptorService);
4255
- this.subscribeToLanguageChange();
4150
+ class SuccessSnackBarComponent {
4151
+ constructor(data, viewContext, manager) {
4152
+ this.data = data;
4153
+ this.viewContext = viewContext;
4154
+ this.manager = manager;
4155
+ this.manager.getActionDescriptor(data).then((descriptor) => {
4156
+ if (descriptor.feedbackText) {
4157
+ this.text = descriptor.feedbackText;
4158
+ }
4159
+ else {
4160
+ this.text = this.viewContext.commonFeedbackText ?? "A mentés sikeres volt!";
4161
+ }
4162
+ });
4256
4163
  }
4257
- ngOnInit() {
4258
- // Overrides the basic UiActionDescriptorService with a custom one if there is one
4259
- if (this.uiActionDescriptorService) {
4260
- this.manager = this.uiActionDescriptorService;
4261
- this.subscribeToLanguageChange();
4262
- }
4164
+ }
4165
+ SuccessSnackBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SuccessSnackBarComponent, deps: [{ token: MAT_SNACK_BAR_DATA }, { token: SmartViewContextService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
4166
+ SuccessSnackBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SuccessSnackBarComponent, selector: "app-success-snack-bar", ngImport: i0, template: "<span class=\"successSnakBarContainer\" matSnackBarLabel> {{ text }} </span>\n", styles: ["::ng-deep .mat-snack-bar-container{text-align:center;border-radius:2rem}.successSnakBarContainer{color:#fff}\n"] });
4167
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SuccessSnackBarComponent, decorators: [{
4168
+ type: Component,
4169
+ args: [{ selector: "app-success-snack-bar", template: "<span class=\"successSnakBarContainer\" matSnackBarLabel> {{ text }} </span>\n", styles: ["::ng-deep .mat-snack-bar-container{text-align:center;border-radius:2rem}.successSnakBarContainer{color:#fff}\n"] }]
4170
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
4171
+ type: Inject,
4172
+ args: [MAT_SNACK_BAR_DATA]
4173
+ }] }, { type: SmartViewContextService }, { type: UiActionDescriptorService }]; } });
4174
+
4175
+ class UiActionConfirmDialogComponent {
4176
+ constructor(service, manager) {
4177
+ this.service = service;
4178
+ this.manager = manager;
4179
+ this.code = this.service.action.code;
4263
4180
  this.setUp();
4264
4181
  }
4265
- ngOnChanges(changes) {
4266
- let uiActionModels = changes['uiActionModels'].currentValue;
4267
- if (uiActionModels) {
4268
- this.uiActionModels = uiActionModels;
4269
- this.setUp();
4270
- }
4182
+ async setUp() {
4183
+ this.descriptor = await this.manager.getActionDescriptor(this.service.action);
4184
+ this.dialogType = this.descriptor.confirmDialog ? "confirmDialog" : "dialog";
4271
4185
  }
4272
4186
  ngOnDestroy() {
4273
- this._destroy$.next();
4187
+ this.service._destroy$.next();
4188
+ this.cancel();
4274
4189
  }
4275
- subscribeToLanguageChange() {
4276
- this.languageChangedSubscription?.unsubscribe();
4277
- this.languageChangedSubscription = this.manager.languageChanged
4278
- .pipe(takeUntil(this._destroy$))
4279
- .subscribe(() => {
4280
- this.setUp();
4281
- });
4190
+ getTitle() {
4191
+ return this.descriptor[this.dialogType].title;
4282
4192
  }
4283
- async setUp() {
4284
- this.uiActionModelsWithDescriptions = await Promise.all(this.uiActionModels.map(async (uiActionModel) => {
4285
- uiActionModel.descriptor = await this.manager.getActionDescriptor(uiActionModel.uiAction);
4286
- return uiActionModel;
4287
- }));
4193
+ getText() {
4194
+ return this.descriptor[this.dialogType].text ?? "";
4288
4195
  }
4289
- async onActionClicked(event, uiActionModel) {
4290
- event.stopPropagation();
4291
- if (this.pressedButtonActive) {
4292
- this.pressedButtonActive = false;
4293
- this.service.uiActionModel = uiActionModel;
4294
- let options = {
4295
- nodeId: uiActionModel.nodeId,
4296
- widgetId: uiActionModel.widgetId,
4297
- };
4298
- await this.service.execute(uiActionModel.uiAction, options);
4299
- this.pressedButtonActive = true;
4300
- }
4196
+ getActionButtonLabel() {
4197
+ return this.descriptor[this.dialogType].actionButton.caption;
4301
4198
  }
4302
- onActionDoubleClicked(event, uiActionModel) {
4303
- event.stopPropagation();
4304
- // We do not handle double clicks
4199
+ getActionButtonColor() {
4200
+ return this.descriptor[this.dialogType].actionButton.color;
4305
4201
  }
4306
- getType(uiActionModel) {
4307
- switch (uiActionModel.descriptor?.type) {
4308
- case UiActionButtonType.Normal:
4309
- return 'mat-button';
4310
- case UiActionButtonType.Flat:
4311
- return 'mat-flat-button';
4312
- case UiActionButtonType.Raised:
4313
- return 'mat-raised-button';
4314
- case UiActionButtonType.Stroked:
4315
- return 'mat-stroked-button';
4316
- case UiActionButtonType.Icon:
4317
- return 'mat-icon-button';
4318
- case UiActionButtonType.MiniFab:
4319
- return 'mat-mini-fab';
4320
- case UiActionButtonType.Fab:
4321
- return 'mat-fab';
4322
- default:
4323
- console.log(`Unhandled action button type case: ${uiActionModel.descriptor?.type}`);
4324
- return `mat-button`;
4325
- }
4202
+ getCancelButtonLabel() {
4203
+ return this.descriptor[this.dialogType].cancelButton.caption;
4326
4204
  }
4327
- iconPosition() {
4328
- return UiActionButtonIconPos;
4205
+ getCancelButtonColor() {
4206
+ return this.descriptor[this.dialogType].cancelButton.color;
4329
4207
  }
4330
- isOnlyIcon(uiActionModel) {
4331
- return (uiActionModel.descriptor?.type === UiActionButtonType.Icon ||
4332
- uiActionModel.descriptor?.type === UiActionButtonType.MiniFab ||
4333
- uiActionModel.descriptor?.type === UiActionButtonType.Fab);
4208
+ doAction() {
4209
+ this.service.doAction();
4210
+ }
4211
+ cancel() {
4212
+ this.service.cancel();
4334
4213
  }
4335
4214
  }
4336
- UiActionToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionToolbarComponent, deps: [{ token: UiActionService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
4337
- UiActionToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionToolbarComponent, selector: "smart-ui-action-toolbar", inputs: { uiActionModels: "uiActionModels", uiActionDescriptorService: "uiActionDescriptorService" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"uiActionButtonsContainer\">\n <button\n *ngFor=\"let uiActionModel of uiActionModelsWithDescriptions\"\n mat-button\n [ngClass]=\"getType(uiActionModel)\"\n class=\"{{ uiActionModel.cssClass }}\"\n [color]=\"uiActionModel.descriptor?.color\"\n (click)=\"onActionClicked($event, uiActionModel)\"\n (dblclick)=\"onActionDoubleClicked($event, uiActionModel)\"\n >\n <div *ngIf=\"isOnlyIcon(uiActionModel); then iconOnly; else text\"></div>\n <ng-template #iconOnly>\n <smart-icon\n *ngIf=\"uiActionModel.descriptor?.icon\"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n <ng-template #text>\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Pre\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n {{ uiActionModel.descriptor?.title }}\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Post\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n </button>\n</div>\n", styles: [".uiActionButtonsContainer{display:flex;flex-direction:row;gap:1rem;flex-wrap:wrap;min-height:2.25rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$2.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }], directives: [{ type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4338
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionToolbarComponent, decorators: [{
4215
+ UiActionConfirmDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogComponent, deps: [{ token: UiActionConfirmDialogService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
4216
+ UiActionConfirmDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionConfirmDialogComponent, selector: "app-ui-action-confirm-dialog", ngImport: i0, template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"doAction()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$2.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }] });
4217
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogComponent, decorators: [{
4339
4218
  type: Component,
4340
- args: [{ selector: 'smart-ui-action-toolbar', template: "<div class=\"uiActionButtonsContainer\">\n <button\n *ngFor=\"let uiActionModel of uiActionModelsWithDescriptions\"\n mat-button\n [ngClass]=\"getType(uiActionModel)\"\n class=\"{{ uiActionModel.cssClass }}\"\n [color]=\"uiActionModel.descriptor?.color\"\n (click)=\"onActionClicked($event, uiActionModel)\"\n (dblclick)=\"onActionDoubleClicked($event, uiActionModel)\"\n >\n <div *ngIf=\"isOnlyIcon(uiActionModel); then iconOnly; else text\"></div>\n <ng-template #iconOnly>\n <smart-icon\n *ngIf=\"uiActionModel.descriptor?.icon\"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n <ng-template #text>\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Pre\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n {{ uiActionModel.descriptor?.title }}\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Post\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n </button>\n</div>\n", styles: [".uiActionButtonsContainer{display:flex;flex-direction:row;gap:1rem;flex-wrap:wrap;min-height:2.25rem}\n"] }]
4341
- }], ctorParameters: function () { return [{ type: UiActionService }, { type: i0.Injector }]; }, propDecorators: { uiActionModels: [{
4342
- type: Input
4343
- }], uiActionDescriptorService: [{
4344
- type: Input
4345
- }] } });
4219
+ args: [{ selector: "app-ui-action-confirm-dialog", template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"doAction()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"] }]
4220
+ }], ctorParameters: function () { return [{ type: UiActionConfirmDialogService }, { type: UiActionDescriptorService }]; } });
4346
4221
 
4347
- class SmartViewContextModule {
4222
+ class UiActionConfirmDialogService extends SmartdialogService {
4223
+ constructor(dialog, router) {
4224
+ super(dialog, router);
4225
+ this._destroy$ = new Subject();
4226
+ this.onAction = new SmartSubject(this._destroy$);
4227
+ this.shouldDoAction = false;
4228
+ }
4229
+ openDialog() {
4230
+ this.shouldDoAction = false;
4231
+ this.onAction = new SmartSubject(this._destroy$);
4232
+ const dialogData = {
4233
+ content: {
4234
+ title: '',
4235
+ },
4236
+ size: {},
4237
+ customComponent: UiActionConfirmDialogComponent,
4238
+ };
4239
+ this.createDialog(dialogData, UiActionConfirmDialogComponent);
4240
+ }
4241
+ doAction() {
4242
+ this.shouldDoAction = true;
4243
+ this.onAction.complete();
4244
+ this.closeDialog();
4245
+ this.onAction = new SmartSubject(this._destroy$);
4246
+ }
4247
+ cancel() {
4248
+ this.onAction.complete();
4249
+ this.closeDialog();
4250
+ this.onAction = new SmartSubject(this._destroy$);
4251
+ }
4348
4252
  }
4349
- SmartViewContextModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
4350
- SmartViewContextModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, declarations: [MessageDialogComponent,
4351
- SmartViewContextErrorDialogComponent,
4352
- SmartViewRedirect,
4353
- UiActionToolbarComponent,
4354
- UiActionInputDialogComponent,
4355
- UiActionConfirmDialogComponent,
4356
- UiActionFileUploadDialogComponent], imports: [CommonModule,
4357
- HttpClientModule,
4358
- MatCommonModule,
4359
- MatButtonModule,
4360
- MatIconModule,
4361
- MatSnackBarModule,
4362
- SmartIconModule,
4363
- SmartformModule], exports: [UiActionToolbarComponent, UiActionInputDialogComponent] });
4364
- SmartViewContextModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, providers: [
4365
- SmartViewContextService,
4366
- {
4367
- provide: HTTP_INTERCEPTORS,
4368
- useClass: SmartViewContextInterceptor,
4369
- multi: true,
4370
- },
4371
- ], imports: [[
4372
- CommonModule,
4373
- HttpClientModule,
4374
- MatCommonModule,
4375
- MatButtonModule,
4376
- MatIconModule,
4377
- MatSnackBarModule,
4378
- SmartIconModule,
4379
- SmartformModule,
4380
- ]] });
4381
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, decorators: [{
4382
- type: NgModule,
4253
+ UiActionConfirmDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
4254
+ UiActionConfirmDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogService, providedIn: 'root' });
4255
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogService, decorators: [{
4256
+ type: Injectable,
4383
4257
  args: [{
4384
- declarations: [
4385
- MessageDialogComponent,
4386
- SmartViewContextErrorDialogComponent,
4387
- SmartViewRedirect,
4388
- UiActionToolbarComponent,
4389
- UiActionInputDialogComponent,
4390
- UiActionConfirmDialogComponent,
4391
- UiActionFileUploadDialogComponent,
4392
- ],
4393
- imports: [
4394
- CommonModule,
4395
- HttpClientModule,
4396
- MatCommonModule,
4397
- MatButtonModule,
4398
- MatIconModule,
4399
- MatSnackBarModule,
4400
- SmartIconModule,
4401
- SmartformModule,
4402
- ],
4403
- exports: [UiActionToolbarComponent, UiActionInputDialogComponent],
4404
- providers: [
4405
- SmartViewContextService,
4406
- {
4407
- provide: HTTP_INTERCEPTORS,
4408
- useClass: SmartViewContextInterceptor,
4409
- multi: true,
4410
- },
4411
- ],
4258
+ providedIn: 'root',
4412
4259
  }]
4413
- }] });
4414
-
4415
- var UiActionDialogType;
4416
- (function (UiActionDialogType) {
4417
- UiActionDialogType["inputDialog"] = "inputDialog";
4418
- UiActionDialogType["confirmDialog"] = "confirmDialog";
4419
- UiActionDialogType["dialog"] = "dialog";
4420
- })(UiActionDialogType || (UiActionDialogType = {}));
4421
-
4422
- /*
4423
- * Public API Surface of smart-view-context
4424
- */
4260
+ }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }]; } });
4425
4261
 
4426
- class SmartFileUploaderComponent {
4427
- constructor(uiActionService, uiActionDescriptorService) {
4428
- this.uiActionService = uiActionService;
4429
- this.uiActionDescriptorService = uiActionDescriptorService;
4262
+ class UiActionInputDialogComponent {
4263
+ constructor(service, manager) {
4264
+ this.service = service;
4265
+ this.manager = manager;
4266
+ this.code = this.service.action.code;
4267
+ this.setUp();
4430
4268
  }
4431
- ngOnChanges(changes) {
4432
- this.config = changes['config'].currentValue;
4433
- if (this.config) {
4434
- this.setUp();
4435
- }
4269
+ ngOnDestroy() {
4270
+ this.service._destroy$.next();
4271
+ this.cancel();
4436
4272
  }
4437
4273
  async setUp() {
4438
- this.uiActionModel = this.config?.smartComponent.uiActionModels.find((uiActionModel) => uiActionModel.uiAction.code === this.config?.uiActionCode);
4439
- if (!this.uiActionModel) {
4440
- throw new Error(`UiAction with code ${this.config?.uiActionCode} could not found`);
4274
+ this.descriptor = await this.manager.getActionDescriptor(this.service.action);
4275
+ if (this.descriptor[this.service.inputTypeName]) {
4276
+ this.dialogType = this.service.inputTypeName;
4441
4277
  }
4442
- const descriptor = await this.uiActionDescriptorService.getActionDescriptor(this.uiActionModel.uiAction);
4443
- this.i18n = {
4444
- addFile: descriptor.upload?.title ?? 'dokumentum hozzáadása',
4445
- browseOrDrag: descriptor.upload?.description ?? 'tallózás vagy behúzás',
4446
- formats: descriptor.upload?.formats ?? '',
4447
- maxSize: descriptor.upload?.maxSize ?? '',
4448
- upload: descriptor.upload?.uploadButtonTitle,
4449
- };
4450
- }
4451
- executeUpload(files) {
4452
- this.uiActionModel.uiAction.params = {
4453
- ...this.uiActionModel.uiAction.params,
4454
- _files: files,
4455
- isMultiple: this.config?.isMultiple,
4456
- param: 'INPUT',
4278
+ else {
4279
+ this.dialogType = this.descriptor.inputDialog ? 'inputDialog' : 'dialog';
4280
+ }
4281
+ this.constructForm();
4282
+ }
4283
+ getTitle() {
4284
+ return this.descriptor[this.dialogType].title;
4285
+ }
4286
+ getText() {
4287
+ return this.descriptor[this.dialogType].text ?? '';
4288
+ }
4289
+ getActionButtonLabel() {
4290
+ return this.descriptor[this.dialogType].actionButton.caption;
4291
+ }
4292
+ getActionButtonColor() {
4293
+ return this.descriptor[this.dialogType].actionButton.color;
4294
+ }
4295
+ getCancelButtonLabel() {
4296
+ return this.descriptor[this.dialogType].cancelButton.caption;
4297
+ }
4298
+ getCancelButtonColor() {
4299
+ return this.descriptor[this.dialogType].cancelButton.color;
4300
+ }
4301
+ constructForm() {
4302
+ let model = {};
4303
+ let inputName;
4304
+ if (this.service.inputTypeName === 'inputDialog') {
4305
+ inputName = 'input';
4306
+ }
4307
+ else {
4308
+ inputName = 'input2';
4309
+ }
4310
+ if (this.service.nodeName) {
4311
+ model[inputName] = this.service.nodeName;
4312
+ }
4313
+ else {
4314
+ model[inputName] = '';
4315
+ }
4316
+ let type;
4317
+ let inputType = `${inputName}Type`;
4318
+ if (this.service.action[inputType] === UiActionInputType.Textfield) {
4319
+ type = SmartFormWidgetType.TEXT_FIELD;
4320
+ }
4321
+ else {
4322
+ type = SmartFormWidgetType.TEXT_BOX;
4323
+ }
4324
+ let widgets = [
4325
+ {
4326
+ key: inputName,
4327
+ label: '',
4328
+ type,
4329
+ value: '',
4330
+ validators: [
4331
+ {
4332
+ validator: Validators.required,
4333
+ name: SmartValidatorName.required,
4334
+ errorMessage: 'Ez a mező kötelező',
4335
+ },
4336
+ ],
4337
+ placeholder: this.descriptor[this.dialogType].placeholder ?? '',
4338
+ showLabel: true,
4339
+ },
4340
+ ];
4341
+ if (widgets[0].type === SmartFormWidgetType.TEXT_FIELD && this.descriptor[this.dialogType]?.mask) {
4342
+ widgets[0].mask = this.descriptor[this.dialogType]?.mask;
4343
+ }
4344
+ this.folderForm = {
4345
+ direction: SmartFormWidgetDirection.COL,
4346
+ model,
4347
+ widgets,
4457
4348
  };
4458
- this.uiActionService.uiActionModel = this.uiActionModel;
4459
- this.uiActionService.execute(this.uiActionModel.uiAction);
4349
+ }
4350
+ save() {
4351
+ let form = this.folderFormChild.submitForm();
4352
+ if (form.invalidFields) {
4353
+ throw new Error('The form is invalid!');
4354
+ }
4355
+ this.service.onSave(form.model);
4356
+ }
4357
+ cancel() {
4358
+ this.service.cancel();
4460
4359
  }
4461
4360
  }
4462
- SmartFileUploaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartFileUploaderComponent, deps: [{ token: UiActionService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
4463
- SmartFileUploaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartFileUploaderComponent, selector: "smart-file-uploader4sc", inputs: { config: "config" }, usesOnChanges: true, ngImport: i0, template: "<smartfileuploader\n *ngIf=\"i18n\"\n [i18n]=\"i18n\"\n [fileFormats]=\"config?.fileFormats\"\n [isMultiple]=\"config?.isMultiple\"\n [maxSizeMb]=\"config?.maxSizeMb\"\n [uploadCallback]=\"executeUpload.bind(this)\"\n></smartfileuploader>\n", styles: [""], components: [{ type: i1$2.SmartfileuploaderComponent, selector: "smartfileuploader", inputs: ["uploadCallback", "fileFormats", "maxSizeMb", "i18n", "useIconButton", "isMultiple"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4464
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartFileUploaderComponent, decorators: [{
4361
+ UiActionInputDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogComponent, deps: [{ token: UiActionInputDialogService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
4362
+ UiActionInputDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionInputDialogComponent, selector: "smart-ui-action-input-dialog", viewQueries: [{ propertyName: "folderFormChild", first: true, predicate: ["form"], descendants: true }], ngImport: i0, template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<smartform #form [smartForm]=\"folderForm\"></smartform>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"save()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$2.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }, { type: i1$2.SmartformComponent, selector: "smartform", inputs: ["smartForm"] }] });
4363
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogComponent, decorators: [{
4465
4364
  type: Component,
4466
- args: [{ selector: 'smart-file-uploader4sc', template: "<smartfileuploader\n *ngIf=\"i18n\"\n [i18n]=\"i18n\"\n [fileFormats]=\"config?.fileFormats\"\n [isMultiple]=\"config?.isMultiple\"\n [maxSizeMb]=\"config?.maxSizeMb\"\n [uploadCallback]=\"executeUpload.bind(this)\"\n></smartfileuploader>\n", styles: [""] }]
4467
- }], ctorParameters: function () { return [{ type: UiActionService }, { type: UiActionDescriptorService }]; }, propDecorators: { config: [{
4468
- type: Input
4365
+ args: [{ selector: 'smart-ui-action-input-dialog', template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<smartform #form [smartForm]=\"folderForm\"></smartform>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"save()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"] }]
4366
+ }], ctorParameters: function () { return [{ type: UiActionInputDialogService }, { type: UiActionDescriptorService }]; }, propDecorators: { folderFormChild: [{
4367
+ type: ViewChild,
4368
+ args: ['form']
4469
4369
  }] } });
4470
4370
 
4471
- /**
4472
- * Custom HttpParameterCodec
4473
- * Workaround for https://github.com/angular/angular/issues/18261
4474
- */
4475
- class CustomHttpParameterCodec {
4476
- encodeKey(k) {
4477
- return encodeURIComponent(k);
4371
+ class UiActionInputDialogService extends SmartdialogService {
4372
+ constructor(dialog, router) {
4373
+ super(dialog, router);
4374
+ this._destroy$ = new Subject();
4375
+ this.onAction = new SmartSubject(this._destroy$);
4478
4376
  }
4479
- encodeValue(v) {
4480
- return encodeURIComponent(v);
4377
+ setDataAndOpenDialog(action, nodeName) {
4378
+ this.action = action;
4379
+ this.nodeName = nodeName;
4380
+ this.openDialog();
4481
4381
  }
4482
- decodeKey(k) {
4483
- return decodeURIComponent(k);
4382
+ openDialog() {
4383
+ this.params = undefined;
4384
+ this.onAction = new SmartSubject(this._destroy$);
4385
+ const dialogData = {
4386
+ content: {
4387
+ title: '',
4388
+ },
4389
+ size: {},
4390
+ customComponent: UiActionInputDialogComponent,
4391
+ };
4392
+ this.createDialog(dialogData, UiActionInputDialogComponent);
4484
4393
  }
4485
- decodeValue(v) {
4486
- return decodeURIComponent(v);
4394
+ async onSave(params) {
4395
+ this.params = params;
4396
+ this.onAction.complete();
4397
+ this.closeDialog();
4398
+ this.onAction = new SmartSubject(this._destroy$);
4399
+ }
4400
+ cancel() {
4401
+ this.onAction.complete();
4402
+ this.closeDialog();
4403
+ this.onAction = new SmartSubject(this._destroy$);
4487
4404
  }
4488
4405
  }
4406
+ UiActionInputDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
4407
+ UiActionInputDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogService, providedIn: 'root' });
4408
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogService, decorators: [{
4409
+ type: Injectable,
4410
+ args: [{
4411
+ providedIn: 'root',
4412
+ }]
4413
+ }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }]; } });
4489
4414
 
4490
- const BASE_PATH = new InjectionToken('basePath');
4491
- const COLLECTION_FORMATS = {
4492
- 'csv': ',',
4493
- 'tsv': ' ',
4494
- 'ssv': ' ',
4495
- 'pipes': '|'
4496
- };
4497
-
4498
- class Configuration {
4499
- constructor(configurationParameters = {}) {
4500
- this.apiKeys = configurationParameters.apiKeys;
4501
- this.username = configurationParameters.username;
4502
- this.password = configurationParameters.password;
4503
- this.accessToken = configurationParameters.accessToken;
4504
- this.basePath = configurationParameters.basePath;
4505
- this.withCredentials = configurationParameters.withCredentials;
4506
- this.encoder = configurationParameters.encoder;
4507
- if (configurationParameters.encodeParam) {
4508
- this.encodeParam = configurationParameters.encodeParam;
4509
- }
4510
- else {
4511
- this.encodeParam = param => this.defaultEncodeParam(param);
4512
- }
4513
- if (configurationParameters.credentials) {
4514
- this.credentials = configurationParameters.credentials;
4415
+ class UiActionFileUploadDialogComponent {
4416
+ constructor(service, manager) {
4417
+ this.service = service;
4418
+ this.manager = manager;
4419
+ this.code = this.service.action.code;
4420
+ this.setUp();
4421
+ }
4422
+ ngOnDestroy() {
4423
+ this.service._destroy$.next();
4424
+ this.cancel();
4425
+ }
4426
+ async setUp() {
4427
+ this.descriptor = await this.manager.getActionDescriptor(this.service.action);
4428
+ this.isMultiple = this.service.isMultiple;
4429
+ this.i18n = {
4430
+ addFile: this.descriptor.upload?.title ?? 'dokumentum hozzáadása',
4431
+ browseOrDrag: this.descriptor.upload?.description ?? 'tallózás vagy behúzás',
4432
+ formats: this.descriptor.upload?.formats ?? '',
4433
+ maxSize: this.descriptor.upload?.maxSize ?? '',
4434
+ upload: this.descriptor.upload?.uploadButtonTitle,
4435
+ };
4436
+ // TODO set max size and file formats by UiAction.params
4437
+ if (this.descriptor[this.service.inputTypeName]) {
4438
+ this.dialogType = this.service.inputTypeName;
4515
4439
  }
4516
4440
  else {
4517
- this.credentials = {};
4441
+ this.dialogType = this.descriptor.inputDialog ? 'inputDialog' : 'dialog';
4518
4442
  }
4519
4443
  }
4520
- /**
4521
- * Select the correct content-type to use for a request.
4522
- * Uses {@link Configuration#isJsonMime} to determine the correct content-type.
4523
- * If no content type is found return the first found type if the contentTypes is not empty
4524
- * @param contentTypes - the array of content types that are available for selection
4525
- * @returns the selected content-type or <code>undefined</code> if no selection could be made.
4526
- */
4527
- selectHeaderContentType(contentTypes) {
4528
- if (contentTypes.length === 0) {
4529
- return undefined;
4530
- }
4531
- const type = contentTypes.find((x) => this.isJsonMime(x));
4532
- if (type === undefined) {
4533
- return contentTypes[0];
4534
- }
4535
- return type;
4444
+ getTitle() {
4445
+ return this.descriptor[this.dialogType].title;
4536
4446
  }
4537
- /**
4538
- * Select the correct accept content-type to use for a request.
4539
- * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
4540
- * If no content type is found return the first found type if the contentTypes is not empty
4541
- * @param accepts - the array of content types that are available for selection.
4542
- * @returns the selected content-type or <code>undefined</code> if no selection could be made.
4543
- */
4544
- selectHeaderAccept(accepts) {
4545
- if (accepts.length === 0) {
4546
- return undefined;
4547
- }
4548
- const type = accepts.find((x) => this.isJsonMime(x));
4549
- if (type === undefined) {
4550
- return accepts[0];
4551
- }
4552
- return type;
4447
+ getText() {
4448
+ return this.descriptor[this.dialogType].text ?? '';
4553
4449
  }
4554
- /**
4555
- * Check if the given MIME is a JSON MIME.
4556
- * JSON MIME examples:
4557
- * application/json
4558
- * application/json; charset=UTF8
4559
- * APPLICATION/JSON
4560
- * application/vnd.company+json
4561
- * @param mime - MIME (Multipurpose Internet Mail Extensions)
4562
- * @return True if the given MIME is JSON, false otherwise.
4563
- */
4564
- isJsonMime(mime) {
4565
- const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
4566
- return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
4450
+ getActionButtonLabel() {
4451
+ return this.descriptor[this.dialogType].actionButton.caption;
4567
4452
  }
4568
- lookupCredential(key) {
4569
- const value = this.credentials[key];
4570
- return typeof value === 'function'
4571
- ? value()
4572
- : value;
4453
+ getActionButtonColor() {
4454
+ return this.descriptor[this.dialogType].actionButton.color;
4573
4455
  }
4574
- defaultEncodeParam(param) {
4575
- // This implementation exists as fallback for missing configuration
4576
- // and for backwards compatibility to older typescript-angular generator versions.
4577
- // It only works for the 'simple' parameter style.
4578
- // Date-handling only works for the 'date-time' format.
4579
- // All other styles and Date-formats are probably handled incorrectly.
4580
- //
4581
- // But: if that's all you need (i.e.: the most common use-case): no need for customization!
4582
- const value = param.dataFormat === 'date-time' && param.value instanceof Date
4583
- ? param.value.toISOString()
4584
- : param.value;
4585
- return encodeURIComponent(String(value));
4456
+ getCancelButtonLabel() {
4457
+ return this.descriptor[this.dialogType].cancelButton.caption;
4458
+ }
4459
+ getCancelButtonColor() {
4460
+ return this.descriptor[this.dialogType].cancelButton.color;
4461
+ }
4462
+ upload(files) {
4463
+ this.service.onSave(files);
4464
+ }
4465
+ cancel() {
4466
+ this.service.cancel();
4586
4467
  }
4587
4468
  }
4469
+ UiActionFileUploadDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogComponent, deps: [{ token: UiActionFileUploadDialogService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
4470
+ UiActionFileUploadDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionFileUploadDialogComponent, selector: "lib-ui-action-file-upload-dialog", ngImport: i0, template: "<div class=\"folderNameDialogContainer\">\n <div class=\"headerContainer\">\n <h3 class=\"color-accent-700\">\n {{ getTitle() }}\n </h3>\n <button mat-icon-button title=\"close\" (click)=\"cancel()\">\n <smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n </button>\n </div>\n <p>\n {{ getText() }}\n </p>\n <smartfileuploader\n [i18n]=\"i18n\"\n [fileFormats]=\"fileFormats\"\n [maxSizeMb]=\"maxSizeMb\"\n [uploadCallback]=\"upload.bind(this)\"\n [isMultiple]=\"isMultiple\"\n ></smartfileuploader>\n <div class=\"folderNameDialogButtonsContainer\">\n <button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n {{ getCancelButtonLabel() }}\n </button>\n <!-- <button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"upload()\">\n {{ getActionButtonLabel() }}\n </button> -->\n </div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$2.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }, { type: i1$2.SmartfileuploaderComponent, selector: "smartfileuploader", inputs: ["uploadCallback", "fileFormats", "maxSizeMb", "i18n", "useIconButton", "isMultiple"] }] });
4471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogComponent, decorators: [{
4472
+ type: Component,
4473
+ args: [{ selector: 'lib-ui-action-file-upload-dialog', template: "<div class=\"folderNameDialogContainer\">\n <div class=\"headerContainer\">\n <h3 class=\"color-accent-700\">\n {{ getTitle() }}\n </h3>\n <button mat-icon-button title=\"close\" (click)=\"cancel()\">\n <smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n </button>\n </div>\n <p>\n {{ getText() }}\n </p>\n <smartfileuploader\n [i18n]=\"i18n\"\n [fileFormats]=\"fileFormats\"\n [maxSizeMb]=\"maxSizeMb\"\n [uploadCallback]=\"upload.bind(this)\"\n [isMultiple]=\"isMultiple\"\n ></smartfileuploader>\n <div class=\"folderNameDialogButtonsContainer\">\n <button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n {{ getCancelButtonLabel() }}\n </button>\n <!-- <button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"upload()\">\n {{ getActionButtonLabel() }}\n </button> -->\n </div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"] }]
4474
+ }], ctorParameters: function () { return [{ type: UiActionFileUploadDialogService }, { type: UiActionDescriptorService }]; } });
4588
4475
 
4589
- /**
4590
- * Form layout definition
4591
- * Contains form layout definition objects.
4592
- *
4593
- * The version of the OpenAPI document: 1.0.0
4594
- * Contact: info@it4all.hu
4595
- *
4596
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
4597
- * https://openapi-generator.tech
4598
- * Do not edit the class manually.
4599
- */
4600
- class DefaultService {
4601
- constructor(httpClient, basePath, configuration) {
4602
- this.httpClient = httpClient;
4603
- this.basePath = 'http://localhost';
4604
- this.defaultHeaders = new HttpHeaders();
4605
- this.configuration = new Configuration();
4606
- if (configuration) {
4607
- this.configuration = configuration;
4476
+ class UiActionFileUploadDialogService extends SmartdialogService {
4477
+ constructor(dialog, router) {
4478
+ super(dialog, router);
4479
+ this._destroy$ = new Subject();
4480
+ this.onAction = new SmartSubject(this._destroy$);
4481
+ this.isMultiple = false;
4482
+ }
4483
+ setDataAndOpenDialog(action, nodeName) {
4484
+ this.action = action;
4485
+ this.nodeName = nodeName;
4486
+ this.openDialog();
4487
+ }
4488
+ openDialog() {
4489
+ this.files = undefined;
4490
+ this.onAction = new SmartSubject(this._destroy$);
4491
+ const dialogData = {
4492
+ content: {
4493
+ title: '',
4494
+ },
4495
+ size: {},
4496
+ customComponent: UiActionFileUploadDialogComponent,
4497
+ };
4498
+ this.createDialog(dialogData, UiActionFileUploadDialogComponent);
4499
+ }
4500
+ async onSave(files) {
4501
+ this.files = files;
4502
+ this.onAction.complete();
4503
+ this.closeDialog();
4504
+ this.onAction = new SmartSubject(this._destroy$);
4505
+ }
4506
+ cancel() {
4507
+ this.onAction.complete();
4508
+ this.closeDialog();
4509
+ this.onAction = new SmartSubject(this._destroy$);
4510
+ }
4511
+ }
4512
+ UiActionFileUploadDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
4513
+ UiActionFileUploadDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogService, providedIn: 'root' });
4514
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionFileUploadDialogService, decorators: [{
4515
+ type: Injectable,
4516
+ args: [{
4517
+ providedIn: 'root',
4518
+ }]
4519
+ }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }]; } });
4520
+
4521
+ class UiActionService {
4522
+ constructor(confirmDialogService, textFieldDialogService, fileUploadDialogService, _snackBar) {
4523
+ this.confirmDialogService = confirmDialogService;
4524
+ this.textFieldDialogService = textFieldDialogService;
4525
+ this.fileUploadDialogService = fileUploadDialogService;
4526
+ this._snackBar = _snackBar;
4527
+ this._destroy$ = new Subject();
4528
+ }
4529
+ ngOnDestroy() {
4530
+ this._destroy$.next();
4531
+ this._destroy$.complete();
4532
+ }
4533
+ async execute(uiAction, options) {
4534
+ let uiActionRequest;
4535
+ uiActionRequest = {
4536
+ code: uiAction.code,
4537
+ identifier: uiAction.identifier,
4538
+ params: uiAction.params ?? {},
4539
+ };
4540
+ if (uiAction.submit) {
4541
+ this.uiActionModel.serviceToUse.submit.next();
4542
+ try {
4543
+ await this.uiActionModel.serviceToUse.submit.toPromise();
4544
+ this.uiActionModel.serviceToUse.submit = new SmartSubject(this._destroy$);
4545
+ this.uiActionModel.serviceToUse.reSubscribeToChange.next();
4546
+ }
4547
+ catch (error) {
4548
+ console.error(error);
4549
+ this.uiActionModel.serviceToUse.submit = new SmartSubject(this._destroy$);
4550
+ this.uiActionModel.serviceToUse.reSubscribeToChange.next();
4551
+ return;
4552
+ }
4608
4553
  }
4609
- if (typeof this.configuration.basePath !== 'string') {
4610
- if (Array.isArray(basePath) && basePath.length > 0) {
4611
- basePath = basePath[0];
4554
+ if (uiAction.confirm) {
4555
+ this.confirmDialogService.action = uiAction;
4556
+ this.confirmDialogService.openDialog();
4557
+ await this.confirmDialogService.onAction.toPromise();
4558
+ if (!this.confirmDialogService.shouldDoAction) {
4559
+ return;
4612
4560
  }
4613
- if (typeof basePath !== 'string') {
4614
- basePath = this.basePath;
4561
+ }
4562
+ // InputType
4563
+ if (uiAction.inputType) {
4564
+ uiActionRequest = await this.handleInputType(uiAction.inputType, uiAction, uiActionRequest, 'inputDialog');
4565
+ if (!uiActionRequest) {
4566
+ return;
4567
+ }
4568
+ await new Promise((resolve) => setTimeout(resolve, 250));
4569
+ }
4570
+ // Input2Type
4571
+ if (uiAction.input2Type) {
4572
+ uiActionRequest = await this.handleInputType(uiAction.input2Type, uiAction, uiActionRequest, 'input2Dialog');
4573
+ if (!uiActionRequest) {
4574
+ return;
4575
+ }
4576
+ }
4577
+ if (this.uiActionModel.exception) {
4578
+ let response = await this.uiActionModel.serviceToUse.handleSpecificDemandsAsynchronously(uiAction, uiActionRequest);
4579
+ if (!response.shouldPerformAction || !response.uiActionRequest) {
4580
+ return;
4615
4581
  }
4616
- this.configuration.basePath = basePath;
4582
+ uiActionRequest = response.uiActionRequest;
4617
4583
  }
4618
- this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
4584
+ await this.performAction(uiAction, uiActionRequest, options);
4619
4585
  }
4620
- // @ts-ignore
4621
- addToHttpParams(httpParams, value, key) {
4622
- if (typeof value === "object" && value instanceof Date === false) {
4623
- httpParams = this.addToHttpParamsRecursive(httpParams, value);
4624
- }
4625
- else {
4626
- httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
4586
+ async handleInputType(inputType, uiAction, uiActionRequest, inputTypeName) {
4587
+ switch (inputType) {
4588
+ case UiActionInputType.None:
4589
+ return uiActionRequest;
4590
+ case UiActionInputType.Textarea:
4591
+ case UiActionInputType.Textfield:
4592
+ return await this.handleInputTypeTextField(inputTypeName, uiAction, uiActionRequest);
4593
+ case UiActionInputType.UserSelect:
4594
+ return await this.handleInputTypeUserSelect(inputTypeName, uiAction, uiActionRequest);
4595
+ case UiActionInputType.File:
4596
+ return await this.handleInputTypeUpload(inputTypeName, uiAction, uiActionRequest, false);
4597
+ case UiActionInputType.MultipleFiles:
4598
+ return await this.handleInputTypeUpload(inputTypeName, uiAction, uiActionRequest, true);
4599
+ default:
4600
+ return uiActionRequest;
4627
4601
  }
4628
- return httpParams;
4629
4602
  }
4630
- addToHttpParamsRecursive(httpParams, value, key) {
4631
- if (value == null) {
4632
- return httpParams;
4603
+ async handleInputTypeTextField(inputTypeName, uiAction, uiActionRequest) {
4604
+ let additionalParams = this.uiActionModel.serviceToUse.getAdditionalParams(uiAction);
4605
+ let inputType = inputTypeName === 'inputDialog' ? 'inputType' : 'input2Type';
4606
+ if (uiAction[inputType] === UiActionInputType.Textfield) {
4607
+ this.textFieldDialogService.nodeName = additionalParams.forTextField;
4633
4608
  }
4634
- if (typeof value === "object") {
4635
- if (Array.isArray(value)) {
4636
- value.forEach(elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
4637
- }
4638
- else if (value instanceof Date) {
4639
- if (key != null) {
4640
- httpParams = httpParams.append(key, value.toISOString().substr(0, 10));
4641
- }
4642
- else {
4643
- throw Error("key may not be null if value is Date");
4644
- }
4645
- }
4646
- else {
4647
- Object.keys(value).forEach(k => httpParams = this.addToHttpParamsRecursive(httpParams, value[k], key != null ? `${key}.${k}` : k));
4648
- }
4609
+ else if (uiAction[inputType] === UiActionInputType.Textarea) {
4610
+ this.textFieldDialogService.nodeName = additionalParams.forTextArea;
4649
4611
  }
4650
- else if (key != null) {
4651
- httpParams = httpParams.append(key, value);
4612
+ this.textFieldDialogService.inputTypeName = inputTypeName;
4613
+ this.textFieldDialogService.action = uiAction;
4614
+ this.textFieldDialogService.openDialog();
4615
+ await this.textFieldDialogService.onAction.toPromise();
4616
+ let params = this.textFieldDialogService.params;
4617
+ if (!params) {
4618
+ console.error('There was no response from InputDialog');
4619
+ return;
4652
4620
  }
4653
- else {
4654
- throw Error("key may not be null if value is not object or array");
4621
+ uiActionRequest.params = {
4622
+ ...uiActionRequest.params,
4623
+ ...params,
4624
+ };
4625
+ return uiActionRequest;
4626
+ }
4627
+ async handleInputTypeUpload(inputTypeName, uiAction, uiActionRequest, isMultiple) {
4628
+ this.fileUploadDialogService.inputTypeName = inputTypeName;
4629
+ this.fileUploadDialogService.action = uiAction;
4630
+ this.fileUploadDialogService.isMultiple = isMultiple;
4631
+ this.fileUploadDialogService.openDialog();
4632
+ await this.fileUploadDialogService.onAction.toPromise();
4633
+ let files = this.fileUploadDialogService.files;
4634
+ if (!files || !files.length) {
4635
+ console.error('There was no response from InputDialog');
4636
+ return;
4655
4637
  }
4656
- return httpParams;
4638
+ uiActionRequest.params = {
4639
+ ...uiActionRequest.params,
4640
+ _files: files,
4641
+ isMultiple,
4642
+ param: uiAction.inputType === 'file' || uiAction.inputType === 'multiple_files'
4643
+ ? 'INPUT'
4644
+ : 'INPUT2',
4645
+ };
4646
+ return uiActionRequest;
4657
4647
  }
4658
- nopePost(observe = 'body', reportProgress = false, options) {
4659
- let localVarHeaders = this.defaultHeaders;
4660
- let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
4661
- if (localVarHttpHeaderAcceptSelected === undefined) {
4662
- // to determine the Accept header
4663
- const httpHeaderAccepts = [];
4664
- localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
4648
+ async handleInputTypeUserSelect(inputTypeName, uiAction, uiActionRequest) {
4649
+ let response = await this.uiActionModel.serviceToUse.handleSpecificDemandsAsynchronously(uiAction, uiActionRequest);
4650
+ if (!response.shouldPerformAction || !response.uiActionRequest) {
4651
+ return;
4665
4652
  }
4666
- if (localVarHttpHeaderAcceptSelected !== undefined) {
4667
- localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
4653
+ uiActionRequest = response.uiActionRequest;
4654
+ return uiActionRequest;
4655
+ }
4656
+ async performAction(uiAction, uiActionRequest, options) {
4657
+ if (!uiActionRequest.params ||
4658
+ (uiActionRequest.params && !Object.keys(uiActionRequest.params).length)) {
4659
+ uiActionRequest.params = {
4660
+ model: this.uiActionModel.serviceToUse.getModel(),
4661
+ };
4668
4662
  }
4669
- let localVarHttpContext = options && options.context;
4670
- if (localVarHttpContext === undefined) {
4671
- localVarHttpContext = new HttpContext();
4663
+ else if (uiAction.submit) {
4664
+ uiActionRequest.params['model'] = this.uiActionModel.serviceToUse.getModel();
4672
4665
  }
4673
- let responseType_ = 'json';
4674
- if (localVarHttpHeaderAcceptSelected) {
4675
- if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
4676
- responseType_ = 'text';
4677
- }
4678
- else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
4679
- responseType_ = 'json';
4680
- }
4681
- else {
4682
- responseType_ = 'blob';
4666
+ try {
4667
+ await this.uiActionModel.serviceToUse.performUiActionRequest(uiActionRequest, options?.widgetId, options?.nodeId);
4668
+ if (this.uiActionModel.descriptor?.feedbackType === UiActionFeedbackType.Snackbar) {
4669
+ this.showSavedSnackbar(uiAction);
4683
4670
  }
4684
4671
  }
4685
- let localVarPath = `/nope`;
4686
- return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, {
4687
- context: localVarHttpContext,
4688
- responseType: responseType_,
4689
- withCredentials: this.configuration.withCredentials,
4690
- headers: localVarHeaders,
4691
- observe: observe,
4692
- reportProgress: reportProgress
4672
+ catch (error) {
4673
+ console.error(error);
4674
+ }
4675
+ }
4676
+ showSavedSnackbar(uiAction) {
4677
+ this._snackBar.openFromComponent(SuccessSnackBarComponent, {
4678
+ duration: 5 * 1000,
4679
+ panelClass: ['backgroundColor-accent'],
4680
+ data: uiAction,
4693
4681
  });
4694
4682
  }
4695
4683
  }
4696
- DefaultService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DefaultService, deps: [{ token: i1.HttpClient }, { token: BASE_PATH, optional: true }, { token: Configuration, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
4697
- DefaultService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DefaultService, providedIn: 'root' });
4698
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DefaultService, decorators: [{
4684
+ UiActionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionService, deps: [{ token: UiActionConfirmDialogService }, { token: UiActionInputDialogService }, { token: UiActionFileUploadDialogService }, { token: i4$5.MatSnackBar }], target: i0.ɵɵFactoryTarget.Injectable });
4685
+ UiActionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionService, providedIn: 'root' });
4686
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionService, decorators: [{
4699
4687
  type: Injectable,
4700
4688
  args: [{
4701
- providedIn: 'root'
4689
+ providedIn: 'root',
4702
4690
  }]
4703
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
4704
- type: Optional
4705
- }, {
4706
- type: Inject,
4707
- args: [BASE_PATH]
4708
- }] }, { type: Configuration, decorators: [{
4709
- type: Optional
4710
- }] }]; } });
4711
-
4712
- const APIS = [DefaultService];
4713
-
4714
- /**
4715
- * Form layout definition
4716
- * Contains form layout definition objects.
4717
- *
4718
- * The version of the OpenAPI document: 1.0.0
4719
- * Contact: info@it4all.hu
4720
- *
4721
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
4722
- * https://openapi-generator.tech
4723
- * Do not edit the class manually.
4724
- */
4725
- const ComponentType = {
4726
- Container: 'container',
4727
- Form: 'form',
4728
- Widget: 'widget'
4729
- };
4730
-
4731
- /**
4732
- * Form layout definition
4733
- * Contains form layout definition objects.
4734
- *
4735
- * The version of the OpenAPI document: 1.0.0
4736
- * Contact: info@it4all.hu
4737
- *
4738
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
4739
- * https://openapi-generator.tech
4740
- * Do not edit the class manually.
4741
- */
4742
- const ComponentWidgetType = {
4743
- Grid: 'grid'
4744
- };
4745
-
4746
- /**
4747
- * Form layout definition
4748
- * Contains form layout definition objects.
4749
- *
4750
- * The version of the OpenAPI document: 1.0.0
4751
- * Contact: info@it4all.hu
4752
- *
4753
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
4754
- * https://openapi-generator.tech
4755
- * Do not edit the class manually.
4756
- */
4757
- const LayoutDirection = {
4758
- Horizontal: 'horizontal',
4759
- Vertical: 'vertical'
4760
- };
4691
+ }], ctorParameters: function () { return [{ type: UiActionConfirmDialogService }, { type: UiActionInputDialogService }, { type: UiActionFileUploadDialogService }, { type: i4$5.MatSnackBar }]; } });
4761
4692
 
4762
- class ApiModule {
4763
- constructor(parentModule, http) {
4764
- if (parentModule) {
4765
- throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
4693
+ class UiActionToolbarComponent {
4694
+ constructor(service, inject) {
4695
+ this.service = service;
4696
+ this.inject = inject;
4697
+ this._destroy$ = new Subject();
4698
+ this.pressedButtonActive = true;
4699
+ // Injects the basic UiActionDescriptorService provided by the AppModule
4700
+ this.manager = inject.get(UiActionDescriptorService);
4701
+ this.subscribeToLanguageChange();
4702
+ }
4703
+ ngOnInit() {
4704
+ // Overrides the basic UiActionDescriptorService with a custom one if there is one
4705
+ if (this.uiActionDescriptorService) {
4706
+ this.manager = this.uiActionDescriptorService;
4707
+ this.subscribeToLanguageChange();
4708
+ }
4709
+ this.setUp();
4710
+ }
4711
+ ngOnChanges(changes) {
4712
+ let uiActionModels = changes['uiActionModels'].currentValue;
4713
+ if (uiActionModels) {
4714
+ this.uiActionModels = uiActionModels;
4715
+ this.setUp();
4716
+ }
4717
+ }
4718
+ ngOnDestroy() {
4719
+ this._destroy$.next();
4720
+ }
4721
+ subscribeToLanguageChange() {
4722
+ this.languageChangedSubscription?.unsubscribe();
4723
+ this.languageChangedSubscription = this.manager.languageChanged
4724
+ .pipe(takeUntil(this._destroy$))
4725
+ .subscribe(() => {
4726
+ this.setUp();
4727
+ });
4728
+ }
4729
+ async setUp() {
4730
+ this.uiActionModelsWithDescriptions = await Promise.all(this.uiActionModels.map(async (uiActionModel) => {
4731
+ uiActionModel.descriptor = await this.manager.getActionDescriptor(uiActionModel.uiAction);
4732
+ return uiActionModel;
4733
+ }));
4734
+ }
4735
+ async onActionClicked(event, uiActionModel) {
4736
+ event.stopPropagation();
4737
+ if (this.pressedButtonActive) {
4738
+ this.pressedButtonActive = false;
4739
+ this.service.uiActionModel = uiActionModel;
4740
+ let options = {
4741
+ nodeId: uiActionModel.nodeId,
4742
+ widgetId: uiActionModel.widgetId,
4743
+ };
4744
+ await this.service.execute(uiActionModel.uiAction, options);
4745
+ this.pressedButtonActive = true;
4766
4746
  }
4767
- if (!http) {
4768
- throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
4769
- 'See also https://github.com/angular/angular/issues/20575');
4747
+ }
4748
+ onActionDoubleClicked(event, uiActionModel) {
4749
+ event.stopPropagation();
4750
+ // We do not handle double clicks
4751
+ }
4752
+ getType(uiActionModel) {
4753
+ switch (uiActionModel.descriptor?.type) {
4754
+ case UiActionButtonType.Normal:
4755
+ return 'mat-button';
4756
+ case UiActionButtonType.Flat:
4757
+ return 'mat-flat-button';
4758
+ case UiActionButtonType.Raised:
4759
+ return 'mat-raised-button';
4760
+ case UiActionButtonType.Stroked:
4761
+ return 'mat-stroked-button';
4762
+ case UiActionButtonType.Icon:
4763
+ return 'mat-icon-button';
4764
+ case UiActionButtonType.MiniFab:
4765
+ return 'mat-mini-fab';
4766
+ case UiActionButtonType.Fab:
4767
+ return 'mat-fab';
4768
+ default:
4769
+ console.log(`Unhandled action button type case: ${uiActionModel.descriptor?.type}`);
4770
+ return `mat-button`;
4770
4771
  }
4771
4772
  }
4772
- static forRoot(configurationFactory) {
4773
- return {
4774
- ngModule: ApiModule,
4775
- providers: [{ provide: Configuration, useFactory: configurationFactory }]
4776
- };
4773
+ iconPosition() {
4774
+ return UiActionButtonIconPos;
4775
+ }
4776
+ isOnlyIcon(uiActionModel) {
4777
+ return (uiActionModel.descriptor?.type === UiActionButtonType.Icon ||
4778
+ uiActionModel.descriptor?.type === UiActionButtonType.MiniFab ||
4779
+ uiActionModel.descriptor?.type === UiActionButtonType.Fab);
4777
4780
  }
4778
4781
  }
4779
- ApiModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiModule, deps: [{ token: ApiModule, optional: true, skipSelf: true }, { token: i1.HttpClient, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
4780
- ApiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiModule });
4781
- ApiModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiModule, providers: [], imports: [[]] });
4782
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiModule, decorators: [{
4782
+ UiActionToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionToolbarComponent, deps: [{ token: UiActionService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
4783
+ UiActionToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionToolbarComponent, selector: "smart-ui-action-toolbar", inputs: { uiActionModels: "uiActionModels", uiActionDescriptorService: "uiActionDescriptorService" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"uiActionButtonsContainer\">\n <button\n *ngFor=\"let uiActionModel of uiActionModelsWithDescriptions\"\n mat-button\n [ngClass]=\"getType(uiActionModel)\"\n class=\"{{ uiActionModel.cssClass }}\"\n [color]=\"uiActionModel.descriptor?.color\"\n (click)=\"onActionClicked($event, uiActionModel)\"\n (dblclick)=\"onActionDoubleClicked($event, uiActionModel)\"\n >\n <div *ngIf=\"isOnlyIcon(uiActionModel); then iconOnly; else text\"></div>\n <ng-template #iconOnly>\n <smart-icon\n *ngIf=\"uiActionModel.descriptor?.icon\"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n <ng-template #text>\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Pre\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n {{ uiActionModel.descriptor?.title }}\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Post\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n </button>\n</div>\n", styles: [".uiActionButtonsContainer{display:flex;flex-direction:row;gap:1rem;flex-wrap:wrap;min-height:2.25rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$2.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }], directives: [{ type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4784
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionToolbarComponent, decorators: [{
4785
+ type: Component,
4786
+ args: [{ selector: 'smart-ui-action-toolbar', template: "<div class=\"uiActionButtonsContainer\">\n <button\n *ngFor=\"let uiActionModel of uiActionModelsWithDescriptions\"\n mat-button\n [ngClass]=\"getType(uiActionModel)\"\n class=\"{{ uiActionModel.cssClass }}\"\n [color]=\"uiActionModel.descriptor?.color\"\n (click)=\"onActionClicked($event, uiActionModel)\"\n (dblclick)=\"onActionDoubleClicked($event, uiActionModel)\"\n >\n <div *ngIf=\"isOnlyIcon(uiActionModel); then iconOnly; else text\"></div>\n <ng-template #iconOnly>\n <smart-icon\n *ngIf=\"uiActionModel.descriptor?.icon\"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n <ng-template #text>\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Pre\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n {{ uiActionModel.descriptor?.title }}\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Post\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n </button>\n</div>\n", styles: [".uiActionButtonsContainer{display:flex;flex-direction:row;gap:1rem;flex-wrap:wrap;min-height:2.25rem}\n"] }]
4787
+ }], ctorParameters: function () { return [{ type: UiActionService }, { type: i0.Injector }]; }, propDecorators: { uiActionModels: [{
4788
+ type: Input
4789
+ }], uiActionDescriptorService: [{
4790
+ type: Input
4791
+ }] } });
4792
+
4793
+ class SmartViewContextModule {
4794
+ }
4795
+ SmartViewContextModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
4796
+ SmartViewContextModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, declarations: [MessageDialogComponent,
4797
+ SmartViewContextErrorDialogComponent,
4798
+ SmartViewRedirect,
4799
+ UiActionToolbarComponent,
4800
+ UiActionInputDialogComponent,
4801
+ UiActionConfirmDialogComponent,
4802
+ UiActionFileUploadDialogComponent], imports: [CommonModule,
4803
+ HttpClientModule,
4804
+ MatCommonModule,
4805
+ MatButtonModule,
4806
+ MatIconModule,
4807
+ MatSnackBarModule,
4808
+ SmartIconModule,
4809
+ SmartformModule], exports: [UiActionToolbarComponent, UiActionInputDialogComponent] });
4810
+ SmartViewContextModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, providers: [
4811
+ SmartViewContextService,
4812
+ {
4813
+ provide: HTTP_INTERCEPTORS,
4814
+ useClass: SmartViewContextInterceptor,
4815
+ multi: true,
4816
+ },
4817
+ ], imports: [[
4818
+ CommonModule,
4819
+ HttpClientModule,
4820
+ MatCommonModule,
4821
+ MatButtonModule,
4822
+ MatIconModule,
4823
+ MatSnackBarModule,
4824
+ SmartIconModule,
4825
+ SmartformModule,
4826
+ ]] });
4827
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, decorators: [{
4783
4828
  type: NgModule,
4784
4829
  args: [{
4785
- imports: [],
4786
- declarations: [],
4787
- exports: [],
4788
- providers: []
4830
+ declarations: [
4831
+ MessageDialogComponent,
4832
+ SmartViewContextErrorDialogComponent,
4833
+ SmartViewRedirect,
4834
+ UiActionToolbarComponent,
4835
+ UiActionInputDialogComponent,
4836
+ UiActionConfirmDialogComponent,
4837
+ UiActionFileUploadDialogComponent,
4838
+ ],
4839
+ imports: [
4840
+ CommonModule,
4841
+ HttpClientModule,
4842
+ MatCommonModule,
4843
+ MatButtonModule,
4844
+ MatIconModule,
4845
+ MatSnackBarModule,
4846
+ SmartIconModule,
4847
+ SmartformModule,
4848
+ ],
4849
+ exports: [UiActionToolbarComponent, UiActionInputDialogComponent],
4850
+ providers: [
4851
+ SmartViewContextService,
4852
+ {
4853
+ provide: HTTP_INTERCEPTORS,
4854
+ useClass: SmartViewContextInterceptor,
4855
+ multi: true,
4856
+ },
4857
+ ],
4789
4858
  }]
4790
- }], ctorParameters: function () { return [{ type: ApiModule, decorators: [{
4791
- type: Optional
4792
- }, {
4793
- type: SkipSelf
4794
- }] }, { type: i1.HttpClient, decorators: [{
4795
- type: Optional
4796
- }] }]; } });
4859
+ }] });
4797
4860
 
4798
- class SmartComponentLayoutComponent {
4799
- constructor(layoutService) {
4800
- this.layoutService = layoutService;
4801
- }
4802
- ngOnInit() {
4803
- if (this.smartComponentLayout) {
4804
- this.setUp();
4805
- }
4861
+ var UiActionDialogType;
4862
+ (function (UiActionDialogType) {
4863
+ UiActionDialogType["inputDialog"] = "inputDialog";
4864
+ UiActionDialogType["confirmDialog"] = "confirmDialog";
4865
+ UiActionDialogType["dialog"] = "dialog";
4866
+ })(UiActionDialogType || (UiActionDialogType = {}));
4867
+
4868
+ /*
4869
+ * Public API Surface of smart-view-context
4870
+ */
4871
+
4872
+ class SmartFileUploaderComponent {
4873
+ constructor(uiActionService, uiActionDescriptorService) {
4874
+ this.uiActionService = uiActionService;
4875
+ this.uiActionDescriptorService = uiActionDescriptorService;
4806
4876
  }
4807
4877
  ngOnChanges(changes) {
4808
- this.smartComponentLayout = changes['smartComponentLayout'].currentValue;
4809
- if (this.smartComponentLayout) {
4878
+ this.config = changes['config'].currentValue;
4879
+ if (this.config) {
4810
4880
  this.setUp();
4811
4881
  }
4812
4882
  }
4813
- setUp() {
4814
- this.uuid = this.smartComponentLayout?.parentComponent.uuid;
4815
- if (this.smartComponentLayout?.expandable) {
4816
- this.constructExpandableSection();
4817
- }
4818
- else if (this.smartComponentLayout?.type === ComponentType.Form) {
4819
- this.constructForm();
4820
- }
4821
- else if (this.smartComponentLayout?.type === ComponentType.Widget) {
4822
- if (this.smartComponentLayout.widget?.type === ComponentWidgetType.Grid) {
4823
- this.constructGrid();
4824
- }
4883
+ async setUp() {
4884
+ this.uiActionModel = this.config?.smartComponent.uiActionModels.find((uiActionModel) => uiActionModel.uiAction.code === this.config?.uiActionCode);
4885
+ if (!this.uiActionModel) {
4886
+ throw new Error(`UiAction with code ${this.config?.uiActionCode} could not found`);
4825
4887
  }
4826
- }
4827
- type() {
4828
- return ComponentType;
4829
- }
4830
- constructExpandableSection() {
4831
- let data = { ...this.smartComponentLayout };
4832
- data.expandable = false;
4833
- this.expandableSection = {
4834
- title: this.smartComponentLayout?.expandableSectionLabel ?? '',
4835
- data,
4836
- inputName: 'smartComponentLayout',
4837
- customComponent: SmartComponentLayoutComponent,
4838
- };
4839
- }
4840
- constructForm() {
4841
- const widgets = this.layoutService.render({
4842
- layoutDefinitions: this.smartComponentLayout?.form,
4843
- });
4844
- this.smartForm = {
4845
- direction: SmartFormWidgetDirection.COL,
4846
- model: this.smartComponentLayout?.parentComponent.model,
4847
- constraints: this.smartComponentLayout?.parentComponent.model?.constraints,
4848
- widgets,
4888
+ const descriptor = await this.uiActionDescriptorService.getActionDescriptor(this.uiActionModel.uiAction);
4889
+ this.i18n = {
4890
+ addFile: descriptor.upload?.title ?? 'dokumentum hozzáadása',
4891
+ browseOrDrag: descriptor.upload?.description ?? 'tallózás vagy behúzás',
4892
+ formats: descriptor.upload?.formats ?? '',
4893
+ maxSize: descriptor.upload?.maxSize ?? '',
4894
+ upload: descriptor.upload?.uploadButtonTitle,
4849
4895
  };
4850
- this.smartComponentLayout?.parentComponent.addForm(
4851
- // unique identifier for the form
4852
- `form_${this.makeid(5)}`, this.smartForm, this.formChild);
4853
- }
4854
- makeid(length) {
4855
- let result = '';
4856
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
4857
- const charactersLength = characters.length;
4858
- let counter = 0;
4859
- while (counter < length) {
4860
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
4861
- counter += 1;
4862
- }
4863
- return result;
4864
4896
  }
4865
- constructGrid() {
4866
- this.smartGrid = {
4867
- gridIdentifier: this.smartComponentLayout?.widget?.gridIdentifier,
4868
- gridModel: {
4869
- page: {},
4870
- },
4871
- layoutDef: SmartLayoutDef.TABLE,
4897
+ executeUpload(files) {
4898
+ this.uiActionModel.uiAction.params = {
4899
+ ...this.uiActionModel.uiAction.params,
4900
+ _files: files,
4901
+ isMultiple: this.config?.isMultiple,
4902
+ param: 'INPUT',
4872
4903
  };
4873
- this.smartGrid = this.smartComponentLayout?.parentComponent.addGrid(this.smartGrid, {
4874
- rowUiActionType: GridUiActionType.POPUP_MENU,
4875
- }, false, this.gridChild);
4904
+ this.uiActionService.uiActionModel = this.uiActionModel;
4905
+ this.uiActionService.execute(this.uiActionModel.uiAction);
4876
4906
  }
4877
4907
  }
4878
- SmartComponentLayoutComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartComponentLayoutComponent, deps: [{ token: i1$2.SmartformLayoutDefinitionService }], target: i0.ɵɵFactoryTarget.Component });
4879
- SmartComponentLayoutComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartComponentLayoutComponent, selector: "smart-component-layout", inputs: { smartComponentLayout: "smartComponentLayout" }, viewQueries: [{ propertyName: "formChild", first: true, predicate: ["form"], descendants: true }, { propertyName: "gridChild", first: true, predicate: ["grid"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div *ngIf=\"smartComponentLayout?.expandable; then expandable; else normal\"> </div>\n\n<ng-template #expandable>\n <smart-expandable-section\n *ngIf=\"expandableSection\"\n [data]=\"expandableSection\"\n ></smart-expandable-section>\n</ng-template>\n\n<ng-template #normal>\n <div\n *ngIf=\"smartComponentLayout?.type === type().Container\"\n [ngClass]=\"smartComponentLayout?.direction ?? 'vertical'\"\n >\n <smart-component-layout\n [smartComponentLayout]=\"layout\"\n *ngFor=\"let layout of smartComponentLayout?.components\"\n ></smart-component-layout>\n </div>\n <smartform #form [smartForm]=\"smartForm\"></smartform>\n <smart-grid #grid [smartGrid]=\"smartGrid\" [uuid]=\"uuid!\"></smart-grid>\n</ng-template>\n", styles: [".horizontal{display:flex;flex-direction:row}.vertical{display:flex;flex-direction:column}\n"], components: [{ type: i2$2.ExpandableSectionComponent, selector: "smart-expandable-section", inputs: ["data", "index"] }, { type: SmartComponentLayoutComponent, selector: "smart-component-layout", inputs: ["smartComponentLayout"] }, { type: i1$2.SmartformComponent, selector: "smartform", inputs: ["smartForm"] }, { type: i3$2.SmartGridComponent, selector: "smart-grid", inputs: ["smartGrid", "uuid", "dev"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
4880
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartComponentLayoutComponent, decorators: [{
4908
+ SmartFileUploaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartFileUploaderComponent, deps: [{ token: UiActionService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
4909
+ SmartFileUploaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartFileUploaderComponent, selector: "smart-file-uploader4sc", inputs: { config: "config" }, usesOnChanges: true, ngImport: i0, template: "<smartfileuploader\n *ngIf=\"i18n\"\n [i18n]=\"i18n\"\n [fileFormats]=\"config?.fileFormats\"\n [isMultiple]=\"config?.isMultiple\"\n [maxSizeMb]=\"config?.maxSizeMb\"\n [uploadCallback]=\"executeUpload.bind(this)\"\n></smartfileuploader>\n", styles: [""], components: [{ type: i1$2.SmartfileuploaderComponent, selector: "smartfileuploader", inputs: ["uploadCallback", "fileFormats", "maxSizeMb", "i18n", "useIconButton", "isMultiple"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4910
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartFileUploaderComponent, decorators: [{
4881
4911
  type: Component,
4882
- args: [{ selector: 'smart-component-layout', template: "<div *ngIf=\"smartComponentLayout?.expandable; then expandable; else normal\"> </div>\n\n<ng-template #expandable>\n <smart-expandable-section\n *ngIf=\"expandableSection\"\n [data]=\"expandableSection\"\n ></smart-expandable-section>\n</ng-template>\n\n<ng-template #normal>\n <div\n *ngIf=\"smartComponentLayout?.type === type().Container\"\n [ngClass]=\"smartComponentLayout?.direction ?? 'vertical'\"\n >\n <smart-component-layout\n [smartComponentLayout]=\"layout\"\n *ngFor=\"let layout of smartComponentLayout?.components\"\n ></smart-component-layout>\n </div>\n <smartform #form [smartForm]=\"smartForm\"></smartform>\n <smart-grid #grid [smartGrid]=\"smartGrid\" [uuid]=\"uuid!\"></smart-grid>\n</ng-template>\n", styles: [".horizontal{display:flex;flex-direction:row}.vertical{display:flex;flex-direction:column}\n"] }]
4883
- }], ctorParameters: function () { return [{ type: i1$2.SmartformLayoutDefinitionService }]; }, propDecorators: { smartComponentLayout: [{
4912
+ args: [{ selector: 'smart-file-uploader4sc', template: "<smartfileuploader\n *ngIf=\"i18n\"\n [i18n]=\"i18n\"\n [fileFormats]=\"config?.fileFormats\"\n [isMultiple]=\"config?.isMultiple\"\n [maxSizeMb]=\"config?.maxSizeMb\"\n [uploadCallback]=\"executeUpload.bind(this)\"\n></smartfileuploader>\n", styles: [""] }]
4913
+ }], ctorParameters: function () { return [{ type: UiActionService }, { type: UiActionDescriptorService }]; }, propDecorators: { config: [{
4884
4914
  type: Input
4885
- }], formChild: [{
4886
- type: ViewChild,
4887
- args: ['form']
4888
- }], gridChild: [{
4889
- type: ViewChild,
4890
- args: ['grid']
4891
4915
  }] } });
4892
4916
 
4893
4917
  class SmartNgClientModule {
@@ -4899,7 +4923,8 @@ SmartNgClientModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", ver
4899
4923
  SmartViewContextModule,
4900
4924
  SmartformModule,
4901
4925
  SmartGridModule,
4902
- SmartExpandableSectionModule], exports: [SmartSessionModule,
4926
+ SmartExpandableSectionModule,
4927
+ SmarttreeModule], exports: [SmartSessionModule,
4903
4928
  SmartViewContextModule,
4904
4929
  SmartFileUploaderComponent,
4905
4930
  SmartComponentLayoutComponent] });
@@ -4911,6 +4936,7 @@ SmartNgClientModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
4911
4936
  SmartformModule,
4912
4937
  SmartGridModule,
4913
4938
  SmartExpandableSectionModule,
4939
+ SmarttreeModule,
4914
4940
  ], SmartSessionModule,
4915
4941
  SmartViewContextModule] });
4916
4942
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartNgClientModule, decorators: [{
@@ -4925,6 +4951,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
4925
4951
  SmartformModule,
4926
4952
  SmartGridModule,
4927
4953
  SmartExpandableSectionModule,
4954
+ SmarttreeModule,
4928
4955
  ],
4929
4956
  exports: [
4930
4957
  SmartSessionModule,
@@ -4953,6 +4980,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
4953
4980
  type: Injectable
4954
4981
  }] });
4955
4982
 
4983
+ // import {
4984
+ // FilterExpressionFieldList,
4985
+ // SmartFilter,
4986
+ // SmartFilterComponent,
4987
+ // SmartFilterType,
4988
+ // } from '@smartbit4all/filter';
4956
4989
  let SmartComponentApiClient = class SmartComponentApiClient {
4957
4990
  constructor(inject, auth, pageName) {
4958
4991
  this.inject = inject;
@@ -5180,6 +5213,25 @@ let SmartComponentApiClient = class SmartComponentApiClient {
5180
5213
  maxSizeMb,
5181
5214
  };
5182
5215
  }
5216
+ // public addFilter(
5217
+ // smartFilterId: string,
5218
+ // filter: FilterExpressionFieldList,
5219
+ // type: SmartFilterType,
5220
+ // smartFilterComponent: SmartFilterComponent,
5221
+ // isDefault?: boolean
5222
+ // ): SmartFilter {
5223
+ // const smartFilter: SmartFilter = {
5224
+ // data: filter.filters,
5225
+ // type,
5226
+ // translateService: this.translate,
5227
+ // };
5228
+ // this.widgets.addWidget(smartFilterId, smartFilterComponent);
5229
+ // if (isDefault) {
5230
+ // this.smartFilter = smartFilter;
5231
+ // return this.smartFilter!;
5232
+ // }
5233
+ // return smartFilter;
5234
+ // }
5183
5235
  // #region handle changes
5184
5236
  handleValueChanges(valueChange) {
5185
5237
  let dataChange;