barsa-novin-ray-core 2.3.94 → 2.3.96

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,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, inject, ElementRef, Input, ChangeDetectionStrategy, Component, Pipe, ComponentFactoryResolver, Injector, ApplicationRef, Compiler, DOCUMENT, NgModuleFactory, InjectionToken, NgZone, EventEmitter, ChangeDetectorRef, Renderer2, HostBinding, Output, HostListener, ViewContainerRef, ViewChild, signal, Directive, TemplateRef, input, NgModule, NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA, provideAppInitializer, ErrorHandler } from '@angular/core';
3
- import { Subject, from, BehaviorSubject, of, exhaustMap, map as map$1, combineLatest, withLatestFrom as withLatestFrom$1, fromEvent, forkJoin, takeUntil as takeUntil$1, filter as filter$1, throwError, merge, interval, tap as tap$1, concatMap as concatMap$1, catchError as catchError$1, finalize as finalize$1, take, debounceTime as debounceTime$1, skip, Observable, timer, mergeWith, Subscription } from 'rxjs';
3
+ import { Subject, from, BehaviorSubject, of, exhaustMap, map as map$1, combineLatest, withLatestFrom as withLatestFrom$1, fromEvent, forkJoin, takeUntil as takeUntil$1, filter as filter$1, throwError, merge, interval, concatMap as concatMap$1, catchError as catchError$1, finalize as finalize$1, take, debounceTime as debounceTime$1, skip, Observable, tap as tap$1, timer, mergeWith, Subscription } from 'rxjs';
4
4
  import * as i1 from '@angular/router';
5
5
  import { Router, NavigationEnd, ActivatedRoute, RouterEvent, NavigationStart, RouterModule } from '@angular/router';
6
6
  import { DomSanitizer, Title } from '@angular/platform-browser';
@@ -6250,7 +6250,9 @@ class ContainerService {
6250
6250
  this.oldActiveSystem = null;
6251
6251
  this.detachParent = true;
6252
6252
  this.masterDetails = false;
6253
+ this.state = 'attach';
6253
6254
  this.isMobile = getDeviceIsMobile();
6255
+ this.addModules = new Subject();
6254
6256
  this._activatedRoute = inject(ActivatedRoute);
6255
6257
  this._router = inject(Router);
6256
6258
  this._portalService = inject(PortalService);
@@ -6271,6 +6273,7 @@ class ContainerService {
6271
6273
  }
6272
6274
  setViewContainerRef(viewContainerRef) {
6273
6275
  this._viewContainerRef = viewContainerRef;
6276
+ this.state = 'attach';
6274
6277
  if (this._parentService && this.detachParent) {
6275
6278
  this._parentService.detach();
6276
6279
  }
@@ -6310,6 +6313,7 @@ class ContainerService {
6310
6313
  }
6311
6314
  detach() {
6312
6315
  this._setScrollPosition();
6316
+ this.state = 'detach';
6313
6317
  this._viewRef = this._viewContainerRef.detach();
6314
6318
  }
6315
6319
  _setScrollPosition() {
@@ -6341,6 +6345,9 @@ class ContainerService {
6341
6345
  this._viewContainerRef.insert(this._viewRef);
6342
6346
  this._restoreScrollPostion();
6343
6347
  }
6348
+ else {
6349
+ this.addModules.next();
6350
+ }
6344
6351
  }
6345
6352
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: ContainerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
6346
6353
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: ContainerService }); }
@@ -7795,35 +7802,16 @@ const NOTIFICATION_WEBWORKER_FACTORY = new InjectionToken('notificaion-worker');
7795
7802
 
7796
7803
  class ServiceWorkerNotificationService {
7797
7804
  constructor() {
7798
- this.hasRegistration = false;
7799
7805
  this._logService = inject(LogService);
7800
7806
  this._swPush = inject(SwPush);
7801
7807
  this._portalService = inject(PortalService);
7802
- this._notificationPermissionAllowed = true;
7803
- const _logService = this._logService;
7804
- const _swPush = this._swPush;
7805
- _logService.info(`swPush enable ${_swPush.isEnabled}`);
7806
- _swPush.notificationClicks.pipe(tap$1((c) => console.log(c))).subscribe((e) => {
7807
- if (!e.notification.tag) {
7808
- return;
7809
- }
7810
- this.closeNotifications([e.notification.tag]);
7811
- let actionTitle = e.action;
7812
- if (actionTitle === '') {
7813
- actionTitle = 'show';
7814
- }
7815
- if (!BarsaApi?.LoginFormData?.IsUserLoggedIn) {
7816
- return;
7817
- }
7818
- this._portalService.ExecuteNotificationAction(e.notification.tag, actionTitle);
7819
- // TODO:exeucte action
7820
- // not handled!!
7821
- });
7822
- this.getSw().then((c) => (this.hasRegistration = !!c));
7823
- this.handlePermission();
7808
+ this._notificationPermissionAllowed = false;
7809
+ this._hasRegistration = false;
7810
+ this.init();
7824
7811
  }
7812
+ // بررسی وضعیت فعلی
7825
7813
  get isEnabled() {
7826
- return this._swPush.isEnabled && this.hasRegistration && this._notificationPermissionAllowed;
7814
+ return this._swPush.isEnabled && this._hasRegistration && this._notificationPermissionAllowed;
7827
7815
  }
7828
7816
  async closeNotifications(tags) {
7829
7817
  const sw = await this.getSw();
@@ -7837,6 +7825,7 @@ class ServiceWorkerNotificationService {
7837
7825
  }
7838
7826
  });
