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>-->
<!-- -->
<!--</p-carousel>-->
<h4 class="tab-heading" *ngIf="!careerProfile?.Template">Select the design template for your Career Profile</h4>
<div class="selected-template" *ngIf="careerProfile?.Template">
<img [src]="apiBase + careerProfile.Template.FullImageURI" alt="">
</div>
<div class="text-center mt-3">
<button pButton label="Please choose a profile template" class="ui-button-info rounded-btn"
(click)="showTemplates()"></button>
<div class="text-center mt-3">
<button pButton [label]="careerProfile?.Template ? 'Choose another template' : 'Please choose a profile template'" class="ui-button-info rounded-btn"
(click)="showTemplates()"></button>
</div>
</div>
......
......@@ -43,6 +43,7 @@ export class TemplatesComponent extends BaseComponent implements OnInit {
.subscribe(response => {
this.isLoading = false;
this.careerProfile = response;
this.updatedObjs[this.careerProfile.ObjectID] = this.careerProfile;
if (this.careerProfile.Candidate.AllTempletes) {
this.careerProfile.Candidate.AllTempletes.map(t => {
t.CanUse = t.Availability === this.tempalteStatus.INCLUDED_IN_FREE
......@@ -50,8 +51,8 @@ export class TemplatesComponent extends BaseComponent implements OnInit {
t.ImgPath = this.apiBase + t.FullImageURI
});
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 => {
this.isLoading = false;
this.utilsService.handleError(err);
......@@ -59,12 +60,8 @@ export class TemplatesComponent extends BaseComponent implements OnInit {
}
selectTemplate(template): void {
const templateModel = new CandidateTemplateModel();
templateModel.Candidate = this.careerProfile.Candidate.ObjectID;
templateModel.Template = template.Value;
this.utilsService.createObject(templateModel, this.createdObjs);
this.saveService.saveObjectsWithDefaultSvc(this.createdObjs, this.updatedObjs, this.updatedObjs)
this.careerProfile.Template = template;
this.saveService.saveObjectsWithDefaultSvc(this.createdObjs, this.updatedObjs, this.deletedObjs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
console.log(response);
......
......@@ -78,7 +78,7 @@
<div class="row mt-5">
<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 class="col-md-6 d-flex justify-content-end">
<button (click)="saveIntroLetter()" pButton label="Update" class="mc-btn-primary"></button>
......
......@@ -12,6 +12,8 @@ import { HelperService } from '../../services/helper.service';
import { ILWorkExperienceModel } from '../../models/il-work-experience.model';
import { ILSkillModel } from '../../models/il-skill.model';
import * as FileSaver from 'file-saver';
@Component({
selector: 'app-intro-letter',
templateUrl: './intro-letter.component.html',
......@@ -70,14 +72,19 @@ export class IntroLetterComponent extends BaseComponent implements OnInit {
})
}
getIntroLetter(): void {
getIntroLetter(download = false): void {
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))
.subscribe(response => {
this.isLoading = false;
this.introductionLetter = response;
this.updatedObjs[this.introductionLetter.ObjectID] = this.introductionLetter;
if (download) {
FileSaver.saveAs(response.content, `intro-letter-${this.introductionLetter.ObjectID}.pdf`);
} else {
this.introductionLetter = response;
this.updatedObjs[this.introductionLetter.ObjectID] = this.introductionLetter;
}
}, err => {
this.utilsService.handleError(err);
this.isLoading = false;
......
......@@ -35,4 +35,5 @@ export class CareerProfileModel extends BaseModel {
TEMPLATES: boolean;
WORK_HISTORY: boolean;
};
Template: any;
}
......@@ -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> {
return this.saveService.saveObjectsWithDefaultSvc(createdObjs, updatedObjs, deleteObjs);
}
......
......@@ -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