diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/LicenseModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/LicenseModel.cs index b799b28..8ee87dd 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/LicenseModel.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/LicenseModel.cs @@ -168,7 +168,7 @@ namespace AIAHTML5.ADMIN.API.Models LicenseObj.TotalRenewals = result[0].TotalRenewals; LicenseObj.SubscriptionStartDate = (result[0].SubscriptionStartDate == null ? DateTime.MinValue : result[0].SubscriptionStartDate.Value); LicenseObj.SubscriptionEndDate = (result[0].SubscriptionEndDate == null ? DateTime.MinValue : result[0].SubscriptionEndDate.Value); - LicenseObj.RenewDate = (result[0].RenewalDate == null ? DateTime.MinValue : result[0].RenewalDate.Value); + LicenseObj.RenewDate = DateTime.Now.Date;// (result[0].RenewalDate == null ? DateTime.Now.Date : result[0].RenewalDate.Value); } } catch (Exception ex) { } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 5f2753c..c364483 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -754,11 +754,23 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data //6. reset the isCommingSoonModel to false in local storage so that upcomming module pop up would not show again to the user after firts time localStorage.setItem('isCommingSoonModel', false); + + // for reseller type user first need to update profile + // only instructor ,not student + if (result.UserTypeId == 7 && result.EditionId == 1 && (result.FirstName == "" || result.EmailId == "" || result.LastName == "")) { - $location.path('/'); + $('#updateprofile').html(LoginMessageConstants.USER_UPDATE_PROFILE); + + $("#profileUpdateModal").modal('show'); + + $(".modal-backdrop").css("opacity", ".5"); + + } + else { + $location.path('/'); + } } - else - { + else { if ($('#dvTerms').length > 0) { $('#dvTerms').html(result.TermsAndConditionsText); } @@ -1145,6 +1157,20 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data $rootScope.userData = userInfo; $rootScope.userModules = userInfo.Modules; // ShowAssignedModulesPopup(userInfo.Modules);; + // for reseller type user first need to update profile + // allow popup for instructor ,not for student. + if (userInfo.UserTypeId == 7 && userInfo.EditionId == 1 && (userInfo.FirstName == "" || userInfo.EmailId == "" || userInfo.LastName == "")) { + + $('#updateprofile').html(LoginMessageConstants.USER_UPDATE_PROFILE); + + $("#profileUpdateModal").modal('show'); + + $(".modal-backdrop").css("opacity", ".5"); + + } + else { + $location.path('/'); + } } } } @@ -6866,7 +6892,11 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data } $rootScope.reDirectURLToAdmin = function () { - window.location.href = "Admin"; + $("#profileUpdateModal").modal('hide'); + $timeout(function () { + window.location.href = "Admin"; + }, 300) + }; $rootScope.SendAdminAccessRequestMail = function (userInfo) { diff --git a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js index 04ae6c8..be715a3 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js @@ -388,6 +388,7 @@ AIA.constant("LoginConstants", { }); AIA.constant("LoginMessageConstants", { + "USER_UPDATE_PROFILE":"Please update your profile first", "USER_OR_PASSWORD_INCORRECT": "UserId or Password is incorrect.", "RESET_PASSWORD": "Please check you email and reset your password.", "USERID_SENT_IN_EMAIL": "We have sent you userId in email.", diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx b/400-SOURCECODE/AIAHTML5.Web/index.aspx index a737613..7a13b17 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.aspx +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx @@ -1081,6 +1081,30 @@ + + +
@@ -276,7 +276,7 @@
- + (xxx-xxx-xxxx)
Phone is required
Phone is invalid
@@ -292,9 +292,9 @@
- -
Email is required
-
Email is invalid
+ +
Email is required
+
Email is invalid
diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.ts b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.ts index 44f5f64..22e274e 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.ts @@ -35,15 +35,15 @@ export class AddLicense implements OnInit { divClass: string = ''; topPos: string = '2000px'; datePipe: DatePipe = new DatePipe('en-US'); - bsValue1: Date = null;//new Date(); + bsValue1: Date =new Date(); bsValue2: Date = null;//new Date(); bsValue3: Date = null;//new Date(); modalRef: BsModalRef; editionLoginsText: string; rowIndex: number = 0; ParamsObj: any; - // minDate = new Date(1110, 11, 1); minDate = new Date(); + startDate= new Date(); maxDate = new Date(9999, 11, 31); bsConfig: Partial; dateStartInvalid: boolean = false; @@ -63,39 +63,40 @@ export class AddLicense implements OnInit { this.editionLoginsText = ''; this.insertUpdateLicenseFrm = this.fb.group({ licenseId: [0], - accountNumber: ['', Validators.required], + accountNumber: ['', [Validators.required,this.noWhitespaceValidator]], accountTypeId: [0, Validators.min(1)], productId: [''], - licenseeFirstName: ['', Validators.required], - licenseeLastName: ['', Validators.required], + licenseeFirstName: ['', [Validators.required,this.noWhitespaceValidator]], + licenseeLastName: ['', [Validators.required,this.noWhitespaceValidator]], licenseTypeId: [1], - institutionName: ['', Validators.required], - address1: ['', Validators.required], + institutionName: ['', [Validators.required,this.noWhitespaceValidator]], + address1: ['', [Validators.required,this.noWhitespaceValidator]], address2: [''], - city: ['', Validators.required], + city: ['', [Validators.required,this.noWhitespaceValidator]], stateId: [0, Validators.min(1)], countryId: [0, Validators.min(1)], - zip: ['', Validators.required], - emailId: ['', [Validators.email, Validators.required]], - phone: ['', [Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$')]], + zip: ['', [Validators.required,this.noWhitespaceValidator]], + emailId: ['', [Validators.required,this.noWhitespaceValidator]], + phone: ['', [Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$'),this.noWhitespaceValidator]], editionLoginArr: this.fb.array([]), editionLogins: [''], totalLogins: [0], - subscriptionPrice: ['', [Validators.required, Validators.pattern('[0-9.]*')]], - subscriptionStartDate: ['', Validators.required], + subscriptionPrice: [0, [Validators.required, Validators.pattern('[0-9.]*'),this.noWhitespaceValidator]], + subscriptionStartDate: [this.startDate, Validators.required], subscriptionEndDate: ['', Validators.required], - noOfImages: [0, [Validators.required, Validators.pattern('[0-9]*')]], - masterSiteUrl: ['a', Validators.required], + noOfImages: ['', [Validators.required, Validators.pattern('[0-9]*'),this.noWhitespaceValidator]], + masterSiteUrl: ['a', [Validators.required,this.noWhitespaceValidator]], siteUrlFrom: [''], siteUrlTo: [''], - login: ['a', [Validators.required, Validators.minLength(8)]], - password: ['a', [Validators.required, Validators.minLength(8)]], + login: ['a', [Validators.required, Validators.minLength(8),this.noWhitespaceValidator]], + password: ['a', [Validators.required, Validators.minLength(8),this.noWhitespaceValidator]], securityQuestionId: [0, Validators.min(1)], - answer: ['a', Validators.required], + answer: ['a', [Validators.required,this.noWhitespaceValidator]], testLicenseEditionId: [1], creatorId: [this.globalService.loggedInUser.Id], renew: [false], renewDate: [''], + //renewDate: ['', Validators.required], totalRenewals: [0], isActive: ['false'] }); @@ -133,7 +134,76 @@ export class AddLicense implements OnInit { }); }, error => this.error = error); } + public noWhitespaceValidator(control: FormControl) { + // new validation for intial whaite space + //****Birendra *****/ + var isValid=false; + if(control.value!=null) + { + var controlLen=control.value.length; + if(controlLen==undefined)//undefined for integer value + { + isValid=true; + } + else if(controlLen!=0) + { + const isWhitespace = (control.value || '').trim().length === 0; + isValid = !isWhitespace; + if(!isValid) + { + control.setValue(''); + + } + } + } + // can use also on page of input control + // + return isValid ? null: { 'whitespace': true }; + + } + + onKeyUp(event: any) { + var mobno = event.target.value; + var newnum=mobno; + if(mobno!="" && event.key!="Backspace") + { + var tempArr = mobno.split('-'); + + if(tempArr.length==1) + { + var countdigit=tempArr[0].length; + newnum=tempArr[0]; + if(countdigit==3) + { + newnum=tempArr[0]+"-"; + } + else if(countdigit>3) + { + newnum=tempArr[0].substr(0,3)+"-"+tempArr[0].substr(3,1); + } + + } + else if(tempArr.length==2) + { + newnum=tempArr[0]+"-"+tempArr[1]; + var countdigit=tempArr[1].length; + if(countdigit==3) + { + newnum=tempArr[0]+"-"+tempArr[1]+"-"; + } + else if(countdigit>3) + { + newnum= tempArr[0]+"-"+tempArr[1].substr(0,3)+"-"+tempArr[1].substr(3,1); + } + } + else + { + newnum=tempArr[0]+"-"+tempArr[1]+"-"+tempArr[2]; + } + } + this.insertUpdateLicenseFrm.controls['phone'].setValue(newnum); +}; openModal(template: TemplateRef) { this.modalRef = this.modalService.show(template); @@ -157,6 +227,46 @@ export class AddLicense implements OnInit { this.OnLoginBlur(); } + // clear alert on check/uncheck renew checkbox + reNewChange(isChecked: boolean) + { + this.alerts = ''; + this.NumberOfRows=0; + //renew date + if(isChecked) + { + this.insertUpdateLicenseFrm.controls['renewDate'].clearValidators(); + this.insertUpdateLicenseFrm.controls['renewDate'].setValidators(Validators.required); + } + else + { + this.insertUpdateLicenseFrm.controls['renewDate'].clearValidators(); + } + this.insertUpdateLicenseFrm.controls['renewDate'].updateValueAndValidity(); + + if (this.insertUpdateLicenseFrm.controls['licenseTypeId'].value == 2) { + this.insertUpdateLicenseFrm.controls['editionLoginArr'].value.forEach(element => { + if(this.NumberOfRows >1) + { + this.alerts = "Please select one edition only."; + } + else{ + if (element.Checked == 1 && element.Login > 0) { + this.NumberOfRows+=1 + } + else if (element.Checked == 1) + { + this.NumberOfRows+=1 + } + + } + }); + if(this.totalLogins>1) + { + this.alerts += "
For single license total login can not be more than one."; + } + } + } DateChange(dateValue: any) { this.alerts = ''; this.NumberOfRows=0; @@ -232,11 +342,7 @@ export class AddLicense implements OnInit { if (Date.parse(this.insertUpdateLicenseFrm.controls['subscriptionStartDate'].value) > Date.parse(this.insertUpdateLicenseFrm.controls['subscriptionEndDate'].value)) { this.alerts += 'Subscription start date must be less than the subscription end date
'; - } - // if (Date.parse(this.insertUpdateLicenseFrm.controls['subscriptionStartDate'].value) > - // Date.parse(this.insertUpdateLicenseFrm.controls['renewDate'].value)) { - // this.alerts += 'Subscription start date must be less than the subscription renew date
'; - //} + } } } } @@ -289,7 +395,7 @@ export class AddLicense implements OnInit { if (this.license.SiteUrlTo == null) { this.license.SiteUrlTo = ''; } - this.LicenseTypeChanged(this.license.LicenseTypeId); + this.LicenseTypeChanged(this.license.LicenseTypeId,this.license.SubscriptionStartDate); this.insertUpdateLicenseFrm.controls['licenseId'].setValue(this.license.LicenseId); this.insertUpdateLicenseFrm.controls['licenseTypeId'].setValue(this.license.LicenseTypeId); this.insertUpdateLicenseFrm.controls['accountNumber'].setValue(this.license.AccountNumber); @@ -300,7 +406,7 @@ export class AddLicense implements OnInit { this.insertUpdateLicenseFrm.controls['institutionName'].setValue(this.license.InstitutionName); this.insertUpdateLicenseFrm.controls['address1'].setValue(this.license.Address1); this.insertUpdateLicenseFrm.controls['address2'].setValue(this.license.Address2); - this.insertUpdateLicenseFrm.controls['city'].setValue(this.license.City); + this.insertUpdateLicenseFrm.controls['city'].setValue(this.license.City); this.insertUpdateLicenseFrm.controls['stateId'].setValue(this.license.StateId); this.insertUpdateLicenseFrm.controls['countryId'].setValue(this.license.CountryId); this.insertUpdateLicenseFrm.controls['zip'].setValue(this.license.Zip); @@ -310,7 +416,7 @@ export class AddLicense implements OnInit { this.insertUpdateLicenseFrm.controls['subscriptionPrice'].setValue(this.license.Price); this.insertUpdateLicenseFrm.controls['subscriptionStartDate'].setValue(this.datePipe.transform(this.license.SubscriptionStartDate, 'MM/dd/yyyy')); this.insertUpdateLicenseFrm.controls['subscriptionEndDate'].setValue(this.datePipe.transform(this.license.SubscriptionEndDate, 'MM/dd/yyyy')); - this.insertUpdateLicenseFrm.controls['renewDate'].setValue(this.datePipe.transform(this.license.Renewdate, 'MM/dd/yyyy')); + this.insertUpdateLicenseFrm.controls['renewDate'].setValue(this.datePipe.transform(this.license.RenewDate, 'MM/dd/yyyy')); this.insertUpdateLicenseFrm.controls['noOfImages'].setValue(this.license.NoOfImages); this.insertUpdateLicenseFrm.controls['masterSiteUrl'].setValue(this.license.MasterSiteUrl); this.insertUpdateLicenseFrm.controls['siteUrlFrom'].setValue(this.license.SiteUrlFrom); @@ -329,14 +435,14 @@ export class AddLicense implements OnInit { this.insertUpdateLicenseFrm.controls['isActive'].setValue('false'); } - this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); - if (this.lstCountry.find(C => C.Id == this.license.CountryId).CountryName != "United States") { - this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required]); - } - else { - this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$')]); - } - this.insertUpdateLicenseFrm.controls['phone'].updateValueAndValidity(); + // this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); + // if (this.lstCountry.find(C => C.Id == this.license.CountryId).CountryName != "United States") { + // this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required,this.noWhitespaceValidator]); + // } + // else { + // this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$'),this.noWhitespaceValidator]); + // } + // this.insertUpdateLicenseFrm.controls['phone'].updateValueAndValidity(); this.insertUpdateLicenseFrm.controls['phone'].setValue(this.license.Phone); if (this.license.EditionLogins == null) return; @@ -390,9 +496,7 @@ export class AddLicense implements OnInit { else{ this._confirmService.activate("License saved successfully.", "alertMsg"); } - - //this.modalAlerts = "

License saved successfully.

"; - // this.modalRef = this.modalService.show(template); + } } @@ -401,8 +505,7 @@ export class AddLicense implements OnInit { this.alerts = "License update unsuccessfull."; } else { this._confirmService.activate("License updated successfully.", "alertMsg"); - // this.modalAlerts = "

License updated successfully.

"; - //this.modalRef = this.modalService.show(template); + } } @@ -471,7 +574,15 @@ export class AddLicense implements OnInit { } } - LicenseTypeChanged(LicenseTypeId: number) { + LicenseTypeChanged(LicenseTypeId: number,startDate: Date) { + + var currentDate = new Date(); + + if(startDate==undefined) + { + this.insertUpdateLicenseFrm.controls['subscriptionStartDate'].setValue(currentDate); + + } this.totalLogins = 0; this.editionLoginsText = ''; this.license.TotalLogins = this.totalLogins; @@ -483,6 +594,7 @@ export class AddLicense implements OnInit { this.insertUpdateLicenseFrm.controls['subscriptionPrice'].setValue(''); this.insertUpdateLicenseFrm.controls['masterSiteUrl'].setValue(''); this.insertUpdateLicenseFrm.controls['accountNumber'].setValue(''); + this.lstEditionLogins = new Array(); this.lstEdition.forEach(element => { this.lstEditionLogins.push({ Id: element.Id, Title: element.Title, Login: 0 }); @@ -542,7 +654,7 @@ export class AddLicense implements OnInit { if (this.insertUpdateLicenseFrm.controls['renew'].value == true){ if (Date.parse(this.insertUpdateLicenseFrm.controls['subscriptionStartDate'].value) < Date.parse(this.license.SubscriptionEndDate.toString())) { - this.alerts += 'The new subscription start date should be greater than the previous subscription end date'; + this.alerts += 'The new subscription start date should be greater than the previous subscription end date('+this.datePipe.transform(this.license.SubscriptionEndDate, 'MM/dd/yyyy')+')'; } } this.editionLoginsText = ''; @@ -552,8 +664,7 @@ export class AddLicense implements OnInit { this.editionLoginsText += element.Id.toString() + '-' + element.Login + '|'; } }); - } - + } else { this.insertUpdateLicenseFrm.controls['editionLoginArr'].value.forEach(element => { if (element.Login > 0) { @@ -612,16 +723,16 @@ export class AddLicense implements OnInit { if (this.lstCountry.find(C => C.Id == this.license.CountryId).CountryName != "United States") { this.license.StateId = this.lstState.find(C => C.StateName == "Other").Id; this.insertUpdateLicenseFrm.controls['stateId'].setValue(this.license.StateId); - this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); - this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required]); + // this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); + // this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required,this.noWhitespaceValidator]); } else { this.license.StateId = 0; this.insertUpdateLicenseFrm.controls['stateId'].setValue(this.license.StateId); - this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); - this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$')]); + // this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); + // this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$'),this.noWhitespaceValidator]); } - this.insertUpdateLicenseFrm.controls['phone'].updateValueAndValidity(); + //this.insertUpdateLicenseFrm.controls['phone'].updateValueAndValidity(); } OnStateChange(element: any) { @@ -629,16 +740,16 @@ export class AddLicense implements OnInit { if (this.lstState.find(C => C.Id == this.license.StateId).StateName != "Other") { this.license.CountryId = this.lstCountry.find(C => C.CountryName == "United States").Id; this.insertUpdateLicenseFrm.controls['countryId'].setValue(this.license.CountryId); - this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); - this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$')]); + // this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); + // this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$'),this.noWhitespaceValidator]); } else { this.license.CountryId = 0; this.insertUpdateLicenseFrm.controls['countryId'].setValue(this.license.CountryId); - this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); - this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required]); + // this.insertUpdateLicenseFrm.controls['phone'].clearValidators(); + // this.insertUpdateLicenseFrm.controls['phone'].setValidators([Validators.required,this.noWhitespaceValidator]); } - this.insertUpdateLicenseFrm.controls['phone'].updateValueAndValidity(); + // this.insertUpdateLicenseFrm.controls['phone'].updateValueAndValidity(); } SubscriptionPriceBlur() { diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.html b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.html index 4ff43c6..2cede89 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.html +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.html @@ -97,9 +97,9 @@
- -
Email is required
-
Email is invalid
+ +
Email is required
+
Email is invalid
@@ -161,7 +161,7 @@
- + (xxx-xxx-xxxx)
Phone is required
Phone is invalid
diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.ts b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.ts index 120b010..bdbc411 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.ts @@ -48,23 +48,93 @@ export class EditLicenseBasicSettings implements OnInit { this.lastScrollPos = 0; this.updateLicenseBasicSettingsFrm = this.fb.group({ licenseId: [0], - accountNumber: ['', Validators.required], - licenseeFirstName: ['', Validators.required], - licenseeLastName: ['', Validators.required], - institutionName: ['', Validators.required], - address1: ['', Validators.required], + accountNumber: ['', [Validators.required,this.noWhitespaceValidator]], + licenseeFirstName: ['', [Validators.required,this.noWhitespaceValidator]], + licenseeLastName: ['', [Validators.required,this.noWhitespaceValidator]], + institutionName: ['', [Validators.required,this.noWhitespaceValidator]], + address1: ['', [Validators.required,this.noWhitespaceValidator]], address2: [''], - city: ['', Validators.required], + city: ['', [Validators.required,this.noWhitespaceValidator]], stateId: [0], countryId: [0], - zip: ['', Validators.required], - emailId: ['', [Validators.required, Validators.email]], - phone: ['', [Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$')]], + zip: ['', [Validators.required,this.noWhitespaceValidator]], + emailId: ['', [Validators.required,this.noWhitespaceValidator]], + phone: ['', [Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$'),this.noWhitespaceValidator]], }); this.GetCountry(); this.GetState(); this.GetLicenseAccounts(); } + public noWhitespaceValidator(control: FormControl) { + // new validation for intial whaite space + //****Birendra *****/ + var isValid=false; + if(control.value!=null) + { + var controlLen=control.value.length; + if(controlLen==undefined)//undefined for integer value + { + isValid=true; + } + else if(controlLen!=0) + { + const isWhitespace = (control.value || '').trim().length === 0; + isValid = !isWhitespace; + if(!isValid) + { + control.setValue(''); + + } + } + } + // can use also on page of input control + // + return isValid ? null: { 'whitespace': true }; + + } + onKeyUp(event: any) { + var mobno = event.target.value; + var newnum=mobno; + if(mobno!="" && event.key!="Backspace") + { + var tempArr = mobno.split('-'); + + if(tempArr.length==1) + { + var countdigit=tempArr[0].length; + newnum=tempArr[0]; + if(countdigit==3) + { + newnum=tempArr[0]+"-"; + } + else if(countdigit>3) + { + newnum=tempArr[0].substr(0,3)+"-"+tempArr[0].substr(3,1); + } + + } + else if(tempArr.length==2) + { + newnum=tempArr[0]+"-"+tempArr[1]; + var countdigit=tempArr[1].length; + if(countdigit==3) + { + newnum=tempArr[0]+"-"+tempArr[1]+"-"; + } + else if(countdigit>3) + { + newnum= tempArr[0]+"-"+tempArr[1].substr(0,3)+"-"+tempArr[1].substr(3,1); + } + } + else + { + newnum=tempArr[0]+"-"+tempArr[1]+"-"+tempArr[2]; + } + + } + this.updateLicenseBasicSettingsFrm.controls['phone'].setValue(newnum); + +}; openModal(template: TemplateRef) { this.modalRef = this.modalService.show(template); diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/searchlicense.component.ts b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/searchlicense.component.ts index a9d2a44..f436e13 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/searchlicense.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/searchlicense.component.ts @@ -177,7 +177,7 @@ export class SearchLicense implements OnInit, AfterViewChecked { this.license = this.licenses[0]; this.searchLicenseFrm.setControl('licenses', this.fb.array(this.licenses)); if(this.selectedId > -1){ - this.license = this.searchLicenseFrm.controls['licenses'].value.find(C => C.LicenseId = this.selectedId); + this.license = this.searchLicenseFrm.controls['licenses'].value.find(C => C.LicenseId == this.selectedId); } if (this.licenses.length > 0) { this.NoRecord = ''; diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/sitelicenseaccount.component.html b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/sitelicenseaccount.component.html index 8559ced..26ef230 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/sitelicenseaccount.component.html +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/sitelicenseaccount.component.html @@ -336,7 +336,7 @@
- + (xxx-xxx-xxxx)
Phone is required
@@ -362,7 +362,7 @@
- +
diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/sitelicenseaccount.component.ts b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/sitelicenseaccount.component.ts index 1028b3b..8739200 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/sitelicenseaccount.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/sitelicenseaccount.component.ts @@ -63,22 +63,22 @@ export class SiteLicenseAccount implements OnInit { licenseId: [0], accountNumber: [{value: '', disabled: true}], siteId: [0], - siteUrl: ['', Validators.required], + siteUrl: ['', [Validators.required,this.noWhitespaceValidator]], siteUrlTo: [''], siteMasterUrlTo: [''], buildAccName: [''], - institutionName: ['', Validators.required], + institutionName: ['', [Validators.required,this.noWhitespaceValidator]], departmentName: [''], - address1: ['', Validators.required], + address1: ['', [Validators.required,this.noWhitespaceValidator]], address2: [''], - city: ['', Validators.required], + city: ['', [Validators.required,this.noWhitespaceValidator]], countryId: [0, Validators.min(1)], stateId: [0, Validators.min(1)], - zip: ['', Validators.required], - phone: ['', [Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$')]], + zip: ['', [Validators.required,this.noWhitespaceValidator]], + phone: ['', [Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$'),this.noWhitespaceValidator]], //phone: ['', Validators.required], clientAdminId: [0, Validators.min(1)], - clientAdminEmail: [{value: '', disabled: true}, Validators.email], + clientAdminEmail: [{value: '', disabled: true}, this.noWhitespaceValidator], isActive: [0], isMaster: [0], creationDate: [''], @@ -123,6 +123,75 @@ export class SiteLicenseAccount implements OnInit { document.body.appendChild(testScript); } } + public noWhitespaceValidator(control: FormControl) { + // new validation for intial whaite space + //****Birendra *****/ + var isValid=false; + if(control.value!=null) + { + var controlLen=control.value.length; + if(controlLen==undefined)//undefined for integer value + { + isValid=true; + } + else if(controlLen!=0) + { + const isWhitespace = (control.value || '').trim().length === 0; + isValid = !isWhitespace; + if(!isValid) + { + control.setValue(''); + + } + } + } + // can use also on page of input control + // + return isValid ? null: { 'whitespace': true }; + + } + onKeyUp(event: any) { + var mobno = event.target.value; + var newnum=mobno; + if(mobno!="" && event.key!="Backspace") + { + var tempArr = mobno.split('-'); + + if(tempArr.length==1) + { + var countdigit=tempArr[0].length; + newnum=tempArr[0]; + if(countdigit==3) + { + newnum=tempArr[0]+"-"; + } + else if(countdigit>3) + { + newnum=tempArr[0].substr(0,3)+"-"+tempArr[0].substr(3,1); + } + + } + else if(tempArr.length==2) + { + newnum=tempArr[0]+"-"+tempArr[1]; + var countdigit=tempArr[1].length; + if(countdigit==3) + { + newnum=tempArr[0]+"-"+tempArr[1]+"-"; + } + else if(countdigit>3) + { + newnum= tempArr[0]+"-"+tempArr[1].substr(0,3)+"-"+tempArr[1].substr(3,1); + } + } + else + { + newnum=tempArr[0]+"-"+tempArr[1]+"-"+tempArr[2]; + } + + } + this.insertUpdateSiteLicenseFrm.controls['phone'].setValue(newnum); + }; openModal(template: TemplateRef) { this.modalRef = this.modalService.show(template); @@ -428,46 +497,38 @@ export class SiteLicenseAccount implements OnInit { this.insertUpdateSiteLicenseFrm.controls['clientAdminEmail'].setValue(''); } OnCountryChange(element: any) { - if (element.innerText != '') { - - } - else { this.license.CountryId = parseInt(element.value); if (this.lstCountry.find(C => C.Id == this.license.CountryId).CountryName != "United States") { this.license.StateId = this.lstState.find(C => C.StateName == "Other").Id; this.insertUpdateSiteLicenseFrm.controls['stateId'].setValue(this.license.StateId); - this.insertUpdateSiteLicenseFrm.controls['phone'].clearValidators(); - this.insertUpdateSiteLicenseFrm.controls['phone'].setValidators([Validators.required]); + // this.insertUpdateSiteLicenseFrm.controls['phone'].clearValidators(); + // this.insertUpdateSiteLicenseFrm.controls['phone'].setValidators([Validators.required,this.noWhitespaceValidator]); } else { this.license.StateId = 0; this.insertUpdateSiteLicenseFrm.controls['stateId'].setValue(this.license.StateId); - this.insertUpdateSiteLicenseFrm.controls['phone'].clearValidators(); - this.insertUpdateSiteLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$')]); + // this.insertUpdateSiteLicenseFrm.controls['phone'].clearValidators(); + // this.insertUpdateSiteLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$'),this.noWhitespaceValidator]); } - this.insertUpdateSiteLicenseFrm.controls['phone'].updateValueAndValidity(); - } + // this.insertUpdateSiteLicenseFrm.controls['phone'].updateValueAndValidity(); + } OnStateChange(element: any) { - if (element.innerText != '') { - - } - else { this.license.StateId = parseInt(element.value); if (this.lstState.find(C => C.Id == this.license.StateId).StateName != "Other") { this.license.CountryId = this.lstCountry.find(C => C.CountryName == "United States").Id; this.insertUpdateSiteLicenseFrm.controls['countryId'].setValue(this.license.CountryId); - this.insertUpdateSiteLicenseFrm.controls['phone'].clearValidators(); - this.insertUpdateSiteLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$')]); + // this.insertUpdateSiteLicenseFrm.controls['phone'].clearValidators(); + // this.insertUpdateSiteLicenseFrm.controls['phone'].setValidators([Validators.required, Validators.pattern('^([0-9]{3})-([0-9]{3})-([0-9]{4})$'),this.noWhitespaceValidator]); } else { this.license.CountryId = 0; this.insertUpdateSiteLicenseFrm.controls['countryId'].setValue(this.license.CountryId); - this.insertUpdateSiteLicenseFrm.controls['phone'].clearValidators(); - this.insertUpdateSiteLicenseFrm.controls['phone'].setValidators([Validators.required]); + // this.insertUpdateSiteLicenseFrm.controls['phone'].clearValidators(); + // this.insertUpdateSiteLicenseFrm.controls['phone'].setValidators([Validators.required,this.noWhitespaceValidator]); } - this.insertUpdateSiteLicenseFrm.controls['phone'].updateValueAndValidity(); - } + // this.insertUpdateSiteLicenseFrm.controls['phone'].updateValueAndValidity(); + } EditLicenseSite(){ diff --git a/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.ts b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.ts index e5b19ed..a8f3be1 100644 --- a/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.ts @@ -55,9 +55,9 @@ RecordDeleted: number[]; }); this.insertSubscriptionPriceFrm = this.fb.group({ subscriptionPriceId: [''], - title: ['', Validators.required], - price: ['', [Validators.required, Validators.pattern('[0-9.]*')]], - duration: ['', [Validators.required, Validators.pattern('[0-9]*')]], + title: ['', [Validators.required,this.noWhitespaceValidator]], + price: ['', [Validators.required, Validators.pattern('[0-9.]*'),this.noWhitespaceValidator]], + duration: ['', [Validators.required, Validators.pattern('[0-9]*'),this.noWhitespaceValidator]], editionId: [''], isActive: ['false'] }); @@ -91,6 +91,33 @@ RecordDeleted: number[]; document.body.appendChild(testScript); } } + public noWhitespaceValidator(control: FormControl) { + // new validation for intial whaite space + //****Birendra *****/ + var isValid=false; + if(control.value!=null) + { + var controlLen=control.value.length; + if(controlLen==undefined)//undefined for integer value + { + isValid=true; + } + else if(controlLen!=0) + { + const isWhitespace = (control.value || '').trim().length === 0; + isValid = !isWhitespace; + if(!isValid) + { + control.setValue(''); + + } + } + } + // can use also on page of input control + // + return isValid ? null: { 'whitespace': true }; + + } public SearchSubscriptionPrices(evt: any) { if (this.global.ValidationMsg != '') { diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html index bf45b20..a697839 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html @@ -71,6 +71,7 @@
Last Name is required
+
@@ -89,6 +90,7 @@
+
@@ -116,6 +118,7 @@
+
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts index 53d69d6..59ddd38 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts @@ -60,29 +60,65 @@ export class AddUser implements OnInit, AfterViewInit { //this.userservice.GetUserById(this.UserId); this.adduserFrm = this.fb.group({ id: [''], - UserName: ['', [Validators.required, Validators.minLength(8)]], - Password: ['', [Validators.required, Validators.minLength(8)]], - ConfirmPassword: ['', Validators.required], - FirstName: ['', Validators.required], - LastName: ['', Validators.required], - EmailId: ['', Validators.required], + UserName: ['', [Validators.required, Validators.minLength(8),this.noWhitespaceValidator]], + Password: ['', [Validators.required, Validators.minLength(8),this.noWhitespaceValidator]], + ConfirmPassword: ['', [Validators.required,this.noWhitespaceValidator]], + FirstName: ['', [Validators.required,this.noWhitespaceValidator]], + LastName: ['', [Validators.required,this.noWhitespaceValidator]], + EmailId: ['', [Validators.required,this.noWhitespaceValidator]], AccountNumberId: ['', Validators.required], UserTypeId: ['', Validators.required], ProductEditionId: ['', Validators.required] }); this._loadingService.ShowLoading("global-loading"); - this.bindUsers(); - this.GetAccountNumber(); - //this.GetUserTypeByLicenseId(); - + this.bindUsers(0); + if(this.router.url === '/adduser') + { + this.GetAccountNumber(); + } + else{ + this._loadingService.HideLoading("global-loading"); + } + } ngAfterViewInit() { - this.CheckDropDownOrUp(this.accountNodiv.nativeElement); + if(this.router.url === '/adduser') + { + this.CheckDropDownOrUp(this.accountNodiv.nativeElement); + } + } redirect() { this.router.navigate(['/']); } + public noWhitespaceValidator(control: FormControl) { + // new validation for intial whaite space + //****Birendra *****/ + var isValid=false; + if(control.value!=null) + { + var controlLen=control.value.length; + if(controlLen==undefined)//undefined for integer value + { + isValid=true; + } + else if(controlLen!=0) + { + const isWhitespace = (control.value || '').trim().length === 0; + isValid = !isWhitespace; + if(!isValid) + { + control.setValue(''); + + } + } + } + // can use also on page of input control + // + return isValid ? null: { 'whitespace': true }; + + } GetUserTypeByLicenseId() { var Accountnumber = this.adduserFrm.controls['AccountNumberId'].value; if (Accountnumber == "") { Accountnumber = 0 } @@ -222,16 +258,19 @@ export class AddUser implements OnInit, AfterViewInit { this.alerts += '
Last Name is required.'; } - - if (this.adduserFrm.value.AccountNumberId == '0') { - this.alerts += '
Please select account number'; - } - if (this.adduserFrm.value.UserTypeId == '0') { - this.alerts += '
Please select user type'; - } - if (this.adduserFrm.value.ProductEditionId == '0') { - this.alerts += '
Please select product edition'; - } + if(this.router.url === '/adduser') + { + if (this.adduserFrm.value.AccountNumberId == '0') { + this.alerts += '
Please select account number'; + } + if (this.adduserFrm.value.UserTypeId == '0') { + this.alerts += '
Please select user type'; + } + if (this.adduserFrm.value.ProductEditionId == '0') { + this.alerts += '
Please select product edition'; + } + } + if (this.alerts == '') { var AddUserEntity = this.adduserFrm.value; return this.userservice.InsertUser(AddUserEntity) @@ -253,22 +292,23 @@ export class AddUser implements OnInit, AfterViewInit { } ResetForm() { - this._buildForm(); + var lcid= this.adduserFrm.controls['AccountNumberId'].value; + this._buildForm(lcid); } - _buildForm() { + _buildForm(lcid) { this.adduserFrm = this.fb.group({ id: [''], - UserName: [""], - Password: [""], - ConfirmPassword: [""], - FirstName: [""], - LastName: [""], - EmailId: [""], - AccountNumberId: ["0"], - UserTypeId: ["0"], - ProductEditionId: ["0"] - + UserName: ['', [Validators.required, Validators.minLength(8),this.noWhitespaceValidator]], + Password: ['', [Validators.required, Validators.minLength(8),this.noWhitespaceValidator]], + ConfirmPassword: ['', [Validators.required,this.noWhitespaceValidator]], + FirstName: ['', [Validators.required,this.noWhitespaceValidator]], + LastName: ['', [Validators.required,this.noWhitespaceValidator]], + EmailId: ['', [Validators.required,this.noWhitespaceValidator]], + AccountNumberId: ['', Validators.required], + UserTypeId: ['', Validators.required], + ProductEditionId: ['', Validators.required] }); + this.bindUsers(lcid); } CheckDropDownOrUp(elm: any) { var dropDownTop = elm.children[0].offsetTop; @@ -283,23 +323,31 @@ export class AddUser implements OnInit, AfterViewInit { } @HostListener('window:scroll', ['$event']) onWindowScroll(event) { - // console.debug("Scroll Event", document.body.scrollTop); - // see Andr�s Szepesh�zi's comment below - //console.debug("Scroll Event", window.pageYOffset ); - this.CheckDropDownOrUp(this.accountNodiv.nativeElement); + if(this.router.url === '/adduser') + { + this.CheckDropDownOrUp(this.accountNodiv.nativeElement); + } } @HostListener('window:resize', ['$event']) onWindowResize(event) { - this.CheckDropDownOrUp(this.accountNodiv.nativeElement); + if(this.router.url === '/adduser') + { + this.CheckDropDownOrUp(this.accountNodiv.nativeElement); + } } - bindUsers() { - - //console.log(data); - //alert(JSON.stringify(data)); - //this.user = data[0]; - - + bindUsers(lcid) { + this.alerts = ''; + if (this.commonService.UserTypeName == "Client Admin" || this.commonService.UserTypeName == "District Admin" ) + { + this.adduserFrm.controls['AccountNumberId'].setValue(lcid) + } + else + { + this.accountDropDownText = 'Select'; + this.adduserFrm.controls['AccountNumberId'].setValue(0) + } + this.adduserFrm.controls['id'].setValue(0) this.adduserFrm.controls['FirstName'].setValue('') this.adduserFrm.controls['LastName'].setValue('') @@ -307,8 +355,17 @@ export class AddUser implements OnInit, AfterViewInit { this.adduserFrm.controls['UserName'].setValue('') this.adduserFrm.controls['Password'].setValue('') this.adduserFrm.controls['ConfirmPassword'].setValue('') - this.adduserFrm.controls['AccountNumberId'].setValue(0) - this.adduserFrm.controls['UserTypeId'].setValue(0) + + if(this.router.url === '/adduser') + { + this.adduserFrm.controls['UserTypeId'].setValue(0) + } + else + { + // for genral admin + this.adduserFrm.controls['UserTypeId'].setValue(2) + } + this.adduserFrm.controls['ProductEditionId'].setValue(0) } diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/datamodel.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/datamodel.ts index 3e573bd..b90c10f 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/datamodel.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/datamodel.ts @@ -64,7 +64,7 @@ export class License { ProductKey: string; SubscriptionStartDate: Date; SubscriptionEndDate: Date; - Renewdate: Date; + RenewDate: Date; EditionLogins: string; Price: DoubleRange; NoOfImages: number; diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.ts index cccb72d..f76f909 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.ts @@ -109,15 +109,23 @@ export class UnblockUser implements OnInit { GetBlockUserList(this) { - if (this.commonService.UserTypeName == 'District Admin') { - this.licId = this.commonService.AccLicId; - } - else if (this.commonService.UserTypeName == 'Client Admin') { - this.licId = this.commonService.AccLicId; + if (this.commonService.UserTypeName == "Client Admin" || this.commonService.UserTypeName == "District Admin") + { + if(this.commonService.AccountNumber !=undefined && this.commonService.AccountNumber !="") + { + this.licId = this.commonService.AccLicId; + } + else + { + this.licId =0 + } + } - else { + else + { this.licId =0 } + var UserFilterControl = this.UnBlockedUserFrm.value; this.userservice.GetBlockUserList( { diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.html index aa236c2..2d229f2 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.html +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.html @@ -21,25 +21,26 @@
- +
- -
First Name is required
+ +
First Name is required
- +
- -
Last Name is required
+ +
Last Name is required
- +
- -
Email is required
-
Email is invalid
+ +
Email Id is required
+ +
Email is Invalid.
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts index 7d6e6c9..4478f1a 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts @@ -44,17 +44,14 @@ export class UpdateUserProfile implements OnInit { ngOnInit(): void { this.user = new User(); this.alerts = ''; - //this.userservice.GetUserById(this.UserId); this.userFrm = this.fb.group({ id: [''], - firstName: ['', Validators.required], - lastName: ['', Validators.required], - emailId: ['', [Validators.required, Validators.email]] - // LastName: [''], - // Gender: ['', Validators.required], - // Email: [''] + firstName: ['', [Validators.required,this.noWhitespaceValidator]], + lastName: ['', [Validators.required,this.noWhitespaceValidator]], + emailId: ['', [Validators.required,this.noWhitespaceValidator]] }); + this._loadingService.ShowLoading("global-loading"); this.GetUserById(); @@ -62,21 +59,34 @@ export class UpdateUserProfile implements OnInit { redirect() { this.router.navigate(['/']); } - //ngAfterviewint() { - // this.LoadUsers(); - //} - - - //getCustomerById(UserId) { - // return this.userservice.GetUserById(UserId) - // .map((response: Response) => response.json()) - // .catch(this._errorHandler) - //} - //formErrors = { - // 'firstName': '', - // 'lastName': '', - // 'email': '' - //}; + public noWhitespaceValidator(control: FormControl) { + // new validation for intial whaite space + //****Birendra *****/ + var isValid=false; + if(control.value!=null) + { + var controlLen=control.value.length; + if(controlLen==undefined)//undefined for integer value + { + isValid=true; + } + else if(controlLen!=0) + { + const isWhitespace = (control.value || '').trim().length === 0; + isValid = !isWhitespace; + if(!isValid) + { + control.setValue(''); + + } + } + } + // can use also on page of input control + // + return isValid ? null: { 'whitespace': true }; + +} + GetUserById() { this.userservice.GetUserById() @@ -84,24 +94,35 @@ export class UpdateUserProfile implements OnInit { this._loadingService.HideLoading("global-loading"); } UpdateUserProfile() { - // debugger; - this.user = this.userFrm.value; - //if(this.user.) - //console.log(this.user); - var obj = this.user - if (this.userFrm.valid) { - return this.userservice.UpdateUserProfileById(obj) + this.alerts = ''; + if (this.userFrm.value.firstName == null ||((this.userFrm.value.firstName).trim() == '')) + { + this.alerts += 'First name is required.
'; + } + if (this.userFrm.value.lastName == null ||((this.userFrm.value.lastName).trim() == '')) + { + this.alerts += 'Last name is required.
'; + } + if (this.userFrm.value.emailId == null ||((this.userFrm.value.emailId).trim() == '')) { + this.alerts += 'Email Id is required.'; + } + else if((!this.userFrm.controls.emailId.valid)) + { + this.alerts += 'Enter Valid Email Id.'; + } + + + if (this.userFrm.valid && this.alerts == '') { + var obj = this.userFrm.value; + + return this.userservice.UpdateUserProfileById(obj) .subscribe( n => (this.AfterInsertData(n)), error => this.error = error); } } AfterInsertData(data) { - debugger; - if (data.Status == "False") { - // this._confirmService.activate(data.ResponseMessage, "alertMsg"); - //setTimeout(() => this.amCode.nativeElement.focus(), 0); - // this.closeflag = false; + if (data.Status == "False") { return false; } else { this.status = true; @@ -112,34 +133,9 @@ export class UpdateUserProfile implements OnInit { localStorage.setItem("loggedInUserDetails", JSON.stringify(loggedInUser)); this.global.DisplayName = loggedInUser.FirstName + " " + loggedInUser.LastName; this._confirmService.activate("User Profile Updated Successfully.", "alertMsg"); - // window.location.href = this.global.LiveURL; - - - //this.profileModal.open(); - // this.submitted = false; - // this.GetAllAcctMgr(); - // this.DisableAllControls(); - // this.AccountManagerID.enable(); - // let accountManagerID: string = data.Id == null ? "" : data.Id.toString(); - // console.log(accountManagerID); - - // this.GetAcctMgr(Number(accountManagerID)); - //this.GetAccountManagerListOptions(false); - // this.defautValue = data.id; - // this.BtnReset = true; - // this.BtnSave = true; - // this.BtnEdit = false; - // this.BtnNew = false; - // this.BtnDelete = false; - // this.Abbrevtion = this.Abbrev.value; - // setTimeout(() => this.AMform.controls["AccountManagerID"].setValue(accountManagerID.toString()), 1000); - // setTimeout(() => this.AMform.markAsPristine(), 2000); + } - //if (this.closeflag) { - // this.close.emit(null); - //} - //else { - //} + } bindUsers(data) { @@ -152,23 +148,8 @@ export class UpdateUserProfile implements OnInit { this.userFrm.controls['firstName'].setValue(this.user.FirstName) this.userFrm.controls['lastName'].setValue(this.user.LastName) this.userFrm.controls['emailId'].setValue(this.user.EmailId) - // this.GetClientListOptions(false); - // this.GetCrossRefClientListOptions(false); } - //extractData(res: Response) { - // //debugger; - // let body = res.json(); - // return body; - //} - //handleError(error: any) { - - // // In a real world app, we might use a remote logging infrastructure - // // We'd also dig deeper into the error to get a better message - // let errMsg = (error.message) ? error.message : - // error.status ? `${error.status} - ${error.statusText}` : 'Server error'; - // console.error(errMsg); // log to console instead - // return Observable.throw(errMsg); - //} + validationMessages = { 'firstName': { 'required': 'First name is required.' diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html index 25250dd..0ba5096 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html @@ -168,7 +168,7 @@
-
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts index cefab55..b83958a 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts @@ -88,12 +88,12 @@ export class UsersList implements OnInit, AfterViewChecked { }); this.adduserFrm = this.fb.group({ id: [''], - UserName: ['', [Validators.required, Validators.minLength(8)]], - Password: ['', [Validators.required, Validators.minLength(8)]], - ConfirmPassword: ['', Validators.required], - FirstName: ['', Validators.required], - LastName: ['', Validators.required], - EmailId: ['', Validators.required], + UserName: ['', [Validators.required, Validators.minLength(8),this.noWhitespaceValidator]], + Password: ['', [Validators.required, Validators.minLength(8),this.noWhitespaceValidator]], + ConfirmPassword: ['', [Validators.required,this.noWhitespaceValidator]], + FirstName: ['', [Validators.required,this.noWhitespaceValidator]], + LastName: ['', [Validators.required,this.noWhitespaceValidator]], + EmailId: ['', [Validators.required,this.noWhitespaceValidator]], AccountNumber: [''], UserTypeTitle: [''], AccountTypeTitle: [''], @@ -114,9 +114,14 @@ export class UsersList implements OnInit, AfterViewChecked { }); - if (this.global.UserTypeName == "Client Admin" || this.global.UserTypeName == "District Admin") { - this.Users.controls['AccountNumber'].setValue(this.global.AccountNumber) - this.DisableAccountNumberControl = true; + if (this.global.UserTypeName == "Client Admin" || this.global.UserTypeName == "District Admin" ) + { + if(this.global.AccountNumber !=undefined && this.global.AccountNumber !="") + { + this.Users.controls['AccountNumber'].setValue(this.global.AccountNumber) + this.DisableAccountNumberControl = true; + } + } this._loadingService.ShowLoading("global-loading"); this.GetUserType(); @@ -167,6 +172,33 @@ export class UsersList implements OnInit, AfterViewChecked { //this.GetUserList(); } + public noWhitespaceValidator(control: FormControl) { + // new validation for intial whaite space + //****Birendra *****/ + var isValid=false; + if(control.value!=null) + { + var controlLen=control.value.length; + if(controlLen==undefined)//undefined for integer value + { + isValid=true; + } + else if(controlLen!=0) + { + const isWhitespace = (control.value || '').trim().length === 0; + isValid = !isWhitespace; + if(!isValid) + { + control.setValue(''); + + } + } + } + // can use also on page of input control + // + return isValid ? null: { 'whitespace': true }; + + } handleChange(evt) { var target = evt.target; if (target.value == 'true') { diff --git a/400-SOURCECODE/Admin/src/assets/data/Menu.json b/400-SOURCECODE/Admin/src/assets/data/Menu.json index 20d1e0c..6237dd7 100644 --- a/400-SOURCECODE/Admin/src/assets/data/Menu.json +++ b/400-SOURCECODE/Admin/src/assets/data/Menu.json @@ -85,7 +85,7 @@ "SubMenuName": "Add User", "SubMenuUrl": "adduser", "SubMenuStatus": "True" - }, + }, { "SubMenuId": "209", "SubMenuName": "Unblock User", @@ -292,7 +292,7 @@ "SubMenuName": "Add User", "SubMenuUrl": "adduser", "SubMenuStatus": "True" - }, + }, { "SubMenuId": "209", "SubMenuName": "Unblock User", @@ -1275,19 +1275,19 @@ { "HeaderMenuId": "101", "HeaderMenuName": "Licenses", - "HeaderMenuStatus": "True", + "HeaderMenuStatus": "False", "SubMenu": [ { "SubMenuId": "203", "SubMenuName": "Search License", "SubMenuUrl": "searchlicense", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "204", "SubMenuName": "Add New License", "SubMenuUrl": "addlicense", - "SubMenuStatus": "True" + "SubMenuStatus": "False" } ] @@ -1295,19 +1295,19 @@ { "HeaderMenuId": "102", "HeaderMenuName": "Product Features", - "HeaderMenuStatus": "True", + "HeaderMenuStatus": "False", "SubMenu": [ { "SubMenuId": "205", "SubMenuName": "Manage Discount Code", "SubMenuUrl": "managediscountcode", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "206", "SubMenuName": "Subscription Price", "SubMenuUrl": "subscriptionprice", - "SubMenuStatus": "True" + "SubMenuStatus": "False" } ] @@ -1315,31 +1315,31 @@ { "HeaderMenuId": "103", "HeaderMenuName": "Users", - "HeaderMenuStatus": "True", + "HeaderMenuStatus": "False", "SubMenu": [ { "SubMenuId": "207", "SubMenuName": "List User", "SubMenuUrl": "users", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "208", "SubMenuName": "Add User", "SubMenuUrl": "adduser", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "209", "SubMenuName": "Unblock User", "SubMenuUrl": "unblockuser", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "210", "SubMenuName": "User Group", "SubMenuUrl": "usergroup", - "SubMenuStatus": "True" + "SubMenuStatus": "False" } ] @@ -1347,49 +1347,49 @@ { "HeaderMenuId": "104", "HeaderMenuName": "Reports", - "HeaderMenuStatus": "True", + "HeaderMenuStatus": "False", "SubMenu": [ { "SubMenuId": "211", "SubMenuName": "Usage Report", "SubMenuUrl": "usagereport", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "212", "SubMenuName": "Customer Summary Report", "SubMenuUrl": "customersummaryreport", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "213", "SubMenuName": "Expiring Subscription Report", "SubMenuUrl": "expiringsubscriptionreport", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "214", "SubMenuName": "New Subscription Report", "SubMenuUrl": "subscriptionreport", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "215", "SubMenuName": "Subscription Cancellation Report", "SubMenuUrl": "subscriptioncancellationreport", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "216", "SubMenuName": "Net AD Subscription Report", "SubMenuUrl": "netadsubscriptionreport", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "217", "SubMenuName": "Site License Usage Report", "SubMenuUrl": "sitelicenseusagereport", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "218", @@ -1409,13 +1409,13 @@ { "HeaderMenuId": "105", "HeaderMenuName": "Site Account", - "HeaderMenuStatus": "True", + "HeaderMenuStatus": "False", "SubMenu": [ { "SubMenuId": "220", "SubMenuName": "Add Building Level Account", "SubMenuUrl": "sitelicenseaccount", - "SubMenuStatus": "True" + "SubMenuStatus": "False" } ] @@ -1423,19 +1423,19 @@ { "HeaderMenuId": "106", "HeaderMenuName": "Settings", - "HeaderMenuStatus": "True", + "HeaderMenuStatus": "False", "SubMenu": [ { "SubMenuId": "221", "SubMenuName": "View-Update Profile", "SubMenuUrl": "editlicensebasicsettings", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "222", "SubMenuName": "Manage Modesty Settings", "SubMenuUrl": "licensemodestysettings", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "223",