7839
7827
  }
7828
+ // نمایش دستی نوتیفیکیشن (برای تست)
7840
7829
  async showNotification(payload) {
7841
7830
  const sw = await this.getSw();
7842
7831
  if (!sw) {
@@ -7876,43 +7865,40 @@ class ServiceWorkerNotificationService {
7876
7865
  data
7877
7866
  });
7878
7867
  }
7879
- handlePermission() {
7880
- if (!navigator?.permissions?.query) {
7881
- return;
7882
- }
7883
- return navigator.permissions
7884
- .query({ name: 'notifications' })
7885
- .then(this.permissionQuery.bind(this))
7886
- .catch(this.permissionError.bind(this));
7868
+ async init() {
7869
+ this._logService.info(`SwPush enabled: ${this._swPush.isEnabled}`);
7870
+ // مدیریت کلیک روی نوتیفیکیشن‌ها
7871
+ this._swPush.notificationClicks.subscribe((e) => {
7872
+ if (!e.notification.tag) {
7873
+ return;
7874
+ }
7875
+ const actionTitle = e.action || 'show';
7876
+ if (!BarsaApi?.LoginFormData?.IsUserLoggedIn) {
7877
+ return;
7878
+ }
7879
+ this._portalService.ExecuteNotificationAction(e.notification.tag, actionTitle);
7880
+ });
7881
+ // بررسی مجوز و ثبت سرویس‌ورکر
7882
+ await this.registerServiceWorker();
7883
+ await this.requestPermission();
7887
7884
  }
7888
- permissionQuery(result) {
7889
- let newPrompt;
7890
- if (result.state === 'granted') {
7891
- // notifications allowed, go wild
7892
- }
7893
- else if (result.state === 'prompt') {
7894
- // we can ask the user
7895
- newPrompt = Notification.requestPermission();
7885
+ async requestPermission() {
7886
+ if (Notification.permission === 'default') {
7887
+ await Notification.requestPermission();
7896
7888
  }
7897
- else if (result.state === 'denied') {
7898
- // notifications were disabled
7899
- this._notificationPermissionAllowed = false;
7900
- }
7901
- result.onchange = () => console.log({ updatedPermission: result });
7902
- return newPrompt || result;
7889
+ this._notificationPermissionAllowed = Notification.permission === 'granted';
7903
7890
  }
7904
- permissionError(error) {
7905
- this._notificationPermissionAllowed = false;
7906
- console.error(error);
7891
+ async registerServiceWorker() {
7892
+ if (!('serviceWorker' in navigator)) {
7893
+ return;
7894
+ }
7895
+ const reg = await navigator.serviceWorker.getRegistration();
7896
+ this._hasRegistration = !!reg;
7907
7897
  }
7908
7898
  async getSw() {
7909
- if (!navigator.serviceWorker) {
7910
- this.hasRegistration = false;
7911
- return undefined;
7912
- }
7913
- const x = await navigator.serviceWorker.getRegistration('custom-ngsw-worker.js');
7914
- this.hasRegistration = !!x;
7915
- return x;
7899
+ const reg = await navigator.serviceWorker.getRegistration();
7900
+ this._hasRegistration = !!reg;
7901
+ return reg;
7916
7902
  }
7917
7903
  _isSupported() {
7918
7904
  if (!('serviceWorker' in navigator)) {
@@ -9329,6 +9315,7 @@ class ContainerComponent extends BaseComponent {
9329
9315
  this._renderer2 = inject(Renderer2);
9330
9316
  this._dialogService = inject(DIALOG_SERVICE, { optional: true });
9331
9317
  this._containerServiceParent = inject(ContainerService, { self: true, optional: true });
9318
+ this._containerService = inject(ContainerService);
9332
9319
  this._formDialogComponent = inject(FORM_DIALOG_COMPONENT, { optional: true });
9333
9320
  this.oldContainerContainer = this._barsaDialogService.containerComponent;
9334
9321
  this._barsaDialogService.containerComponent = this;
@@ -9351,9 +9338,7 @@ class ContainerComponent extends BaseComponent {
9351
9338
  this._containerServiceParent?.navigate(navigation, isRelative, queryParams, data);
9352
9339
  };
9353
9340
  super.ngOnInit();
9354
- if (this._containerServiceParent) {
9355
- this._containerServiceParent.setViewContainerRef(this._vcr);
9356
- }
9341
+ this._containerService?.setViewContainerRef(this.containerRef);
9357
9342
  }
9358
9343
  ngOnDestroy() {
9359
9344
  BarsaApi.Bw.FormHandler = this.parentContainer;
@@ -9392,10 +9377,12 @@ class PageBaseComponent extends ContainerComponent {
9392
9377
  super(...arguments);
9393
9378
  this.hasRoute = true;
9394
9379
  this.fullscreen = true;
9380
+ this.componentsAddedToPage = false;
9395
9381
  }
9396
9382
  ngAfterViewInit() {
9397
9383
  super.ngAfterViewInit();
9398
- this.addModulesToDom();
9384
+ this._containerService.state === 'attach' && this.addModulesToDom();
9385
+ this._containerService?.addModules.pipe(takeUntil(this._onDestroy$)).subscribe(() => this.addModulesToDom());
9399
9386
  }
9400
9387
  addModulesToDom() {
9401
9388
  this.getData$()
@@ -9442,6 +9429,9 @@ class PageBaseComponent extends ContainerComponent {
9442
9429
  return controlUi;
9443
9430
  }
9444
9431
  addModulesToPage(modules) {
9432
+ if (this.componentsAddedToPage) {
9433
+ return;
9434
+ }
9445
9435
  modules = modules.sort((a, b) => (Number(a.OrderNumber) > Number(b.OrderNumber) ? 1 : -1));
9446
9436
  from(modules)
9447
9437
  .pipe(takeUntil(this._onDestroy$), concatMap((module) => this.getComponentFactory(module.Component).pipe(tap((controlUi) => {
@@ -9454,7 +9444,10 @@ class PageBaseComponent extends ContainerComponent {
9454
9444
  this._vcr.insert(controlUi.hostView);
9455
9445
  }
9456
9446
  }))))
9457
- .subscribe(() => this._cdr.detectChanges());
9447
+ .subscribe(() => {
9448
+ this.componentsAddedToPage = true;
9449
+ this._cdr.detectChanges();
9450
+ });
9458
9451
  }
9459
9452
  getComponentFactory(uiComponent) {
9460
9453
  return this._portalService.getComponent(uiComponent.Module, uiComponent.ModuleFileName, uiComponent.Name, uiComponent.Selector, this._injector);
@@ -11110,40 +11103,40 @@ class FormPageComponent extends FormPageBaseComponent {
11110
11103
  this.absolutePageClass = false;
11111
11104
  }
11112
11105
  ngOnInit() {
11113
- this.containerRef = this.formRef.vcr; // it must be first because we change containerRef
11106
+ this.containerRef.insert(this._placeHolderTemplate.createEmbeddedView(this, this._injector));
11114
11107
  super.ngOnInit();
11115
11108
  }
11116
- ngAfterViewInit() {
11117
- super.ngAfterViewInit();
11118
- if (!this._el.nativeElement.classList.contains('absolute-page-removed')) {
11119
- this.absolutePageClass = true;
11120
- }
11121
- }
11122
11109
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: FormPageComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11123
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.6", type: FormPageComponent, isStandalone: false, selector: "bnrc-form-page", inputs: { formPanelCtrlr: "formPanelCtrlr" }, host: { properties: { "class.section": "this.sectionClass", "class.absolute-page": "this.absolutePageClass" } }, providers: [FormService, ContainerService], viewQueries: [{ propertyName: "formRef", first: true, predicate: FormComponent, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
11124
- <bnrc-form
11125
- [formPanelCtrl]="formPanelCtrlr"
11126
- [formPanelCtrlId]="formpanelCtrlrId"
11127
- [params]="params"
11128
- (formClose)="onFormClose()"
11129
- ></bnrc-form>
11110
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.6", type: FormPageComponent, isStandalone: false, selector: "bnrc-form-page", inputs: { formPanelCtrlr: "formPanelCtrlr" }, host: { properties: { "class.section": "this.sectionClass", "class.absolute-page": "this.absolutePageClass" } }, providers: [FormService, ContainerService], viewQueries: [{ propertyName: "_placeHolderTemplate", first: true, predicate: ["placeHolderTemplate"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
11111
+ <ng-template #placeHolderTemplate>
11112
+ <bnrc-form
11113
+ [formPanelCtrl]="formPanelCtrlr"
11114
+ [formPanelCtrlId]="formpanelCtrlrId"
11115
+ [params]="params"
11116
+ (formClose)="onFormClose()"
11117
+ ></bnrc-form>
11118
+ </ng-template>
11119
+ <ng-container #containerRef> </ng-container>
11130
11120
  <router-outlet></router-outlet>
11131
11121
  `, isInline: true, styles: [":host{display:block;background:var(--sapBackgroundColor)}\n"], dependencies: [{ kind: "directive", type: i1.RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }, { kind: "component", type: FormComponent, selector: "bnrc-form", inputs: ["params", "customFormPanelUi", "formPanelCtrl", "UlvMainCtrlr", "formPanelCtrlId", "saveOnChange", "inlineEditInReport"], outputs: ["titleChanged", "moChanged", "formClose", "uiComponent", "formRendered", "bruleAction", "beforeTransition", "afterTransition"] }, { kind: "directive", type: FormCloseDirective, selector: "[formClose]", inputs: ["isMobile"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
11132
11122
  }
11133
11123
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: FormPageComponent, decorators: [{
11134
11124
  type: Component,
11135
11125
  args: [{ selector: 'bnrc-form-page', template: `
11136
- <bnrc-form
11137
- [formPanelCtrl]="formPanelCtrlr"
11138
- [formPanelCtrlId]="formpanelCtrlrId"
11139
- [params]="params"
11140
- (formClose)="onFormClose()"
11141
- ></bnrc-form>
11126
+ <ng-template #placeHolderTemplate>
11127
+ <bnrc-form
11128
+ [formPanelCtrl]="formPanelCtrlr"
11129
+ [formPanelCtrlId]="formpanelCtrlrId"
11130
+ [params]="params"
11131
+ (formClose)="onFormClose()"
11132
+ ></bnrc-form>
11133
+ </ng-template>
11134
+ <ng-container #containerRef> </ng-container>
11142
11135
  <router-outlet></router-outlet>
11143
11136
  `, providers: [FormService, ContainerService], changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, styles: [":host{display:block;background:var(--sapBackgroundColor)}\n"] }]
11144
- }], propDecorators: { formRef: [{
11137
+ }], propDecorators: { _placeHolderTemplate: [{
11145
11138
  type: ViewChild,
11146
- args: [FormComponent, { static: true }]
11139
+ args: ['placeHolderTemplate', { static: true }]
11147
11140
  }], formPanelCtrlr: [{
11148
11141
  type: Input
11149
11142
  }], sectionClass: [{
@@ -13004,7 +12997,7 @@ class RootPortalComponent extends PageBaseComponent {
13004
12997
  }
13005
12998
  }
13006
12999
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: RootPortalComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
13007
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: RootPortalComponent, isStandalone: false, selector: "bnrc-root-portal", host: { properties: { "attr.dir": "this._dir", "attr.devicesize": "this._deviceSize" } }, viewQueries: [{ propertyName: "sectionRef", first: true, predicate: ["sectionRef"], descendants: true }, { propertyName: "footerRefVcr", first: true, predicate: ["footerRef"], descendants: true, read: ViewContainerRef }], usesInheritance: true, ngImport: i0, template: `
13000
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: RootPortalComponent, isStandalone: false, selector: "bnrc-root-portal", host: { properties: { "attr.dir": "this._dir", "attr.devicesize": "this._deviceSize" } }, providers: [ContainerService], viewQueries: [{ propertyName: "sectionRef", first: true, predicate: ["sectionRef"], descendants: true }, { propertyName: "footerRefVcr", first: true, predicate: ["footerRef"], descendants: true, read: ViewContainerRef }], usesInheritance: true, ngImport: i0, template: `
13008
13001
  <div
13009
13002
  class="tw-hidden grid-cols-0 tw-grid-cols-1 tw-grid-cols-2 tw-grid-cols-3 tw-grid-cols-4 tw-grid-cols-5
13010
13003
  tw-grid-cols-6 tw-grid-cols-7 tw-grid-cols-8 tw-grid-cols-9 tw-grid-cols-10 tw-grid-cols-11 tw-grid-cols-12"
@@ -13144,6 +13137,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
13144
13137
  }
13145
13138
  `,
13146
13139
  changeDetection: ChangeDetectionStrategy.OnPush,
13140
+ providers: [ContainerService],
13147
13141
  standalone: false
13148
13142
  }]
13149
13143
  }], propDecorators: { sectionRef: [{