diff --git a/interfaces/AW-App/src/app/shared/numeric-input/numeric-input.component.html b/interfaces/AW-App/src/app/shared/numeric-input/numeric-input.component.html index a757f0cbe7..6971a54a7b 100644 --- a/interfaces/AW-App/src/app/shared/numeric-input/numeric-input.component.html +++ b/interfaces/AW-App/src/app/shared/numeric-input/numeric-input.component.html @@ -3,6 +3,8 @@ type="text" inputmode="numeric" pattern="[0-9]+" + [name]="name" + [(ngModel)]="ngModel" [value]="value" [autocomplete]="autocomplete" [disabled]="disabled" @@ -10,5 +12,5 @@ (ionInput)="onInput()" (ionChange)="onChange()" ngDefaultControl - required + [required]="required" > diff --git a/interfaces/AW-App/src/app/shared/numeric-input/numeric-input.component.ts b/interfaces/AW-App/src/app/shared/numeric-input/numeric-input.component.ts index 67bd26a358..03a71efff7 100644 --- a/interfaces/AW-App/src/app/shared/numeric-input/numeric-input.component.ts +++ b/interfaces/AW-App/src/app/shared/numeric-input/numeric-input.component.ts @@ -5,6 +5,7 @@ import { Output, ViewChild, } from '@angular/core'; +import { NgModel } from '@angular/forms'; @Component({ selector: 'numeric-input', @@ -15,9 +16,18 @@ export class NumericInputComponent { @ViewChild('numericInput') public numericInput: any; + @Input() + public name: string; + + @Input() + public ngModel: NgModel; + @Input() public value: string; + @Input() + public required: boolean; + @Input() public autocomplete: string; diff --git a/interfaces/AW-App/src/app/shared/phone-number-input/phone-number-input.component.html b/interfaces/AW-App/src/app/shared/phone-number-input/phone-number-input.component.html index dc9c53e020..ccb874e6d0 100644 --- a/interfaces/AW-App/src/app/shared/phone-number-input/phone-number-input.component.html +++ b/interfaces/AW-App/src/app/shared/phone-number-input/phone-number-input.component.html @@ -6,10 +6,12 @@ placeholder="+0 000 000 000" minlength="8" maxlength="17" + [name]="name" + [(ngModel)]="ngModel" [value]="value" [disabled]="disabled" (ionChange)="onChange()" debounce="500" ngDefaultControl - required + [required]="required" > diff --git a/interfaces/AW-App/src/app/shared/phone-number-input/phone-number-input.component.ts b/interfaces/AW-App/src/app/shared/phone-number-input/phone-number-input.component.ts index 68d4b96ffc..8d388f84f4 100644 --- a/interfaces/AW-App/src/app/shared/phone-number-input/phone-number-input.component.ts +++ b/interfaces/AW-App/src/app/shared/phone-number-input/phone-number-input.component.ts @@ -5,6 +5,7 @@ import { Output, ViewChild, } from '@angular/core'; +import { NgModel } from '@angular/forms'; import { TimeoutError } from 'rxjs'; import { ProgramsServiceApiService } from 'src/app/services/programs-service-api.service'; @@ -17,12 +18,21 @@ export class PhoneNumberInputComponent { @ViewChild('telInput') public telInput: any; + @Input() + public name: string; + + @Input() + public ngModel: NgModel; + @Input() public value: string; @Input() public disabled: boolean; + @Input() + public required: boolean; + @Input() public isValid: boolean; @Output() @@ -40,7 +50,6 @@ export class PhoneNumberInputComponent { } public async onChange() { - console.log('onChange: '); // 'export' the value of the input-ELEMENT to be used as value of this COMPONENT this.value = this.telInput.value; @@ -68,7 +77,7 @@ export class PhoneNumberInputComponent { isValid = typeof result.result !== 'undefined' ? result.result : false; }, (error) => { - // If aidworker is offline do not check phonenumber online + // If offline do not check phonenumber online if ( error.status === 0 || error.status === 504 || diff --git a/interfaces/AW-App/src/app/shared/q-and-a-set/q-and-a-set.component.html b/interfaces/AW-App/src/app/shared/q-and-a-set/q-and-a-set.component.html index c371706360..3babc0a936 100644 --- a/interfaces/AW-App/src/app/shared/q-and-a-set/q-and-a-set.component.html +++ b/interfaces/AW-App/src/app/shared/q-and-a-set/q-and-a-set.component.html @@ -1,121 +1,134 @@ -
+
- - - {{ question.label }} - -
-
- - + + {{ question.label }} +
+
+ - {{ option.label }} - - - -
-
- -
-
- -
-
- -
-
- + + {{ option.label }} + + + +
+
+ +
+
+ +
+
+ +
+
+ +
-
- - -
- -

- {{ 'q-and-a-set.validation.phone-number'|translate }} -

-

- {{ 'q-and-a-set.validation.number'|translate }} -

-

- {{ 'q-and-a-set.validation.date'|translate }} -

-

- {{ 'q-and-a-set.validation.required'|translate }} -

+
+ +

+ {{ 'q-and-a-set.validation.phone-number'|translate }} +

+

+ {{ 'q-and-a-set.validation.number'|translate }} +

+

+ {{ 'q-and-a-set.validation.date'|translate }} +

+

+ {{ 'q-and-a-set.validation.required'|translate }} +

+
+
-
+ +

+ {{ 'q-and-a-set.validation.generic-error'|translate }} +

+
- -

- {{ 'q-and-a-set.validation.generic-error'|translate }} -

-
+ + + + {{ submitLabel|translate }} + + + - - - - {{ submitLabel|translate }} - - - + diff --git a/interfaces/AW-App/src/app/shared/q-and-a-set/q-and-a-set.component.ts b/interfaces/AW-App/src/app/shared/q-and-a-set/q-and-a-set.component.ts index 071c6fd546..d18cb7e1a9 100644 --- a/interfaces/AW-App/src/app/shared/q-and-a-set/q-and-a-set.component.ts +++ b/interfaces/AW-App/src/app/shared/q-and-a-set/q-and-a-set.component.ts @@ -8,6 +8,7 @@ import { SimpleChanges, ViewChildren, } from '@angular/core'; +import { NgForm } from '@angular/forms'; import { Answer, AnswerSet, @@ -31,7 +32,6 @@ export class QAndASetComponent implements OnChanges { @Input() public answers: AnswerSet = {}; - public answerModels = {}; @Input() public isSubmitted = false; @@ -54,25 +54,26 @@ export class QAndASetComponent implements OnChanges { public answerType = AnswerType; + public theForm: NgForm; + public theFormModels = {}; + public validationErrors: string[] = []; constructor() {} ngOnChanges(changes: SimpleChanges) { + // Wait for questions to finish loading, to only THEN parse the provided ansers: if ( changes.questions && typeof changes.questions.currentValue !== 'undefined' ) { - this.fillAnswerModels(this.questions, this.answers); + this.fillAnswerModels(); } } - private fillAnswerModels(questions: Question[], answers: AnswerSet) { - questions.forEach((question) => { - if (!answers[question.code]) { - return; - } - this.answerModels[question.code] = answers[question.code].value; + private fillAnswerModels() { + Object.values(this.answers).forEach((item) => { + this.theFormModels[item.code] = item.value; }); } @@ -114,6 +115,10 @@ export class QAndASetComponent implements OnChanges { } public onAnswerChange(questionCode: string, answerValue: string) { + // Remove 'false positive' change-events on load/initiation of the component with data + if (!answerValue) { + return; + } const question = this.getQuestionByCode(questionCode); const answer = this.createAnswer(question, answerValue); @@ -147,11 +152,7 @@ export class QAndASetComponent implements OnChanges { } private checkAllQuestionsShown(questions: Question[], answers: string[]) { - if (!questions || !answers) { - return false; - } - - return answers.length >= questions.length - 1; + return answers.length === questions.length; } public onChangeWithValidation( diff --git a/interfaces/AW-App/src/app/validation-components/validate-program/validate-program.component.ts b/interfaces/AW-App/src/app/validation-components/validate-program/validate-program.component.ts index ce75beeab3..ea9af01443 100644 --- a/interfaces/AW-App/src/app/validation-components/validate-program/validate-program.component.ts +++ b/interfaces/AW-App/src/app/validation-components/validate-program/validate-program.component.ts @@ -59,7 +59,7 @@ export class ValidateProgramComponent implements ValidationComponent { this.programId = paData[0].programId; await this.getProgramQuestions(); - await this.initialAnswers(paData); + this.initialAnswers(paData); this.ionContent.scrollToBottom(300); } diff --git a/interfaces/PA-App/src/app/personal-components/enroll-in-program/enroll-in-program.component.html b/interfaces/PA-App/src/app/personal-components/enroll-in-program/enroll-in-program.component.html index ca7fe73080..8b8be93ea7 100644 --- a/interfaces/PA-App/src/app/personal-components/enroll-in-program/enroll-in-program.component.html +++ b/interfaces/PA-App/src/app/personal-components/enroll-in-program/enroll-in-program.component.html @@ -23,6 +23,7 @@ [answers]="answers" [(isSubmitted)]="hasAnswered" [(isEditing)]="hasChangedAnswers" + [allQuestionsShown]="allQuestionsShown" (submit)="submit($event)" submitLabel="personal.enroll-in-program.submit" > diff --git a/interfaces/PA-App/src/app/shared/numeric-input/numeric-input.component.html b/interfaces/PA-App/src/app/shared/numeric-input/numeric-input.component.html index a757f0cbe7..6971a54a7b 100644 --- a/interfaces/PA-App/src/app/shared/numeric-input/numeric-input.component.html +++ b/interfaces/PA-App/src/app/shared/numeric-input/numeric-input.component.html @@ -3,6 +3,8 @@ type="text" inputmode="numeric" pattern="[0-9]+" + [name]="name" + [(ngModel)]="ngModel" [value]="value" [autocomplete]="autocomplete" [disabled]="disabled" @@ -10,5 +12,5 @@ (ionInput)="onInput()" (ionChange)="onChange()" ngDefaultControl - required + [required]="required" > diff --git a/interfaces/PA-App/src/app/shared/numeric-input/numeric-input.component.ts b/interfaces/PA-App/src/app/shared/numeric-input/numeric-input.component.ts index 67bd26a358..03a71efff7 100644 --- a/interfaces/PA-App/src/app/shared/numeric-input/numeric-input.component.ts +++ b/interfaces/PA-App/src/app/shared/numeric-input/numeric-input.component.ts @@ -5,6 +5,7 @@ import { Output, ViewChild, } from '@angular/core'; +import { NgModel } from '@angular/forms'; @Component({ selector: 'numeric-input', @@ -15,9 +16,18 @@ export class NumericInputComponent { @ViewChild('numericInput') public numericInput: any; + @Input() + public name: string; + + @Input() + public ngModel: NgModel; + @Input() public value: string; + @Input() + public required: boolean; + @Input() public autocomplete: string; diff --git a/interfaces/PA-App/src/app/shared/phone-number-input/phone-number-input.component.html b/interfaces/PA-App/src/app/shared/phone-number-input/phone-number-input.component.html index dc9c53e020..13aa7420f9 100644 --- a/interfaces/PA-App/src/app/shared/phone-number-input/phone-number-input.component.html +++ b/interfaces/PA-App/src/app/shared/phone-number-input/phone-number-input.component.html @@ -6,10 +6,12 @@ placeholder="+0 000 000 000" minlength="8" maxlength="17" + [name]="name" [value]="value" + [(ngModel)]="ngModel" [disabled]="disabled" (ionChange)="onChange()" debounce="500" ngDefaultControl - required + [required]="required" > diff --git a/interfaces/PA-App/src/app/shared/phone-number-input/phone-number-input.component.ts b/interfaces/PA-App/src/app/shared/phone-number-input/phone-number-input.component.ts index 455ea64cd8..8d388f84f4 100644 --- a/interfaces/PA-App/src/app/shared/phone-number-input/phone-number-input.component.ts +++ b/interfaces/PA-App/src/app/shared/phone-number-input/phone-number-input.component.ts @@ -5,6 +5,7 @@ import { Output, ViewChild, } from '@angular/core'; +import { NgModel } from '@angular/forms'; import { TimeoutError } from 'rxjs'; import { ProgramsServiceApiService } from 'src/app/services/programs-service-api.service'; @@ -17,12 +18,21 @@ export class PhoneNumberInputComponent { @ViewChild('telInput') public telInput: any; + @Input() + public name: string; + + @Input() + public ngModel: NgModel; + @Input() public value: string; @Input() public disabled: boolean; + @Input() + public required: boolean; + @Input() public isValid: boolean; @Output() @@ -67,8 +77,12 @@ export class PhoneNumberInputComponent { isValid = typeof result.result !== 'undefined' ? result.result : false; }, (error) => { - // If aidworker is offline do not check phonenumber online - if (error.status === 0 || error instanceof TimeoutError) { + // If offline do not check phonenumber online + if ( + error.status === 0 || + error.status === 504 || + error instanceof TimeoutError + ) { isValid = true; } else { console.log('error: ', error.error); diff --git a/interfaces/PA-App/src/app/shared/q-and-a-set/q-and-a-set.component.html b/interfaces/PA-App/src/app/shared/q-and-a-set/q-and-a-set.component.html index 242d5a6a57..68fa8f7459 100644 --- a/interfaces/PA-App/src/app/shared/q-and-a-set/q-and-a-set.component.html +++ b/interfaces/PA-App/src/app/shared/q-and-a-set/q-and-a-set.component.html @@ -1,129 +1,140 @@ -
+
- - - {{ question.label }} - -
-
- - + + {{ question.label }} +
+
+ - {{ option.label }} - - - -
-
- -
-
- -
-
- -
-
- + + {{ option.label }} + + + +
+
+ +
+
+ +
+
+ +
+
+ +
-
- - -
- -

- - {{ 'q-and-a-set.validation.phone-number'|translate }} -

-

- - {{ 'q-and-a-set.validation.number'|translate }} -

-

- - {{ 'q-and-a-set.validation.date'|translate }} -

-

- - {{ 'q-and-a-set.validation.required'|translate }} -

+
+ +

+ + {{ 'q-and-a-set.validation.phone-number'|translate }} +

+

+ + {{ 'q-and-a-set.validation.number'|translate }} +

+

+ + {{ 'q-and-a-set.validation.date'|translate }} +

+

+ + {{ 'q-and-a-set.validation.required'|translate }} +

+
+
-
+ +

+ + {{ 'q-and-a-set.validation.generic-error'|translate }} +

+
- -

- - {{ 'q-and-a-set.validation.generic-error'|translate }} -

-
+ + + + + {{ submitLabel|translate }} + + + - - - - - {{ submitLabel|translate }} - - - + diff --git a/interfaces/PA-App/src/app/shared/q-and-a-set/q-and-a-set.component.ts b/interfaces/PA-App/src/app/shared/q-and-a-set/q-and-a-set.component.ts index 071c6fd546..d18cb7e1a9 100644 --- a/interfaces/PA-App/src/app/shared/q-and-a-set/q-and-a-set.component.ts +++ b/interfaces/PA-App/src/app/shared/q-and-a-set/q-and-a-set.component.ts @@ -8,6 +8,7 @@ import { SimpleChanges, ViewChildren, } from '@angular/core'; +import { NgForm } from '@angular/forms'; import { Answer, AnswerSet, @@ -31,7 +32,6 @@ export class QAndASetComponent implements OnChanges { @Input() public answers: AnswerSet = {}; - public answerModels = {}; @Input() public isSubmitted = false; @@ -54,25 +54,26 @@ export class QAndASetComponent implements OnChanges { public answerType = AnswerType; + public theForm: NgForm; + public theFormModels = {}; + public validationErrors: string[] = []; constructor() {} ngOnChanges(changes: SimpleChanges) { + // Wait for questions to finish loading, to only THEN parse the provided ansers: if ( changes.questions && typeof changes.questions.currentValue !== 'undefined' ) { - this.fillAnswerModels(this.questions, this.answers); + this.fillAnswerModels(); } } - private fillAnswerModels(questions: Question[], answers: AnswerSet) { - questions.forEach((question) => { - if (!answers[question.code]) { - return; - } - this.answerModels[question.code] = answers[question.code].value; + private fillAnswerModels() { + Object.values(this.answers).forEach((item) => { + this.theFormModels[item.code] = item.value; }); } @@ -114,6 +115,10 @@ export class QAndASetComponent implements OnChanges { } public onAnswerChange(questionCode: string, answerValue: string) { + // Remove 'false positive' change-events on load/initiation of the component with data + if (!answerValue) { + return; + } const question = this.getQuestionByCode(questionCode); const answer = this.createAnswer(question, answerValue); @@ -147,11 +152,7 @@ export class QAndASetComponent implements OnChanges { } private checkAllQuestionsShown(questions: Question[], answers: string[]) { - if (!questions || !answers) { - return false; - } - - return answers.length >= questions.length - 1; + return answers.length === questions.length; } public onChangeWithValidation(