-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ard-skill-section updated soft skills
- Loading branch information
Showing
6 changed files
with
70 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './render-elements.helpers'; |
2 changes: 1 addition & 1 deletion
2
...ill-section/hard-skill-section.helpers.ts → ...on-app/helpers/render-elements.helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/manfred2word/src/common-app/model/doc-parts.vm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 39 additions & 32 deletions
71
packages/manfred2word/src/engine/doc-parts/soft-skill-section/soft-skill-section.part.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters