SUPPORT-8956: refactor

This commit is contained in:
adel.kalimullin 2025-02-27 13:39:08 +03:00
parent 8588599265
commit 6301122e84
7 changed files with 31 additions and 31 deletions

View file

@ -0,0 +1,24 @@
import {AnalyticalScope, Behavior, TextField} from "@webbpm/base-package";
import {AuthorizationService} from "../../modules/app/service/authorization.service";
@AnalyticalScope("TextField")
export class SetCurrentRecruitmentIdAsDefValue extends Behavior {
private textField: TextField;
private authService: AuthorizationService;
initialize() {
super.initialize();
this.textField = this.getScript('component.ControlWithValue');
this.authService = this.injector.get(AuthorizationService);
}
start(): void {
super.start();
if (this.textField && this.textField.isPristine() && this.authService &&
this.authService.getCurrentSession()) {
this.textField.setValue(this.authService.getDomainId());
this.getContext().getChangeDetector().detectChanges();
}
}
}

View file

@ -1,24 +0,0 @@
import {AnalyticalScope, Behavior, SessionStore, TextField} from "@webbpm/base-package";
@AnalyticalScope("TextField")
export class SetCurrentUserIdAsDefValue extends Behavior {
private textField: TextField;
private sessionStore: SessionStore;
initialize() {
super.initialize();
this.textField = this.getScript('component.ControlWithValue');
this.sessionStore = this.injector.get(SessionStore);
}
start(): void {
super.start();
if (this.textField && this.textField.isPristine() && this.sessionStore &&
this.sessionStore.getSession()) {
this.textField.setValue(this.sessionStore.getSession().userAccountId);
this.getContext().getChangeDetector().detectChanges();
}
}
}

View file

@ -5,7 +5,7 @@ import {HttpClient} from "@angular/common/http";
export interface UserSession {
name: string,
realm: string,
recruitmentId: string,
domainId: string,
roles: string[]
}
@ -45,8 +45,8 @@ export class AuthorizationService {
return this.isAuthorized() ? this.session.realm : null;
}
getRecruitmentId(): string {
return this.isAuthorized() ? this.session.recruitmentId : null;
getDomainId(): string {
return this.isAuthorized() ? this.session.domainId : null;
}
getRoles(): string[] {

View file

@ -13,7 +13,6 @@ import {
BpmnModule,
ComponentsModule,
CoreModule,
SecurityModule,
} from "@webbpm/base-package";
import {AppRoutingModule} from "../app/app-routing.module";
import {GlobalErrorHandler} from "./handler/global-error.handler.prod";

View file

@ -3397,7 +3397,7 @@
<scripts id="d9ac3145-9d66-42bd-9f24-1c3d0d2e31d0"/>
<scripts id="db9c1a9d-2cf4-4fca-b2b0-5c3f78e4cb88">
<classRef type="TS">
<className>SetCurrentUserIdAsDefValue</className>
<className>SetCurrentRecruitmentIdAsDefValue</className>
<packageName>account_applications.scripts</packageName>
</classRef>
<enabled>true</enabled>

View file

@ -3307,7 +3307,7 @@
<scripts id="d9ac3145-9d66-42bd-9f24-1c3d0d2e31d0"/>
<scripts id="db9c1a9d-2cf4-4fca-b2b0-5c3f78e4cb88">
<classRef type="TS">
<className>SetCurrentUserIdAsDefValue</className>
<className>SetCurrentRecruitmentIdAsDefValue</className>
<packageName>account_applications.scripts</packageName>
</classRef>
<enabled>true</enabled>

View file

@ -3362,6 +3362,7 @@
<componentRootId>cde7064b-31a7-420c-9ed8-dd79214c1409</componentRootId>
<name>Text field</name>
<container>false</container>
<expanded>false</expanded>
<childrenReordered>false</childrenReordered>
<scripts id="cf4526a1-96ab-4820-8aa9-62fb54c2b64c">
<properties>
@ -3382,7 +3383,7 @@
<scripts id="d9ac3145-9d66-42bd-9f24-1c3d0d2e31d0"/>
<scripts id="db9c1a9d-2cf4-4fca-b2b0-5c3f78e4cb88">
<classRef type="TS">
<className>SetCurrentUserIdAsDefValue</className>
<className>SetCurrentRecruitmentIdAsDefValue</className>
<packageName>account_applications.scripts</packageName>
</classRef>
<enabled>true</enabled>