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

updated soft skills #121

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions packages/manfred2word/src/common-app/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './render-elements.helpers';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IParagraphOptions, IRunOptions, Paragraph, Table, TableCell, TableRow, TextRun, XmlComponent } from 'docx';
import { TableStyles } from '../doc-parts.vm';
import { TableStyles } from '../model/doc-parts.vm';

export const renderTable = (rows: TableRow[], styles?: TableStyles): XmlComponent =>
new Table({
Expand Down
24 changes: 24 additions & 0 deletions packages/manfred2word/src/common-app/model/doc-parts.vm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
IImageOptions,
IParagraphPropertiesOptions,
IRunOptions,
ISectionOptions,
ITableCellOptions,
ITableOptions,
ITableRowOptions,
} from 'docx';
import { IPropertiesOptions } from 'docx/build/file/core-properties';

export type SectionStyles = Omit<ISectionOptions, 'children'>;
export type DocumentStyle = Omit<IPropertiesOptions, 'sections'>;
export type TableStyles = Omit<ITableOptions, 'rows'>;
export type TableCellStyles = Omit<ITableCellOptions, 'children'>;
export type TableRowStyles = Omit<ITableRowOptions, 'children'>;
export type TextRunStyles = Omit<IRunOptions, 'text'>;
export type ParagraphStyles = IParagraphPropertiesOptions;
export type ImageStyles = Omit<IImageOptions, 'data'>;

export interface RowProperties {
rowStyles?: TableRowStyles;
cellStyles?: TableCellStyles;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { ManfredAwesomicCV } from '@/model';
import { HardSkillVM } from './hard-skill-section.vm';
import { mapFromCvToHardSkillVm } from './hard-skill-section.mapper';
import {
renderParagraph,
renderTable,
renderTableRow,
renderTableCell,
renderParagraph,
renderTableRow,
renderTextRun,
} from './hard-skill-section.helpers';
} from '@/common-app/helpers/render-elements.helpers';
import { sectionTitle } from './hard-skill-constants';
import { styles } from './hard-skill-section.styles';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
import { ManfredAwesomicCV } from '@/model';
import { TableCell, TableRow, Table } from 'docx';
import { titleSoftSkillSection, sectionSoftSkillSection } from './sections-soft-skill-section.parts';
import {
renderParagraph,
renderTable,
renderTableCell,
renderTableRow,
renderTextRun,
} from '@/common-app/helpers/render-elements.helpers';
import { TableRow, Table, XmlComponent } from 'docx';
import { SoftSkillVM } from './soft-skill-section.vm';
import { styles } from './soft-skill-section.styles';
import { mapFromCvToSoftSkillVm } from './soft-skill-section.mapper';
import { sectionTitle } from './soft-skill.constants';

export const generateSoftSkillSection = (cv: ManfredAwesomicCV): Table => {
const profileSectionVm = mapFromCvToSoftSkillVm(cv);
const getSkillNameList = (skillList: SoftSkillVM[]): string[] =>
skillList.map(item => (item.skill?.name ? item.skill?.name : ''));

const createSkillListWithSeparator = (skillList: string[]): XmlComponent[] =>
skillList.map((item, index) => (index === skillList.length - 1 ? renderTextRun(item) : renderTextRun(`${item} / `)));

const createSkillsTableRow = (skillList: SoftSkillVM[]): TableRow => {
const list = getSkillNameList(skillList);
const skillListWithSeparator = createSkillListWithSeparator(list);
const paragraph = renderParagraph(skillListWithSeparator, { spacing: { before: 200 } });
const cell = renderTableCell([paragraph]);
const row = renderTableRow([cell]);

return generateSoftSkillSectionInner(profileSectionVm);
return row;
};

export const generateSoftSkillSectionInner = (softSkillSctionVm: SoftSkillVM[]): Table =>
new Table({
...styles.table,
rows: [generateTitleSoftSkill(), ...generateSectionSoftSkillFromVmToRows(softSkillSctionVm)],
});

const generateTitleSoftSkill = (): TableRow =>
new TableRow({
children: [
new TableCell({
children: [titleSoftSkillSection()],
}),
],
});

const generateSectionSoftSkillFromVmToRows = (softSkillSectionVm: SoftSkillVM[]): TableRow[] =>
Boolean(softSkillSectionVm) ? softSkillSectionVm.map(softSkillVm => softSkillsSection(softSkillVm)) : [];

const softSkillsSection = (sectionSoftSkillVm: SoftSkillVM): TableRow =>
new TableRow({
children: [
new TableCell({
...styles.table,
children: sectionSoftSkillSection(sectionSoftSkillVm),
}),
],
});
const createTitleTableRow = (text: string): TableRow => {
const title = renderTextRun(text, { size: '18pt', bold: true });
const paragraph = renderParagraph([title], { spacing: { before: 200 } });
const cell = renderTableCell([paragraph]);
const row = renderTableRow([cell]);

return row;
};

export const generateSoftSkillSection = (cv: ManfredAwesomicCV): Table => {
const hardSkillList = mapFromCvToSoftSkillVm(cv);
const title = createTitleTableRow(sectionTitle);
const hardSkillItems = createSkillsTableRow(hardSkillList);
const table = renderTable([title, hardSkillItems], styles.table);

return table;
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export const levelSkillList: SkillType[] = [
{ level: 'high', spanish: 'Alto' },
{ level: 'expert', spanish: 'Experto' },
];

export const sectionTitle = 'Soft Skills';