ERVU-226: add start/end dates in ConfigExecuteBtn.ts

This commit is contained in:
Alexandr Shalaginov 2024-12-18 15:35:27 +03:00
parent fa78bf4855
commit dc67e681dd
4 changed files with 83 additions and 19 deletions

View file

@ -1,6 +1,14 @@
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef} from "@angular/core";
import {AbstractButton, MessagesService, NotNull, ObjectRef, TextArea} from "@webbpm/base-package";
import {
AbstractButton,
DateTimePicker,
MessagesService,
NotNull,
ObjectRef,
TextArea
} from "@webbpm/base-package";
import {ConfigExecutorRpcService} from "../generated/rpc/ConfigExecutorRpcService";
import {ConfigExecuteRequest} from "../generated/dto/ConfigExecuteRequest";
/**
* @author: a.petrov
@ -16,6 +24,10 @@ export class ConfigExecuteBtn extends AbstractButton {
@ObjectRef()
@NotNull()
public ervuIdField: TextArea;
@ObjectRef()
public startDate: DateTimePicker;
@ObjectRef()
public endDate: DateTimePicker;
@NotNull()
public methodPath: string;
private script: ConfigExecutorRpcService;
@ -32,13 +44,18 @@ export class ConfigExecuteBtn extends AbstractButton {
}
doClickActions(): Promise<any> {
const value = this.ervuIdField.getValue();
const value: string = this.ervuIdField.getValue();
if (value && this.methodPath.trim().length !== 0) {
const ids = value.replace(/[{}]/g, '')
const ids: string[] = value.replace(/[{}]/g, '')
.split(',')
.map(id => id.trim().replace(/"/g, ''));
return this.script.callConfigExecutor(this.methodPath, ids, true)
let configExecuteRequest: ConfigExecuteRequest = new ConfigExecuteRequest();
configExecuteRequest.ids = ids;
configExecuteRequest.startDate = this.startDate ? this.startDate.getDateValue() : null;
configExecuteRequest.endDate = this.endDate ? this.endDate.getDateValue() : null;
return this.script.callConfigExecutor(this.methodPath, configExecuteRequest, true)
.then(successMsg => this.messagesService.success(successMsg))
.catch(error => Promise.reject(error));
}