From 33a73ace68fc9fcfb424988b676b72ff43f24979 Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Thu, 11 Apr 2024 19:06:32 +0300 Subject: [PATCH] fix empty values again --- .../affiliation-update.component.ts | 58 +++++++++---------- ui/src/app/member/member-update.component.ts | 40 ++++++------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ui/src/app/affiliation/affiliation-update.component.ts b/ui/src/app/affiliation/affiliation-update.component.ts index 4dd9806ce..7e2b4a8da 100644 --- a/ui/src/app/affiliation/affiliation-update.component.ts +++ b/ui/src/app/affiliation/affiliation-update.component.ts @@ -55,7 +55,7 @@ function dateValidator() { function disambiguatedOrgIdValidator(): ValidatorFn { return (control: AbstractControl): { [key: string]: boolean } | null => { - if (control.parent !== undefined) { + if (control.parent) { const disambiguationSourceValue = control.parent?.get('disambiguationSource')?.value if (disambiguationSourceValue === 'RINGGOLD') { const reg = new RegExp('^\\d+$') @@ -200,14 +200,14 @@ export class AffiliationUpdateComponent implements OnInit { onChanges(): void { this.editForm.get('startMonth')?.valueChanges.subscribe((val) => { this.startDaysList = this.dateUtilService.getDaysList( - this.editForm.get('startYear')?.value || undefined, - this.editForm.get('startMonth')?.value || undefined + this.editForm.get('startYear')?.value || null, + this.editForm.get('startMonth')?.value || null ) }) this.editForm.get('endMonth')?.valueChanges.subscribe((val) => { this.endDaysList = this.dateUtilService.getDaysList( - this.editForm.get('endYear')?.value || undefined, - this.editForm.get('endMonth')?.value || undefined + this.editForm.get('endYear')?.value || null, + this.editForm.get('endMonth')?.value || null ) }) this.editForm.get('disambiguationSource')?.valueChanges.subscribe((value) => { @@ -219,24 +219,24 @@ export class AffiliationUpdateComponent implements OnInit { updateForm(assertion: IAffiliation) { if (assertion?.id) { this.editForm.patchValue({ - id: assertion.id || null, + id: assertion.id, email: assertion.email?.trim(), affiliationSection: assertion.affiliationSection, - departmentName: assertion.departmentName || null, - roleTitle: assertion.roleTitle || null, - url: assertion.url || null, - startYear: assertion.startYear || null, + departmentName: assertion.departmentName, + roleTitle: assertion.roleTitle, + url: assertion.url, + startYear: assertion.startYear, startMonth: parseInt(assertion.startMonth || '') || null, - startDay: assertion.startDay || null, - endYear: assertion.endYear || null, + startDay: assertion.startDay, + endYear: assertion.endYear, endMonth: parseInt(assertion.endMonth || '') || null, - endDay: assertion.endDay || null, - orgName: assertion.orgName || null, - orgCountry: assertion.orgCountry || null, - orgCity: assertion.orgCity || null, - orgRegion: assertion.orgRegion || null, - disambiguatedOrgId: assertion.disambiguatedOrgId || null, - disambiguationSource: assertion.disambiguationSource || null, + endDay: assertion.endDay, + orgName: assertion.orgName, + orgCountry: assertion.orgCountry, + orgCity: assertion.orgCity, + orgRegion: assertion.orgRegion, + disambiguatedOrgId: assertion.disambiguatedOrgId, + disambiguationSource: assertion.disambiguationSource, externalId: assertion.externalId, externalIdType: assertion.externalIdType, externalIdUrl: assertion.externalIdUrl, @@ -283,27 +283,27 @@ export class AffiliationUpdateComponent implements OnInit { private createFromForm(): IAffiliation { return { ...new Affiliation(), - id: this.editForm.get(['id'])?.value, - email: this.editForm.get(['email'])?.value, + id: this.editForm.get(['id'])?.value || null, + email: this.editForm.get(['email'])?.value || null, affiliationSection: this.editForm.get(['affiliationSection'])?.value, - departmentName: this.editForm.get(['departmentName'])?.value, - roleTitle: this.editForm.get(['roleTitle'])?.value, - url: this.editForm.get(['url'])?.value, + departmentName: this.editForm.get(['departmentName'])?.value || null, + roleTitle: this.editForm.get(['roleTitle'])?.value || null, + url: this.editForm.get(['url'])?.value || null, startYear: this.editForm.get(['startYear'])?.value, startMonth: this.editForm.get(['startMonth'])?.value, startDay: this.editForm.get(['startDay'])?.value, endYear: this.editForm.get(['endYear'])?.value, endMonth: this.editForm.get(['endMonth'])?.value, endDay: this.editForm.get(['endDay'])?.value, - orgName: this.editForm.get(['orgName'])?.value, + orgName: this.editForm.get(['orgName'])?.value || null, orgCountry: this.editForm.get(['orgCountry'])?.value, orgCity: this.editForm.get(['orgCity'])?.value, - orgRegion: this.editForm.get(['orgRegion'])?.value, + orgRegion: this.editForm.get(['orgRegion'])?.value || null, disambiguatedOrgId: this.editForm.get(['disambiguatedOrgId'])?.value, disambiguationSource: this.editForm.get(['disambiguationSource'])?.value, - externalId: this.editForm.get(['externalId'])?.value, - externalIdType: this.editForm.get(['externalIdType'])?.value, - externalIdUrl: this.editForm.get(['externalIdUrl'])?.value, + externalId: this.editForm.get(['externalId'])?.value || null, + externalIdType: this.editForm.get(['externalIdType'])?.value || null, + externalIdUrl: this.editForm.get(['externalIdUrl'])?.value || null, putCode: this.editForm.get(['putCode'])?.value, created: this.editForm.get(['created'])?.value != null diff --git a/ui/src/app/member/member-update.component.ts b/ui/src/app/member/member-update.component.ts index e87bf53a0..9fe5db4f6 100644 --- a/ui/src/app/member/member-update.component.ts +++ b/ui/src/app/member/member-update.component.ts @@ -11,7 +11,7 @@ import { faBan, faSave } from '@fortawesome/free-solid-svg-icons' function parentSalesforceIdValidator(): ValidatorFn { return (control: AbstractControl): { [key: string]: boolean } | null => { - if (control.parent !== undefined && control.value !== undefined && isNaN(control.value)) { + if (control.parent && control.value && isNaN(control.value)) { const parentSalesforceId = control.value const isConsortiumLead = control.parent?.get('isConsortiumLead')?.value const salesforceId = control.parent?.get('salesforceId')?.value @@ -26,7 +26,7 @@ function parentSalesforceIdValidator(): ValidatorFn { function clientIdValidator(): ValidatorFn { return (control: AbstractControl): { [key: string]: boolean } | null => { - if (control.parent !== undefined && control.value !== undefined && isNaN(control.value)) { + if (control.parent && control.value && isNaN(control.value)) { const clientIdValue = control.value const isConsortiumLead = control.parent?.get('isConsortiumLead')?.value const assertionServiceEnabled = control.parent?.get('assertionServiceEnabled')?.value @@ -49,12 +49,12 @@ function clientIdValidator(): ValidatorFn { } return { validClientId: false } } - if (control.parent !== undefined) { + if (control.parent) { if (control.parent?.get('isConsortiumLead')?.value) { return null } } - if (control.parent !== undefined) { + if (control.parent) { if (!control.parent?.get('assertionServiceEnabled')?.value) { return null } @@ -132,13 +132,13 @@ export class MemberUpdateComponent implements OnInit { updateForm(member: IMember) { this.editForm.patchValue({ - id: member.id || null, - clientId: member.clientId || null, - clientName: member.clientName || null, - salesforceId: member.salesforceId || null, - parentSalesforceId: member.parentSalesforceId || null, - isConsortiumLead: member.isConsortiumLead || false, - assertionServiceEnabled: member.assertionServiceEnabled || false, + id: member.id, + clientId: member.clientId, + clientName: member.clientName, + salesforceId: member.salesforceId, + parentSalesforceId: member.parentSalesforceId, + isConsortiumLead: member.isConsortiumLead, + assertionServiceEnabled: member.assertionServiceEnabled ? true : false, createdBy: member.createdBy, createdDate: member.createdDate != null ? member.createdDate.format(DATE_TIME_FORMAT) : null, lastModifiedBy: member.lastModifiedBy, @@ -162,7 +162,7 @@ export class MemberUpdateComponent implements OnInit { const member = this.createFromForm() this.memberService.validate(member).subscribe((data) => { if (data.valid) { - if (member.id !== undefined) { + if (member.id !== null) { this.subscribeToUpdateResponse(this.memberService.update(member)) } else { this.subscribeToSaveResponse(this.memberService.create(member)) @@ -177,23 +177,23 @@ export class MemberUpdateComponent implements OnInit { private createFromForm(): IMember { return { ...new Member(), - id: this.editForm.get(['id'])?.value || undefined, - clientId: this.editForm.get(['clientId'])?.value, - clientName: this.editForm.get(['clientName'])?.value, - salesforceId: this.editForm.get(['salesforceId'])?.value, - parentSalesforceId: this.editForm.get(['parentSalesforceId'])?.value, - isConsortiumLead: this.editForm.get(['isConsortiumLead'])?.value, + id: this.editForm.get(['id'])?.value || null, + clientId: this.editForm.get(['clientId'])?.value || null, + clientName: this.editForm.get(['clientName'])?.value || null, + salesforceId: this.editForm.get(['salesforceId'])?.value || null, + parentSalesforceId: this.editForm.get(['parentSalesforceId'])?.value || null, + isConsortiumLead: this.editForm.get(['isConsortiumLead'])?.value || false, assertionServiceEnabled: this.editForm.get(['assertionServiceEnabled'])?.value ? true : false, createdBy: this.editForm.get(['createdBy'])?.value, createdDate: this.editForm.get(['createdDate'])?.value != null ? moment(this.editForm.get(['createdDate'])?.value, DATE_TIME_FORMAT) - : undefined, + : null, lastModifiedBy: this.editForm.get(['lastModifiedBy'])?.value, lastModifiedDate: this.editForm.get(['lastModifiedDate'])?.value != null ? moment(this.editForm.get(['lastModifiedDate'])?.value, DATE_TIME_FORMAT) - : undefined, + : null, } }