SUPPORT-8974 send empty id list
This commit is contained in:
parent
f78f3ea446
commit
87927541cc
5 changed files with 114 additions and 60 deletions
|
|
@ -30,7 +30,8 @@ export class ConfigExecuteBtn extends AbstractButton {
|
|||
public endDate: DateTimePicker;
|
||||
@NotNull()
|
||||
public methodPath: string;
|
||||
private script: ConfigExecutorRpcService;
|
||||
|
||||
private rpcService: ConfigExecutorRpcService;
|
||||
private messagesService: MessagesService;
|
||||
|
||||
constructor(el: ElementRef, cd: ChangeDetectorRef) {
|
||||
|
|
@ -39,33 +40,44 @@ export class ConfigExecuteBtn extends AbstractButton {
|
|||
|
||||
initialize() {
|
||||
super.initialize();
|
||||
this.script = this.getScript(ConfigExecutorRpcService);
|
||||
this.rpcService = this.getScript(ConfigExecutorRpcService);
|
||||
this.messagesService = this.injector.get(MessagesService);
|
||||
}
|
||||
|
||||
doClickActions(): Promise<any> {
|
||||
const value: string = this.ervuIdField.getValue();
|
||||
if (value && this.methodPath.trim().length !== 0) {
|
||||
const ids: string[] = value.replace(/[{}]/g, '')
|
||||
.split(',')
|
||||
.map(id => id.trim().replace(/"/g, ''));
|
||||
|
||||
let configExecuteRequest: ConfigExecuteRequest = new ConfigExecuteRequest();
|
||||
let withDate = false;
|
||||
configExecuteRequest.ids = ids;
|
||||
if (this.startDate || this.endDate) {
|
||||
withDate = true;
|
||||
configExecuteRequest.startDate = this.startDate ? this.startDate.getDateValue() : null;
|
||||
configExecuteRequest.endDate = this.endDate ? this.endDate.getDateValue() : null;
|
||||
}
|
||||
|
||||
return this.script.callConfigExecutor(this.methodPath, configExecuteRequest, withDate, true)
|
||||
.then(successMsg => this.messagesService.success(successMsg))
|
||||
.catch(error => Promise.reject(error));
|
||||
if (this.methodPath.trim().length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ids: string[] = this.ervuIdField.getValue()
|
||||
? ConfigExecuteBtn.parseIds(this.ervuIdField.getValue())
|
||||
: new Array<string>();
|
||||
|
||||
let configExecuteRequest: ConfigExecuteRequest = new ConfigExecuteRequest();
|
||||
let withDate = false;
|
||||
configExecuteRequest.ids = ids;
|
||||
|
||||
if (this.startDate || this.endDate) {
|
||||
withDate = true;
|
||||
configExecuteRequest.startDate = this.startDate ? this.startDate.getDateValue() : null;
|
||||
configExecuteRequest.endDate = this.endDate ? this.endDate.getDateValue() : null;
|
||||
}
|
||||
|
||||
return this.rpcService.callConfigExecutor(this.methodPath, configExecuteRequest, withDate, true)
|
||||
.then(successMsg => this.messagesService.success(successMsg))
|
||||
.catch(error => Promise.reject(error));
|
||||
|
||||
}
|
||||
|
||||
getFocusElement(): HTMLInputElement {
|
||||
return this.el.nativeElement.querySelector('button');
|
||||
}
|
||||
|
||||
private static parseIds(value: string): string[] {
|
||||
return value.replace(/[{}]/g, '')
|
||||
.split(',')
|
||||
.map(id => id.trim().replace(/"/g, ''));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue