diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/LicenseModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/LicenseModel.cs index b799b28..034fd12 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 = (result[0].RenewalDate == null ? DateTime.Now.Date : result[0].RenewalDate.Value); } } catch (Exception ex) { } diff --git a/400-SOURCECODE/Admin/src/app/app.component.html b/400-SOURCECODE/Admin/src/app/app.component.html index ec5e7e3..5c51d35 100644 --- a/400-SOURCECODE/Admin/src/app/app.component.html +++ b/400-SOURCECODE/Admin/src/app/app.component.html @@ -33,7 +33,7 @@ diff --git a/400-SOURCECODE/Admin/src/app/app.routing.module.ts b/400-SOURCECODE/Admin/src/app/app.routing.module.ts index 35be9fd..6f65634 100644 --- a/400-SOURCECODE/Admin/src/app/app.routing.module.ts +++ b/400-SOURCECODE/Admin/src/app/app.routing.module.ts @@ -33,6 +33,7 @@ const appRoutes: Routes = [ { path: 'managediscountcode', component: ManageDiscountCode }, { path: 'subscriptionprice', component: SubscriptionPrice }, { path: 'adduser', component: AddUser }, + { path: 'addgeneral', component: AddUser }, { path: 'unblockuser', component: UnblockUser }, { path: 'searchlicense', component: SearchLicense }, { path: 'addlicense', component: AddLicense }, diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.html b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.html index b7e1c7f..12b6adf 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.html +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.html @@ -104,7 +104,7 @@
@@ -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..abbea45 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,39 @@ 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 +133,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 +226,34 @@ export class AddLicense implements OnInit { this.OnLoginBlur(); } + // clear alert on check/uncheck renew checkbox + reNewChange(isChecked: boolean) + { + this.alerts = ''; + this.NumberOfRows=0; + 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; @@ -289,7 +386,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 +397,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 +407,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); @@ -331,10 +428,10 @@ export class AddLicense implements OnInit { 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.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.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); @@ -471,7 +568,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 +588,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 }); @@ -574,10 +680,10 @@ export class AddLicense implements OnInit { this.alerts += 'Account number already exists. Enter a different account number.'; } if (this.alerts == '') { - return this.licenseService.InsertLicense(obj) - .subscribe( - n => (this.AfterInsertData(n, template)), - error => this.error = error); + // return this.licenseService.InsertLicense(obj) + // .subscribe( + // n => (this.AfterInsertData(n, template)), + // error => this.error = error); } }, error => this.error = error); @@ -589,10 +695,10 @@ export class AddLicense implements OnInit { if (this.alerts == '') { console.log(this.insertUpdateLicenseFrm.controls['subscriptionStartDate'].value + ', ' + this.insertUpdateLicenseFrm.controls['subscriptionEndDate'].value + ', ' + this.insertUpdateLicenseFrm.controls['renewDate'].value); console.log(obj.subscriptionStartDate + ', ' + obj.subscriptionEndDate + ', ' + obj.renewDate); - return this.licenseService.UpdateLicense(obj) - .subscribe( - n => (this.AfterUpdateData(n, template)), - error => this.error = error); + // return this.licenseService.UpdateLicense(obj) + // .subscribe( + // n => (this.AfterUpdateData(n, template)), + // error => this.error = error); } } } @@ -612,16 +718,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 +735,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/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..b0c124f 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/updateuserprofile.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts index 0d86130..4478f1a 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts @@ -66,7 +66,11 @@ export class UpdateUserProfile implements OnInit { if(control.value!=null) { var controlLen=control.value.length; - if(controlLen!=0) + if(controlLen==undefined)//undefined for integer value + { + isValid=true; + } + else if(controlLen!=0) { const isWhitespace = (control.value || '').trim().length === 0; isValid = !isWhitespace; 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 9606625..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: [''], @@ -172,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 26197de..298d8ac 100644 --- a/400-SOURCECODE/Admin/src/assets/data/Menu.json +++ b/400-SOURCECODE/Admin/src/assets/data/Menu.json @@ -87,6 +87,12 @@ "SubMenuStatus": "True" }, { + "SubMenuId": "224", + "SubMenuName": "Add General Admin", + "SubMenuUrl": "addgeneral", + "SubMenuStatus": "True" + }, + { "SubMenuId": "209", "SubMenuName": "Unblock User", "SubMenuUrl": "unblockuser", @@ -294,6 +300,12 @@ "SubMenuStatus": "True" }, { + "SubMenuId": "224", + "SubMenuName": "Add General Admin", + "SubMenuUrl": "addgeneral", + "SubMenuStatus": "True" + }, + { "SubMenuId": "209", "SubMenuName": "Unblock User", "SubMenuUrl": "unblockuser",