diff --git a/project/ws/app/src/lib/routes/state-profile/routes/consultancy/consultancy.component.ts b/project/ws/app/src/lib/routes/state-profile/routes/consultancy/consultancy.component.ts index 7f1d891fa..5ed9b9106 100644 --- a/project/ws/app/src/lib/routes/state-profile/routes/consultancy/consultancy.component.ts +++ b/project/ws/app/src/lib/routes/state-profile/routes/consultancy/consultancy.component.ts @@ -26,6 +26,7 @@ export class ConsultancyComponent implements OnInit { deleteBodyRef: ElementRef | null = null editValue: any textBoxActive = false + isConsultancy = false constructor( private orgSvc: OrgProfileService, @@ -46,15 +47,28 @@ export class ConsultancyComponent implements OnInit { // If projects are added then only validation is required, so by default validation is true, so that user can go to next tab this.orgSvc.updateFormStatus('consultancy', true) + } + + ngOnInit() { // pre poluate form fields when data is available (edit mode) if (this.configSvc.unMappedUser && this.configSvc.unMappedUser.orgProfile) { const consultancyData = _.get(this.configSvc.unMappedUser.orgProfile, 'profileDetails.consultancy') this.addedconsultancies = _.get(consultancyData, 'projects') || [] this.orgSvc.updateFormStatus('consultancy', true) } - } - ngOnInit() { + // if Roles and functions tab has "Research" checked then check for atleast 1 prject + let rolesAndFunctions: any + if (JSON.stringify(this.orgSvc.formValues.rolesAndFunctions) === '{}') { + rolesAndFunctions = _.get(this.configSvc.unMappedUser.orgProfile, 'profileDetails.rolesAndFunctions') + } else { + rolesAndFunctions = _.get(this.orgSvc.formValues, 'rolesAndFunctions') + } + if (rolesAndFunctions.consultancy) { + this.isConsultancy = true + // this.removeValidators() + this.orgSvc.updateFormStatus('consultancy', (this.addedconsultancies.length > 0)) + } } addProject() { @@ -141,7 +155,12 @@ export class ConsultancyComponent implements OnInit { } this.orgSvc.updateLocalFormValue('consultancy', localData) // this.orgSvc.updateFormStatus('consultancy', (this.addedconsultancies.length > 0)) - this.orgSvc.updateFormStatus('consultancy', true) + if (this.isConsultancy) { + // tslint:disable-next-line: max-line-length + this.orgSvc.updateFormStatus('consultancy', (this.addedconsultancies.length > 0)) + } else { + this.orgSvc.updateFormStatus('consultancy', true) + } } resetConsultancyForm() { diff --git a/project/ws/app/src/lib/routes/state-profile/routes/research/research.component.ts b/project/ws/app/src/lib/routes/state-profile/routes/research/research.component.ts index 5ba490f4a..9909cc61f 100644 --- a/project/ws/app/src/lib/routes/state-profile/routes/research/research.component.ts +++ b/project/ws/app/src/lib/routes/state-profile/routes/research/research.component.ts @@ -34,6 +34,7 @@ export class ResearchComponent implements OnInit { editPaperValue: any textBoxActive = false textBoxActive1 = false + isResearch = false constructor( private orgSvc: OrgProfileService, @@ -58,6 +59,9 @@ export class ResearchComponent implements OnInit { // setting this to true so that form validation is not required based on number added projects or papers this.orgSvc.updateFormStatus('research', true) + } + + ngOnInit() { // pre poluate form fields when data is available (edit mode) if (this.configSvc.unMappedUser && this.configSvc.unMappedUser.orgProfile) { const researchData = _.get(this.configSvc.unMappedUser.orgProfile, 'profileDetails.research') @@ -67,9 +71,19 @@ export class ResearchComponent implements OnInit { // this.orgSvc.updateFormStatus('research', (this.addedPapers.length > 0 && this.addedPrograms.length > 0)) this.orgSvc.updateFormStatus('research', true) } - } - ngOnInit() { + // if Roles and functions tab has "Research" checked then check for atleast 1 prject + let rolesAndFunctions: any + if (JSON.stringify(this.orgSvc.formValues.rolesAndFunctions) === '{}') { + rolesAndFunctions = _.get(this.configSvc.unMappedUser.orgProfile, 'profileDetails.rolesAndFunctions') + } else { + rolesAndFunctions = _.get(this.orgSvc.formValues, 'rolesAndFunctions') + } + if (rolesAndFunctions.research) { + this.isResearch = true + // this.removeValidators() + this.orgSvc.updateFormStatus('research', (this.addedPrograms.length > 0)) + } } addProgram() { @@ -234,7 +248,13 @@ export class ResearchComponent implements OnInit { researchPapers: this.addedPapers, } this.orgSvc.updateLocalFormValue('research', localData) - this.orgSvc.updateFormStatus('research', true) + if (this.isResearch) { + // tslint:disable-next-line: max-line-length + this.orgSvc.updateFormStatus('research', (this.addedPrograms.length > 0)) + } else { + this.orgSvc.updateFormStatus('research', true) + } + // this.orgSvc.updateFormStatus('research', (this.addedPapers.length > 0 && this.addedPrograms.length > 0)) } diff --git a/project/ws/app/src/lib/routes/state-profile/routes/training-rograms/training-rograms.component.html b/project/ws/app/src/lib/routes/state-profile/routes/training-rograms/training-rograms.component.html index 6ea7535dc..a1fd418c0 100644 --- a/project/ws/app/src/lib/routes/state-profile/routes/training-rograms/training-rograms.component.html +++ b/project/ws/app/src/lib/routes/state-profile/routes/training-rograms/training-rograms.component.html @@ -13,9 +13,9 @@