user config changes
This commit is contained in:
parent
be2434c4ef
commit
0487b0fc15
@ -242,6 +242,10 @@ export class UserService {
|
||||
getEntityPreferences(entity_id){
|
||||
return this.http.get(apiurl+'getEntityPreferences/'+entity_id)
|
||||
}
|
||||
saveConfig(configdata){
|
||||
|
||||
return this.http.post(apiurl + "saveOrUpdateUserConfig",configdata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<mat-card>
|
||||
<form [formGroup]="regForm" (ngSubmit)="register(regForm.value)">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxflex="100" fxLayout="row" fxLayoutAlign="start center">
|
||||
<div dividerColor="primary" class="ml-xs mr-xs">
|
||||
<div style="font-size:24px;"> User Registration</div>
|
||||
@ -10,6 +11,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div fxLayout="row wrap">
|
||||
<form [formGroup]="regForm" (ngSubmit)="register(regForm.value)">
|
||||
<div>
|
||||
<div fxFlex.gt-sm="33.33%" fxFlex="50" class="m-gap p-gap">
|
||||
<mat-card>
|
||||
<mat-card-title>Personal</mat-card-title><hr/>
|
||||
@ -169,9 +172,26 @@
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
<mat-card-actions style="text-align:right;">
|
||||
|
||||
<button *ngIf = "this.regForm.controls['userid'].value == null ; else editreset;" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button>
|
||||
<ng-template #editreset>
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Clear Changes" matTooltipPosition="above" type="button" (click)="onResetForEdit()" ><mat-icon>settings_backup_restore</mat-icon></button>
|
||||
<!-- <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Clear Changes" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button> -->
|
||||
</ng-template>
|
||||
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Submit" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||
|
||||
</mat-card-actions>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form [formGroup]="configForm" (ngSubmit)="configuration(configForm.value)">
|
||||
<div>
|
||||
<mat-card *ngIf="regForm.controls['user_config']">
|
||||
<mat-card-title>Configurations</mat-card-title><hr/>
|
||||
<!--******************************************-->
|
||||
@ -190,12 +210,12 @@
|
||||
|
||||
<mat-card-content>
|
||||
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 50%;">
|
||||
<mat-select multiple placeholder="Sales Products" [formControl]="regForm.get('user_config')['controls']['salespd_products']" [disabled] = "productsList.length == 0">
|
||||
<mat-select multiple placeholder="Sales Products" formControlName="salespd_products" [disabled] = "productsList.length == 0">
|
||||
<mat-option *ngFor="let pd of productsList" [value]="pd.product_id" >
|
||||
{{pd.product_name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error align="end" *ngIf="regForm.get('user_config')['controls']['salespd_products'].hasError('required')">Sales Products required</mat-error>
|
||||
<!-- <mat-error align="end" *ngIf="configForm.get('user_config')['controls']['salespd_products'].hasError('required')">Sales Products required</mat-error>-->
|
||||
</mat-form-field>
|
||||
</mat-card-content>
|
||||
<ng-template>
|
||||
@ -215,13 +235,13 @@
|
||||
|
||||
<mat-card-content >
|
||||
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" >
|
||||
<mat-select multiple matInput placeholder="State" [formControl]="regForm.controls['state']" required (selectionChange)="getcity($event)" >
|
||||
<mat-select multiple placeholder="State" formControlName="rcm_state_mapping" required (selectionChange)="getcity($event)" >
|
||||
<mat-option>--</mat-option>
|
||||
<mat-option *ngFor="let s of State" [value]="s" >
|
||||
<mat-option *ngFor="let s of State" [value]="s.state_id" >
|
||||
{{s.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="regForm.controls['state'].hasError('required') && regForm.controls['state'].touched" class="mat-text-warn">State Required.</mat-error>
|
||||
<!--<mat-error *ngIf="configForm.controls['rcm_state_mapping'].hasError('required') && configForm.controls['rcm_state_mapping'].touched" class="mat-text-warn">State Required.</mat-error>-->
|
||||
</mat-form-field>
|
||||
</mat-card-content>
|
||||
<ng-template>
|
||||
@ -231,27 +251,32 @@
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
<mat-card-actions style="text-align:right;">
|
||||
|
||||
<button *ngIf = "this.regForm.controls['userid'].value == null ; else editreset;" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button>
|
||||
<ng-template #editreset>
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Clear Changes" matTooltipPosition="above" type="button" (click)="onResetForEdit()" ><mat-icon>settings_backup_restore</mat-icon></button>
|
||||
<!-- <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Clear Changes" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button> -->
|
||||
</ng-template>
|
||||
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Submit" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
<!--*************************-->
|
||||
|
||||
|
||||
|
||||
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</mat-card-content>
|
||||
<hr>
|
||||
<mat-card-actions style="text-align:right;">
|
||||
|
||||
<button *ngIf = "this.regForm.controls['userid'].value == null ; else editreset;" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button>
|
||||
<ng-template #editreset>
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Clear Changes" matTooltipPosition="above" type="button" (click)="onResetForEdit()" ><mat-icon>settings_backup_restore</mat-icon></button>
|
||||
<!-- <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Clear Changes" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button> -->
|
||||
</ng-template>
|
||||
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Submit" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||
|
||||
</mat-card-actions>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</mat-card>
|
||||
<div *ngIf="loader">
|
||||
<mat-progress-bar mode="indeterminate" color="primary" class="mb-1"></mat-progress-bar>
|
||||
|
||||
@ -43,6 +43,7 @@ export class RegisterComponent implements OnInit {
|
||||
loader:boolean = false;
|
||||
roleAccess:boolean = false;
|
||||
public regForm: FormGroup;
|
||||
public configForm: FormGroup;
|
||||
|
||||
// name: string;
|
||||
// email: string;
|
||||
@ -70,8 +71,9 @@ export class RegisterComponent implements OnInit {
|
||||
productsList: any = [];
|
||||
Designation: any= [];
|
||||
visible: boolean=false;
|
||||
configdata: any;
|
||||
constructor(
|
||||
private router: Router, public fb: FormBuilder, public AWS: AwsService, private cd: ChangeDetectorRef
|
||||
private router: Router, public fb: FormBuilder,public cb: FormBuilder, public AWS: AwsService, private cd: ChangeDetectorRef
|
||||
,private elementRef: ElementRef,public users:UserService,notifier:NotifierService,private dialog: MatDialog) {
|
||||
this.notifier=notifier
|
||||
// console.log(this.notifier)
|
||||
@ -83,7 +85,11 @@ export class RegisterComponent implements OnInit {
|
||||
this.regdata();
|
||||
}
|
||||
|
||||
|
||||
this.configForm=this.fb.group({
|
||||
|
||||
salespd_products: [null, Validators.compose([Validators.required])],
|
||||
rcm_state_mapping: [null, Validators.compose([Validators.required])]
|
||||
});
|
||||
this.regForm = this.fb.group({
|
||||
userid: [null],
|
||||
firstName: [null, Validators.compose([Validators.required, Validators.minLength(2)])],
|
||||
@ -266,6 +272,41 @@ console.log("cog",userData,this.usersData)
|
||||
|
||||
}
|
||||
}
|
||||
configuration(configForm)
|
||||
{
|
||||
|
||||
let configdata:any={"user_id":this.usersData.userid}
|
||||
|
||||
if(this.configForm.get('salespd_products').dirty==true)
|
||||
{
|
||||
configdata.salespd_products=this.configForm.value.salespd_products;
|
||||
}
|
||||
if(this.configForm.get('rcm_state_mapping').dirty==true)
|
||||
{
|
||||
configdata.rcm_state_mapping=this.configForm.value.rcm_state_mapping;
|
||||
}
|
||||
if(this.configForm.get('rcm_state_mapping').dirty==false && this.configForm.get('salespd_products').dirty==false)
|
||||
{
|
||||
Swal('you cannot change anything');
|
||||
return
|
||||
}
|
||||
|
||||
//alert(this.configForm.get('rcm_state_mapping').dirty);
|
||||
this.users.saveConfig(configdata).subscribe(res=>{
|
||||
this.loader = false;
|
||||
Swal('User Configuration Updated');
|
||||
this.router.navigate(['setting/users/userlist']);
|
||||
//this.shared.redirectTo('settings/userListing');
|
||||
delete this.AWS.localUserId;
|
||||
})
|
||||
|
||||
console.log(this.usersData.userid);
|
||||
|
||||
console.log(this.configForm.value);
|
||||
console.log('testing');
|
||||
console.log(this.configdata);
|
||||
|
||||
}
|
||||
|
||||
toggleAllSelection(e,enitiyid,flag?) {
|
||||
console.log(e);
|
||||
@ -363,7 +404,7 @@ getBranch(flag?){
|
||||
if(res['dataStatus']) {
|
||||
this.Designation = res['records'];
|
||||
if (this.users.localUserId != '' && this.users.localUserId != null && this.users.localUserId !== undefined && this.users.localUserId.user_config) {
|
||||
// this.regForm.get('user_config')['controls']['salespd_products'].setValue(this.users.localUserId.user_config.salespd_products)
|
||||
this.regForm.get('user_config')['controls']['salespd_products'].setValue(this.users.localUserId.user_config.salespd_products)
|
||||
|
||||
this.regForm.get('designation').setValue(this.users.localUserId.designation)
|
||||
}
|
||||
@ -480,7 +521,8 @@ getBranch(flag?){
|
||||
this.regForm.controls['firstName'].setValue(this.usersData.user_first_name);
|
||||
this.regForm.controls['lastName'].setValue(this.usersData.user_last_name);
|
||||
this.regForm.controls['phone'].setValue(this.usersData.mobile_no);
|
||||
|
||||
this.configForm.controls['salespd_products'].setValue(this.usersData.user_config.salespd_products);
|
||||
this.configForm.controls['rcm_state_mapping'].setValue(this.usersData.user_config.rcm_state_mapping);
|
||||
this.regForm.controls['email'].setValue(this.usersData.email);
|
||||
if (this.usersData.isactive == 1) {
|
||||
this.regForm.controls['isactive'].setValue(true);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user