SUPPORT-9012: fix user management service and page
This commit is contained in:
parent
3abb735528
commit
9f9c52d2d8
4 changed files with 29 additions and 182 deletions
|
|
@ -4,12 +4,10 @@ import {
|
|||
NotNull,
|
||||
ObjectRef,
|
||||
SaveButton,
|
||||
TextField,
|
||||
Visible
|
||||
TextField
|
||||
} from "@webbpm/base-package";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {FormField} from "../field/FormField";
|
||||
import {AccountAction} from "../enum/AccountAction";
|
||||
import {AuthorizationService} from "../../../modules/app/service/authorization.service";
|
||||
import {ApplicationKind} from "../enum/ApplicationKind";
|
||||
|
||||
|
|
@ -17,9 +15,6 @@ import {ApplicationKind} from "../enum/ApplicationKind";
|
|||
export class UserManagementService extends Behavior {
|
||||
|
||||
@NotNull()
|
||||
public action: AccountAction;
|
||||
@Visible("action == AccountAction.EDIT")
|
||||
@NotNull("action == AccountAction.EDIT")
|
||||
@ObjectRef()
|
||||
public applicationKind: TextField;
|
||||
|
||||
|
|
@ -37,46 +32,31 @@ export class UserManagementService extends Behavior {
|
|||
return;
|
||||
}
|
||||
let jsonObj = this.collectData();
|
||||
let kind = this.applicationKind.getValue();
|
||||
|
||||
switch (this.action) {
|
||||
case AccountAction.CREATE:
|
||||
switch (kind) {
|
||||
case ApplicationKind.CREATE_USER:
|
||||
this.doRequest("user", jsonObj);
|
||||
break;
|
||||
case AccountAction.EDIT:
|
||||
let kind = this.applicationKind.getValue();
|
||||
|
||||
switch (kind) {
|
||||
case ApplicationKind.EDIT_USER_MAIN:
|
||||
this.doRequest("user/person", jsonObj);
|
||||
break;
|
||||
case ApplicationKind.EDIT_USER_ACCOUNT:
|
||||
this.doRequest("user/account", jsonObj);
|
||||
break;
|
||||
case ApplicationKind.EDIT_USER_ROLES:
|
||||
this.doRequest("user/roles", jsonObj);
|
||||
break;
|
||||
}
|
||||
case ApplicationKind.EDIT_USER_MAIN:
|
||||
this.doRequest("user/person", jsonObj);
|
||||
break;
|
||||
case AccountAction.DEACTIVATE:
|
||||
case ApplicationKind.EDIT_USER_ACCOUNT:
|
||||
this.doRequest("user/account", jsonObj);
|
||||
break;
|
||||
case ApplicationKind.EDIT_USER_ROLES:
|
||||
this.doRequest("user/roles", jsonObj);
|
||||
break;
|
||||
case ApplicationKind.BLOCK_USER:
|
||||
this.doRequest("users/deactivation", jsonObj);
|
||||
break;
|
||||
case AccountAction.RESET_PASSWORD:
|
||||
case ApplicationKind.RESET_PASSWORD:
|
||||
this.doRequest("user/password/reset", jsonObj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Visible()
|
||||
public setAccountAction(actionName: string): void {
|
||||
try {
|
||||
this.action = AccountAction[actionName];
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`Unsupported action name ${actionName}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
private collectData(): any {
|
||||
let jsonObj = {};
|
||||
let fields: FormField[] = this.button.form.getScriptsInChildren(FormField);
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
export enum AccountAction {
|
||||
CREATE = "CREATE",
|
||||
EDIT = "EDIT",
|
||||
DEACTIVATE = "DEACTIVATE",
|
||||
RESET_PASSWORD="RESET_PASSWORD"
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
export enum ApplicationKind {
|
||||
CREATE_USER = "CREATE_USER",
|
||||
EDIT_USER_MAIN = "EDIT_USER_MAIN",
|
||||
EDIT_USER_ACCOUNT = "EDIT_USER_ACCOUNT",
|
||||
EDIT_USER_ROLES = "EDIT_USER_ROLES"
|
||||
}
|
||||
EDIT_USER_ROLES = "EDIT_USER_ROLES",
|
||||
BLOCK_USER = "BLOCK_USER",
|
||||
RESET_PASSWORD = "RESET_PASSWORD"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue