Commit 12a9a8de by Muhammad Usman

work preferences completed

parent 14d4a4de
...@@ -33,14 +33,8 @@ ...@@ -33,14 +33,8 @@
<div class="question-completed">{{workPreferenceQuestion?.Percentage}}%</div> <div class="question-completed">{{workPreferenceQuestion?.Percentage}}%</div>
<div class="answer-options"> <div class="answer-options">
<div class="answer-option"> <div class="answer-option" *ngFor="let question of workPreferenceQuestion?.CultureElement?.Questions" (click)="submitAnswer(question)">
<p-radioButton label="I am a very practical person"></p-radioButton> <p-radioButton [label]="question.Description" name="ANSWER" [value]="question.ObjectID"></p-radioButton>
</div>
<div class="answer-option">
<p-radioButton label="I am a somewhat practical person"></p-radioButton>
</div>
<div class="answer-option">
<p-radioButton label="I am not generally idealistic"></p-radioButton>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -6,6 +6,7 @@ import { takeUntil } from 'rxjs/operators'; ...@@ -6,6 +6,7 @@ import { takeUntil } from 'rxjs/operators';
import { AssessmentService } from '../../services/assessment.service'; import { AssessmentService } from '../../services/assessment.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { HelperService } from '../../services/helper.service'; import { HelperService } from '../../services/helper.service';
import { QuestionModel } from '../../models/question.model';
@Component({ @Component({
selector: 'app-work-preference', selector: 'app-work-preference',
...@@ -16,8 +17,7 @@ import { HelperService } from '../../services/helper.service'; ...@@ -16,8 +17,7 @@ import { HelperService } from '../../services/helper.service';
export class WorkPreferenceComponent extends BaseComponent implements OnInit, OnDestroy { export class WorkPreferenceComponent extends BaseComponent implements OnInit, OnDestroy {
workPreferenceQuestion = new WorkPreferenceQuestionModel(); workPreferenceQuestion = new WorkPreferenceQuestionModel();
assocs = ['CultureElement']; assocs = ['CultureElement', 'CultureElement.Questions'];
answerScales = [];
autoSaveInterval; autoSaveInterval;
autoSavedOn; autoSavedOn;
autoSaveLabel = ''; autoSaveLabel = '';
...@@ -40,11 +40,12 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On ...@@ -40,11 +40,12 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On
this.as.getWorkPreferences(this.assocs) this.as.getWorkPreferences(this.assocs)
.pipe(takeUntil(this.componentInView)) .pipe(takeUntil(this.componentInView))
.subscribe(response => { .subscribe(response => {
console.log(response);
this.isLoading = false; this.isLoading = false;
this.autoSavedOn = new Date(); this.autoSavedOn = new Date();
if (response.length > 0) { if (response.length > 0) {
this.workPreferenceQuestion = response[0]; this.workPreferenceQuestion = response[0];
} else {
this.exit();
} }
}, err => { }, err => {
this.isLoading = false; this.isLoading = false;
...@@ -68,6 +69,29 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On ...@@ -68,6 +69,29 @@ export class WorkPreferenceComponent extends BaseComponent implements OnInit, On
this.r.navigate(['/my-career-web/dashboard/home']); this.r.navigate(['/my-career-web/dashboard/home']);
} }
submitAnswer(question: QuestionModel): void {
const formData = {
CultureElement: this.workPreferenceQuestion.CultureElement.ObjectID,
SelectedQuestion: question.ObjectID,
Continue: true
};
this.isLoading = true;
this.as.saveWorkPreferences(formData)
.subscribe(response => {
this.isLoading = false;
this.autoSavedOn = new Date();
this.autoSave();
if (response.NextQuestion) {
this.initiateWorkPreference();
} else {
this.exit();
}
}, err => {
this.isLoading = false;
this.hs.handleHttpError(err);
});
}
ngOnDestroy(): void { ngOnDestroy(): void {
super.ngOnDestroy(); super.ngOnDestroy();
if (this.autoSaveInterval) { if (this.autoSaveInterval) {
......
export class CultureElementModel { import { QuestionModel } from './question.model';
import { BaseModel } from './base.model';
export class CultureElementModel extends BaseModel {
Description?: string; Description?: string;
DetailedDescription?: string; DetailedDescription?: string;
CultureClass?: string; CultureClass?: string;
Questions: QuestionModel[];
} }
...@@ -33,5 +33,9 @@ export class AssessmentService { ...@@ -33,5 +33,9 @@ export class AssessmentService {
return this.us.processObjects('SaveWorkStyle', params); return this.us.processObjects('SaveWorkStyle', params);
} }
saveWorkPreferences(params): Observable<any> {
return this.us.processObjects('SaveWorkPreferences', params);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment