Commit aa473e22 by Muhammad Usman

intro letter downlaod added, selected template shown

parent 09826c32
<h4 class="tab-heading">Select the design template for your Career Profile</h4> <div class="position-relative">
<app-overlay [isActive]="isLoading"></app-overlay>
<!--<p-carousel>--> <h4 class="tab-heading" *ngIf="!careerProfile?.Template">Select the design template for your Career Profile</h4>
<!-- -->
<!--</p-carousel>--> <div class="selected-template" *ngIf="careerProfile?.Template">
<img [src]="apiBase + careerProfile.Template.FullImageURI" alt="">
</div>
<div class="text-center mt-3"> <div class="text-center mt-3">
<button pButton label="Please choose a profile template" class="ui-button-info rounded-btn" <button pButton [label]="careerProfile?.Template ? 'Choose another template' : 'Please choose a profile template'" class="ui-button-info rounded-btn"
(click)="showTemplates()"></button> (click)="showTemplates()"></button>
</div>
</div> </div>
......
...@@ -43,6 +43,7 @@ export class TemplatesComponent extends BaseComponent implements OnInit { ...@@ -43,6 +43,7 @@ export class TemplatesComponent extends BaseComponent implements OnInit {
.subscribe(response => { .subscribe(response => {
this.isLoading = false; this.isLoading = false;
this.careerProfile = response; this.careerProfile = response;
this.updatedObjs[this.careerProfile.ObjectID] = this.careerProfile;
if (this.careerProfile.Candidate.AllTempletes) { if (this.careerProfile.Candidate.AllTempletes) {
this.careerProfile.Candidate.AllTempletes.map(t => { this.careerProfile.Candidate.AllTempletes.map(t => {
t.CanUse = t.Availability === this.tempalteStatus.INCLUDED_IN_FREE t.CanUse = t.Availability === this.tempalteStatus.INCLUDED_IN_FREE
...@@ -50,8 +51,8 @@ export class TemplatesComponent extends BaseComponent implements OnInit { ...@@ -50,8 +51,8 @@ export class TemplatesComponent extends BaseComponent implements OnInit {
t.ImgPath = this.apiBase + t.FullImageURI t.ImgPath = this.apiBase + t.FullImageURI
}); });
this.careerProfile.Candidate.AllTempletes.sort((t1, t2) => t1.SortOrder - t2.SortOrder); this.careerProfile.Candidate.AllTempletes.sort((t1, t2) => t1.SortOrder - t2.SortOrder);
this.utilsService.addObjsToJSONByObjectID(this.updatedObjs, this.careerProfile.Candidate.CandidateTemplates)
} }
console.log(this.careerProfile);
}, err => { }, err => {
this.isLoading = false; this.isLoading = false;
this.utilsService.handleError(err); this.utilsService.handleError(err);
...@@ -59,12 +60,8 @@ export class TemplatesComponent extends BaseComponent implements OnInit { ...@@ -59,12 +60,8 @@ export class TemplatesComponent extends BaseComponent implements OnInit {
} }
selectTemplate(template): void { selectTemplate(template): void {
const templateModel = new CandidateTemplateModel(); this.careerProfile.Template = template;
templateModel.Candidate = this.careerProfile.Candidate.ObjectID; this.saveService.saveObjectsWithDefaultSvc(this.createdObjs, this.updatedObjs, this.deletedObjs)
templateModel.Template = template.Value;
this.utilsService.createObject(templateModel, this.createdObjs);
this.saveService.saveObjectsWithDefaultSvc(this.createdObjs, this.updatedObjs, this.updatedObjs)
.pipe(takeUntil(this.componentInView)) .pipe(takeUntil(this.componentInView))
.subscribe(response => { .subscribe(response => {
console.log(response); console.log(response);
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
<div class="row mt-5"> <div class="row mt-5">
<div class="col-md-6"> <div class="col-md-6">
<button pButton style="min-width: 180px;" label="Download" class="mc-btn-secondary"></button> <button pButton style="min-width: 180px;" label="Download" class="mc-btn-secondary" (click)="getIntroLetter(true)" *ngIf="isEditMode"></button>
</div> </div>
<div class="col-md-6 d-flex justify-content-end"> <div class="col-md-6 d-flex justify-content-end">
<button (click)="saveIntroLetter()" pButton label="Update" class="mc-btn-primary"></button> <button (click)="saveIntroLetter()" pButton label="Update" class="mc-btn-primary"></button>
......
...@@ -12,6 +12,8 @@ import { HelperService } from '../../services/helper.service'; ...@@ -12,6 +12,8 @@ import { HelperService } from '../../services/helper.service';
import { ILWorkExperienceModel } from '../../models/il-work-experience.model'; import { ILWorkExperienceModel } from '../../models/il-work-experience.model';
import { ILSkillModel } from '../../models/il-skill.model'; import { ILSkillModel } from '../../models/il-skill.model';
import * as FileSaver from 'file-saver';
@Component({ @Component({
selector: 'app-intro-letter', selector: 'app-intro-letter',
templateUrl: './intro-letter.component.html', templateUrl: './intro-letter.component.html',
...@@ -70,14 +72,19 @@ export class IntroLetterComponent extends BaseComponent implements OnInit { ...@@ -70,14 +72,19 @@ export class IntroLetterComponent extends BaseComponent implements OnInit {
}) })
} }
getIntroLetter(): void { getIntroLetter(download = false): void {
this.isLoading = true; this.isLoading = true;
this.introLetterService.getIntroLetter(this.introLetterId, ['WorkExperiences.WorkExperience', 'Skills.Skill']) const sub = download ? this.introLetterService.downloadIntroLetter(this.introLetterId) : this.introLetterService.getIntroLetter(this.introLetterId, ['WorkExperiences.WorkExperience', 'Skills.Skill']);
sub
.pipe(takeUntil(this.componentInView)) .pipe(takeUntil(this.componentInView))
.subscribe(response => { .subscribe(response => {
this.isLoading = false; this.isLoading = false;
this.introductionLetter = response; if (download) {
this.updatedObjs[this.introductionLetter.ObjectID] = this.introductionLetter; FileSaver.saveAs(response.content, `intro-letter-${this.introductionLetter.ObjectID}.pdf`);
} else {
this.introductionLetter = response;
this.updatedObjs[this.introductionLetter.ObjectID] = this.introductionLetter;
}
}, err => { }, err => {
this.utilsService.handleError(err); this.utilsService.handleError(err);
this.isLoading = false; this.isLoading = false;
......
...@@ -35,4 +35,5 @@ export class CareerProfileModel extends BaseModel { ...@@ -35,4 +35,5 @@ export class CareerProfileModel extends BaseModel {
TEMPLATES: boolean; TEMPLATES: boolean;
WORK_HISTORY: boolean; WORK_HISTORY: boolean;
}; };
Template: any;
} }
...@@ -35,6 +35,15 @@ export class IntroLetterService { ...@@ -35,6 +35,15 @@ export class IntroLetterService {
) )
} }
downloadIntroLetter(id): Observable<any> {
return this.searchService.downloadDocument(SERVICES.INTRODUCTION_LETTERS, id, 'IntroductionLetterPDF', null)
.map(
data => {
return data;
}
)
}
saveIntroLetters(createdObjs, updatedObjs, deleteObjs): Observable<any> { saveIntroLetters(createdObjs, updatedObjs, deleteObjs): Observable<any> {
return this.saveService.saveObjectsWithDefaultSvc(createdObjs, updatedObjs, deleteObjs); return this.saveService.saveObjectsWithDefaultSvc(createdObjs, updatedObjs, deleteObjs);
} }
......
...@@ -126,4 +126,4 @@ export class SearchService { ...@@ -126,4 +126,4 @@ export class SearchService {
} }
); );
} }
} }
\ No newline at end of file
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