From 0487b0fc15e30521b023a196cb21eeb9367dd0cd Mon Sep 17 00:00:00 2001 From: gayathri1990 Date: Thu, 25 Mar 2021 18:59:19 +0530 Subject: [PATCH] user config changes --- .../src/app/settings/service/user.service.ts | 4 ++ .../users/register/register.component.html | 65 +++++++++++++------ .../users/register/register.component.ts | 50 ++++++++++++-- 3 files changed, 95 insertions(+), 24 deletions(-) diff --git a/ng6-seed/src/app/settings/service/user.service.ts b/ng6-seed/src/app/settings/service/user.service.ts index fc0848540..4f9cfd5b2 100755 --- a/ng6-seed/src/app/settings/service/user.service.ts +++ b/ng6-seed/src/app/settings/service/user.service.ts @@ -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); +} } diff --git a/ng6-seed/src/app/settings/users/register/register.component.html b/ng6-seed/src/app/settings/users/register/register.component.html index fb5e109b3..baf1a7d3b 100755 --- a/ng6-seed/src/app/settings/users/register/register.component.html +++ b/ng6-seed/src/app/settings/users/register/register.component.html @@ -1,6 +1,7 @@ -
+ +
User Registration
@@ -10,6 +11,8 @@
+ +
Personal
@@ -169,9 +172,26 @@
+ + + + + + + + + + + + +
+
+ +
+
Configurations
@@ -190,12 +210,12 @@ - + {{pd.product_name}} - Sales Products required + @@ -215,13 +235,13 @@ - + -- - + {{s.name}} - State Required. + @@ -231,27 +251,32 @@ + + + + + + + + + + +
- + -
+ +
+ +

- - - - - - - - - - - - + + +
diff --git a/ng6-seed/src/app/settings/users/register/register.component.ts b/ng6-seed/src/app/settings/users/register/register.component.ts index e9aa05881..df3b3f647 100755 --- a/ng6-seed/src/app/settings/users/register/register.component.ts +++ b/ng6-seed/src/app/settings/users/register/register.component.ts @@ -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);