latest change in create user

This commit is contained in:
gayathri1990 2021-03-29 10:14:27 +05:30
parent 0487b0fc15
commit d7a3957a76
2 changed files with 21 additions and 17 deletions

View File

@ -192,12 +192,12 @@
</form>
<form [formGroup]="configForm" (ngSubmit)="configuration(configForm.value)">
<div>
<mat-card *ngIf="regForm.controls['user_config']">
<mat-card *ngIf="shortname =='MWISE'">
<mat-card-title>Configurations</mat-card-title><hr/>
<!--******************************************-->
<mat-card class="p-2" style="box-shadow: 0 0 1px rgba(0,0,0,.18), 0 0 1px rgba(0,0,0,.15) !important">
<mat-tab-group >
<mat-tab-group>
<mat-tab>
<ng-template mat-tab-label>Sales Product</ng-template>
<!-- <div class="cardEdit" *ngIf="currentPDStatus==pdStatusCheck.DRAFT || currentPDStatus==pdStatusCheck.TRIGGERED || currentPDStatus==pdStatusCheck.ALLOCATED || currentPDStatus==pdStatusCheck.SCHEDULED">
@ -235,7 +235,7 @@
<mat-card-content >
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" >
<mat-select multiple placeholder="State" formControlName="rcm_state_mapping" required (selectionChange)="getcity($event)" >
<mat-select multiple placeholder="State" formControlName="rcm_state_mapping" required >
<mat-option>--</mat-option>
<mat-option *ngFor="let s of State" [value]="s.state_id" >
{{s.name}}

View File

@ -72,6 +72,7 @@ export class RegisterComponent implements OnInit {
Designation: any= [];
visible: boolean=false;
configdata: any;
shortname: any;
constructor(
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) {
@ -111,11 +112,11 @@ export class RegisterComponent implements OnInit {
}
addUserConfigControls() {
return this.fb.group({
salespd_products:['',Validators.compose([Validators.required])]
})
}
// addUserConfigControls() {
// return this.fb.group({
// salespd_products:['',Validators.compose()]
// })
// }
regdata() {
this.users.entityType().subscribe(res => {
this.types = res;
@ -235,6 +236,7 @@ export class RegisterComponent implements OnInit {
//console.log(this.usersData);
this.loader = true;
console.log("cog",userData,this.usersData)
if (this.usersData === undefined) {
this.AWS.register(userData).subscribe(res => {
if (res.User.UserStatus != '' && res.User.UserStatus !== undefined && res.User.UserStatus != null) {
@ -243,12 +245,12 @@ console.log("cog",userData,this.usersData)
this.users.saveRecords(res, userData).subscribe(res => {
data = res;
if (data.status == 200) {
this.AWS.adminUpdateuser(userData, data.record).subscribe(res => {});
this.AWS.adminUpdateuser(userData, data.record).subscribe(res => { });
this.loader =false;
// console.log(res);
Swal('User Created');
this.router.navigate(['setting/users/userlist']);
// this.router.navigate(['setting/users/userlist']);
}
})
@ -264,7 +266,7 @@ console.log("cog",userData,this.usersData)
this.users.saveRecords(res,userData).subscribe(res=>{
this.loader = false;
Swal('User Updated');
this.router.navigate(['setting/users/userlist']);
// this.router.navigate(['setting/users/userlist']);
//this.shared.redirectTo('settings/userListing');
delete this.AWS.localUserId;
})
@ -295,7 +297,7 @@ console.log("cog",userData,this.usersData)
this.users.saveConfig(configdata).subscribe(res=>{
this.loader = false;
Swal('User Configuration Updated');
this.router.navigate(['setting/users/userlist']);
// this.router.navigate(['setting/users/userlist']);
//this.shared.redirectTo('settings/userListing');
delete this.AWS.localUserId;
})
@ -381,21 +383,23 @@ getBranch(flag?){
}
checkUserConfigAvail() {
this.shortname=this.regForm.value.lenVenName.short_name;
//userid=this.usersData.userid
console.log(this.types[0].entity_type_id,this.regForm.value.lenVenName)
if(this.types[0].entity_type_id == '2' && this.regForm.value.lenVenName.short_name == 'MWISE') {
this.regForm.addControl('user_config',this.addUserConfigControls())
//this.regForm.addControl('user_config',this.addUserConfigControls())
this.regForm.addControl('designation',new FormControl('',Validators.required))
this.users.getEntityPreferences(this.regForm.value.lenVenName.entity_id).subscribe(res=>{
if(res['dataStatus']) {
this.productsList = res['records'].salespd_products
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)
}
else {
this.regForm.get('user_config')['controls']['salespd_products'].setValue(this.productsList.map(item=>item.product_id))
//this.regForm.get('user_config')['controls']['salespd_products'].setValue(this.productsList.map(item=>item.product_id))
}
}
})
@ -404,7 +408,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)
}