Merge branch 'feature/SUPPORT-8846_client_form' into hotfix/1.9.6

This commit is contained in:
gulnaz 2025-01-16 12:19:12 +03:00
commit b16a0a149e
15 changed files with 485 additions and 1031 deletions

View file

@ -1,7 +1,8 @@
import {Form} from "@webbpm/base-package";
import {ChangeDetectionStrategy, Component} from "@angular/core";
import {Container, FieldData, Visible, Event} from "@webbpm/base-package";
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef} from "@angular/core";
import {ErvuDataService} from "../../../modules/app/service/ervu-data.service";
import {LoadFormRpcService} from "../../../generated/ru/micord/ervu/service/rpc/LoadFormRpcService";
import {LoadFormField} from "../field/LoadFormField";
import {Subscription} from "rxjs";
@Component({
moduleId: module.id,
@ -9,35 +10,52 @@ import {LoadFormRpcService} from "../../../generated/ru/micord/ervu/service/rpc/
templateUrl: './../../../../../src/resources/template/component/container/Form.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class LoadForm extends Form {
export class LoadForm extends Container {
@Visible("false")
public formLoaded: Event<void> = new Event<void>(() => true);
private formRpcService: LoadFormRpcService;
private ervuDataService: ErvuDataService;
private subscription: Subscription;
private fields: any[];
private fieldDataList: FieldData[] = [];
constructor(el: ElementRef, cd: ChangeDetectorRef) {
super(el, cd);
}
public fireOnLoadEvent(): void {
super.fireOnLoadEvent();
this.formLoaded.trigger();
}
protected loadContainer(): Promise<any> {
return Promise.resolve(this.loadData());
}
initialize() {
super.initialize();
this.formRpcService = this.getScript(LoadFormRpcService);
this.fields = this.getScriptsInChildren(LoadFormField);
this.ervuDataService = this.injector.get(ErvuDataService);
this.subscription = this.ervuDataService.message.subscribe(value => {
if (value) {
this.fields.forEach(field => {
let fieldData: FieldData = new FieldData();
fieldData.componentGuid = field.objectId;
fieldData.value = value[field.id];
this.fieldDataList.push(fieldData);
});
this.loadData();
}
});
}
loadData(): Promise<any> {
return this.formRpcService
.loadData()
.then(fieldDataList => this.setData(fieldDataList))
.catch(reason => {
throw new Error(reason);
});
}
saveData(): Promise<any> {
return;
}
deleteData(): Promise<void> {
return;
return this.setData(this.fieldDataList);
}
ngOnDestroy() {
super.ngOnDestroy();
this.subscription.unsubscribe();
}
}

View file

@ -0,0 +1,8 @@
import {AnalyticalScope, Behavior, Control} from "@webbpm/base-package";
@AnalyticalScope(Control)
export class LoadFormField extends Behavior {
public id: string;
}

View file

@ -0,0 +1,12 @@
import {TextFormatter} from "@webbpm/base-package";
export class DateTextFormatter implements TextFormatter {
public prefix: string;
format(value: string): string {
return value
? (this.prefix ? this.prefix + ' ' : '') + new Date(value).toLocaleDateString()
: value;
}
}