Merge remote-tracking branch 'origin/SUPPORT-8943_seamlessness' into feature/SUPPORT-8982_form_load
# Conflicts: # resources/src/main/resources/business-model/Список заявок на пользователя/Создать заявку на изменение.page
This commit is contained in:
commit
bb36a2cc13
15 changed files with 14438 additions and 5567 deletions
|
|
@ -16,5 +16,6 @@
|
|||
"password_pattern": "^((?=(.*\\d){1,})(?=.*[a-zа-яё])(?=.*[A-ZА-ЯЁ]).{8,})$",
|
||||
"password_pattern_error": "Пароль должен содержать заглавные или прописные буквы и как минимум 1 цифру",
|
||||
"show.client.errors": false,
|
||||
"available_task.single_fetch": true
|
||||
"available_task.single_fetch": true,
|
||||
"ervu_url": "https://ervu-dev.pgs.rtlabs.ru/service"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.webbpm.account-applications .msg {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.webbpm.account-applications .btn:not(:disabled):not(.disabled) {
|
||||
color: var(--color-text-active);
|
||||
font-family: 'GolosUIM';
|
||||
|
|
|
|||
36
frontend/src/ts/account_applications/component/IdmService.ts
Normal file
36
frontend/src/ts/account_applications/component/IdmService.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import {Observable, throwError} from 'rxjs';
|
||||
import {catchError, map} from "rxjs/operators";
|
||||
import {AppConfigService} from "@webbpm/base-package";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class IdmService {
|
||||
private ervuUrl: string;
|
||||
|
||||
constructor(private http: HttpClient, appConfigService: AppConfigService) {
|
||||
this.ervuUrl = appConfigService.getParamValue("ervu_url");
|
||||
}
|
||||
|
||||
checkLoginExists(login: string): Observable<boolean> {
|
||||
const url = `${this.ervuUrl}/idm/credentials/login/${login}`;
|
||||
return this.http.get<any[]>(url).pipe(
|
||||
map(response =>
|
||||
response.length > 0 && response.some(user => user.userName === login)
|
||||
),
|
||||
catchError(error => throwError(error))
|
||||
);
|
||||
}
|
||||
|
||||
checkSnilsExists(snils: string): Observable<boolean> {
|
||||
const url = `${this.ervuUrl}/idm/persons?query=snils%3D%3D%22${snils}%22`;
|
||||
return this.http.get<{ records: any[] }>(url).pipe(
|
||||
map(response =>
|
||||
response.records.length > 0 && response.records.some(person => person.snils === snils)
|
||||
),
|
||||
catchError(error => throwError(error))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
import {SimpleValidator, TextField} from "@webbpm/base-package";
|
||||
import {Observable} from "rxjs";
|
||||
import {IdmService} from "../IdmService";
|
||||
|
||||
export abstract class AbstractIdmValidator extends SimpleValidator {
|
||||
protected abstract ERROR_MESSAGE: string;
|
||||
protected abstract checkValueExists(value: string): Observable<boolean>;
|
||||
|
||||
protected textField: TextField;
|
||||
protected idmService: IdmService;
|
||||
protected textInput: HTMLInputElement;
|
||||
|
||||
initialize(): void {
|
||||
super.initialize();
|
||||
this.textField = this.getScript(TextField);
|
||||
this.idmService = this.injector.get(IdmService);
|
||||
this.textInput = this.textField.getEl().nativeElement.querySelector('input');
|
||||
this.textInput.addEventListener('blur', this.onBlurHandler.bind(this));
|
||||
}
|
||||
|
||||
async isValid(): Promise<boolean> {
|
||||
const inputValue: string = this.textInput.value;
|
||||
if (!inputValue) return Promise.resolve(false);
|
||||
|
||||
const cleanedValue = this.cleanValue(inputValue);
|
||||
if (!this.isPatternValid(cleanedValue)) return Promise.resolve(false);
|
||||
|
||||
return this.checkValueExists(cleanedValue).toPromise().then(
|
||||
(exists) => {
|
||||
this.pushError(!exists, this.ERROR_MESSAGE);
|
||||
return !exists;
|
||||
},
|
||||
(err) => {
|
||||
const fieldName = this.textField.getObjectName();
|
||||
console.error(`Ошибка проверки ${fieldName}: ${err.message}`);
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private async onBlurHandler(event: FocusEvent): Promise<void> {
|
||||
await this.isValid();
|
||||
}
|
||||
|
||||
protected cleanValue(value: string): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
protected isPatternValid(value: string): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import {Observable} from "rxjs";
|
||||
import {AbstractIdmValidator} from "./AbstractIdmValidator";
|
||||
|
||||
export class IdmLoginValidator extends AbstractIdmValidator {
|
||||
protected ERROR_MESSAGE = "Пользователь с указанным логином уже существует";
|
||||
|
||||
protected checkValueExists(value: string): Observable<boolean> {
|
||||
return this.idmService.checkLoginExists(value);
|
||||
}
|
||||
|
||||
protected isPatternValid(value: string): boolean {
|
||||
let pattern = this.context.pattern;
|
||||
return pattern ? new RegExp(pattern).test(value) : true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import {Observable} from "rxjs";
|
||||
import {AbstractIdmValidator} from "./AbstractIdmValidator";
|
||||
|
||||
export class IdmSnilsValidator extends AbstractIdmValidator {
|
||||
protected ERROR_MESSAGE = "Пользователь с указанным СНИЛС уже существует";
|
||||
|
||||
protected checkValueExists(value: string): Observable<boolean> {
|
||||
return this.idmService.checkSnilsExists(value);
|
||||
}
|
||||
|
||||
protected cleanValue(value: string): string {
|
||||
return value.replace(/[-\s]/g, '');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue