SUPPORT-8987: refactor FormField
This commit is contained in:
parent
f191dab01a
commit
e266bcba76
6 changed files with 77 additions and 87 deletions
|
|
@ -60,8 +60,10 @@ export class UserManagementService extends Behavior {
|
|||
if (!this.authService.hasRole('security_administrator') || !this.sendToErvu) {
|
||||
return;
|
||||
}
|
||||
let kind = this.applicationKind.getValue();
|
||||
let formJson = this.collectData();
|
||||
const kind = this.applicationKind.getValue();
|
||||
const formJson = this.collectData();
|
||||
const appNumber = formJson['appNumber'];
|
||||
const accountId = formJson['accountId'];
|
||||
let request;
|
||||
|
||||
switch (kind) {
|
||||
|
|
@ -80,30 +82,29 @@ export class UserManagementService extends Behavior {
|
|||
request = new CreateAccountRequest();
|
||||
request.data = createData;
|
||||
request.processKey = ProcessKey.CREATE;
|
||||
this.doRequest(request, formJson['appNumber']);
|
||||
this.doRequest(request, appNumber);
|
||||
break;
|
||||
case ApplicationKind.EDIT_USER_MAIN:
|
||||
let editPersonData = new EditPersonData();
|
||||
editPersonData.accountId = formJson['accountId'];
|
||||
editPersonData.accountId = accountId;
|
||||
editPersonData.personData = this.populateDto(new Person(), formJson);
|
||||
request = new EditPersonRequest();
|
||||
request.data = editPersonData;
|
||||
request.processKey = ProcessKey.EDIT_PERSON;
|
||||
this.doRequest(request, formJson['appNumber']);
|
||||
this.doRequest(request, appNumber);
|
||||
break;
|
||||
case ApplicationKind.EDIT_USER_ACCOUNT:
|
||||
let editAccountData = new EditAccountData();
|
||||
let account = this.populateDto(new Account(), formJson);
|
||||
account.id = formJson['accountId'];
|
||||
account.id = accountId;
|
||||
editAccountData.account = account;
|
||||
request = new EditAccountRequest();
|
||||
request.data = editAccountData;
|
||||
request.processKey = ProcessKey.EDIT_ACCOUNT;
|
||||
this.doRequest(request, formJson['appNumber']);
|
||||
this.doRequest(request, appNumber);
|
||||
break;
|
||||
case ApplicationKind.EDIT_USER_ROLES:
|
||||
let editRolesAccount = new EditRolesAccount();
|
||||
let accountId = formJson['accountId'];
|
||||
let rolesList = formJson['rolesList'];
|
||||
editRolesAccount.accountId = accountId;
|
||||
editRolesAccount.rolesList = rolesList.map(id => {
|
||||
|
|
@ -119,34 +120,34 @@ export class UserManagementService extends Behavior {
|
|||
request = new EditRolesRequest();
|
||||
request.data = editRolesData;
|
||||
request.processKey = ProcessKey.EDIT_ROLES;
|
||||
this.doRequest(request, formJson['appNumber']);
|
||||
this.doRequest(request, appNumber);
|
||||
});
|
||||
break;
|
||||
case ApplicationKind.BLOCK_USER:
|
||||
let deactivationData = new ChangeActivationData();
|
||||
deactivationData.accountIdList = [formJson['accountId']];
|
||||
deactivationData.accountIdList = [accountId];
|
||||
request = new ChangeActivationRequest();
|
||||
request.data = deactivationData;
|
||||
request.processKey = ProcessKey.DEACTIVATE;
|
||||
this.doRequest(request, formJson['appNumber']);
|
||||
this.doRequest(request, appNumber);
|
||||
break;
|
||||
case ApplicationKind.UNBLOCK_USER:
|
||||
let activationData = new ChangeActivationData();
|
||||
activationData.accountIdList = [formJson['accountId']];
|
||||
activationData.accountIdList = [accountId];
|
||||
request = new ChangeActivationRequest();
|
||||
request.data = activationData;
|
||||
request.processKey = ProcessKey.ACTIVATE;
|
||||
this.doRequest(request, formJson['appNumber']);
|
||||
this.doRequest(request, appNumber);
|
||||
break;
|
||||
case ApplicationKind.RESET_PASSWORD:
|
||||
let resetPasswordAccount = new ResetPasswordAccount();
|
||||
resetPasswordAccount.id = formJson['accountId'];
|
||||
resetPasswordAccount.id = accountId;
|
||||
let resetPasswordData = new ResetPasswordData();
|
||||
resetPasswordData.account = resetPasswordAccount;
|
||||
request = new ResetPasswordRequest();
|
||||
request.data = resetPasswordData;
|
||||
request.processKey = ProcessKey.RESET_PASSWORD;
|
||||
this.doRequest(request, formJson['appNumber']);
|
||||
this.doRequest(request, appNumber);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,31 +1,17 @@
|
|||
import {
|
||||
AnalyticalScope,
|
||||
Autocomplete,
|
||||
Behavior,
|
||||
Control,
|
||||
GridV2,
|
||||
NotNull
|
||||
} from "@webbpm/base-package";
|
||||
|
||||
@AnalyticalScope(Control)
|
||||
export class FormField extends Behavior {
|
||||
//TODO SUPPORT-8987
|
||||
|
||||
@NotNull()
|
||||
public name: string;
|
||||
|
||||
public gridValue: boolean = false;
|
||||
@NotNull("gridValue == true")
|
||||
public columnId: string;
|
||||
|
||||
public getValue(): any {
|
||||
if (this.gridValue) {
|
||||
let grid = this.getScript(GridV2);
|
||||
return grid.getAllRows().map(rowData => rowData[this.columnId])
|
||||
}
|
||||
|
||||
return this.context instanceof Autocomplete
|
||||
? this.getScript(Autocomplete).getBusinessId()
|
||||
: this.getScript('component.ControlWithValue').getValueForForm();
|
||||
return this.context.getValueForForm();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
import {FormField} from "./FormField";
|
||||
import {AnalyticalScope, GridV2, GridV2Column, NotNull, ObjectRef} from "@webbpm/base-package";
|
||||
|
||||
@AnalyticalScope(GridV2)
|
||||
export class GridFormField extends FormField {
|
||||
|
||||
@NotNull()
|
||||
@ObjectRef()
|
||||
public column: GridV2Column;
|
||||
|
||||
public getValue(): any[] {
|
||||
let grid: GridV2 = this.getScript(GridV2);
|
||||
return grid.getAllRows().map(rowData => rowData[this.column.getField()]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import {FormField} from "./FormField";
|
||||
import {AnalyticalScope, SelectBase} from "@webbpm/base-package";
|
||||
|
||||
@AnalyticalScope(SelectBase)
|
||||
export class SelectizeFormField extends FormField {
|
||||
|
||||
public getValue(): any {
|
||||
return this.context.getBusinessId();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue