Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

myAchievements: resume generator (fixes #7441) #7445

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into 7441-resume-builder
  • Loading branch information
Mutugiii committed May 24, 2024
commit 009274fa2c3e99786d915f5c40829781e2bac58f
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<span i18n>Create Resumé</span>
</a>
<a mat-raised-button color="accent" routerLink="update" *ngIf="ownAchievements"><mat-icon>mode_edit</mat-icon>
<a mat-raised-button color="primary" style="margin-right: 1rem;" *ngIf="ownAchievements" (click)="generatePDF()">
<span i18n>Print Achievements</span>
</a> <br>
<a mat-raised-button color="accent" routerLink="update" *ngIf="ownAchievements">
<span *ngIf="achievementNotFound" i18n>Add Achievements</span>
<span *ngIf="!achievementNotFound" i18n>Edit Achievements</span>
</a>
Expand Down
78 changes: 78 additions & 0 deletions src/app/users/users-achievements/users-achievements.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,82 @@ export class UsersAchievementsComponent implements OnInit {

}

generatePDF() {
const formattedBirthDate = format(new Date(this.user.birthDate), 'MMM d, y, h:mm:ss a');
let contentArray = [
{
text: `${`${this.user.firstName}'s achievements`}`,
style: 'header',
alignment: 'center',
},
{
text: `
${this.user.firstName} ${this.user.middleName ? this.user.middleName : ''} ${this.user.lastName}
${this.user.birthDate ? `Birthdate: ${this.user.birthDate}` : ''}
${formattedBirthDate ? `Birthplace: ${formattedBirthDate}` : ''}
`,
alignment: 'center',
},
];

const optionals = [];
if (this.achievements.purpose) {
optionals.push(
{ text: 'My Purpose', style: 'subHeader', alignment: 'center' },
{ text: this.achievements.purpose, alignment: 'left', margin: [ 20, 5 ] }
);
}

if (this.achievements.goals) {
optionals.push(
{ text: 'My Goals', style: 'subHeader', alignment: 'center' },
{ text: this.achievements.goals, alignment: 'left', margin: [ 20, 5 ] }
);
}

if (this.achievements.achievements && this.achievements.achievements.length > 0) {
optionals.push(
{ text: 'My Achievements', style: 'subHeader', alignment: 'center' },
...this.achievements.achievements.map((achievement) => {
return [
{ text: achievement.title, bold: true, margin: [ 20, 5 ] },
{ text: achievement.description, marginLeft: 40 },
];
})
);
}

if (this.certifications && this.certifications.length > 0) {
optionals.push(
{ text: 'My Certifications', style: 'subHeader', alignment: 'center' },
...this.certifications.map((certification) => {
return [
{ text: certification.title, bold: true, margin: [ 20, 5 ] },
{ text: certification.description, marginLeft: 40 },
];
})
);
}

contentArray = contentArray.concat(optionals);

const documentDefinition = {
content: contentArray,
styles: {
header: {
fontSize: 18,
bold: true,
},
subHeader: {
fontSize: 16,
bold: true
}
},
};

pdfMake
.createPdf(documentDefinition)
.download(`${this.user.name} achievements.pdf`);
}

}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.