Skip to content

Commit

Permalink
display any lang stored in profile SolidOS#12
Browse files Browse the repository at this point in the history
  • Loading branch information
timea-solid committed Sep 14, 2021
1 parent 8b9cb83 commit 678ce26
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
21 changes: 19 additions & 2 deletions src/CVCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const styles = {
};

export const CVCard = (profileBasics: ProfilePresentation, cvData: CVPresentation): TemplateResult => {
const { rolesByType, skills } = cvData
const { rolesByType, skills, languages } = cvData
const nameStyle = styleMap({
...heading(),
// "text-decoration": "underline",
Expand All @@ -42,7 +42,9 @@ export const CVCard = (profileBasics: ProfilePresentation, cvData: CVPresentatio
<div style=${styles.info}>
${renderSkills(skills)}
</div>
<div style=${styles.info}>
${renderLanguages(languages)}
</div>
</div>
`;
};
Expand Down Expand Up @@ -75,3 +77,18 @@ function renderSkills (skills) {
${skills.length > 1 ? renderSkills(skills.slice(1)) : html``}
`
}

function renderLan (language) {
return language ? html`<div style="margin: 0.5em;">
<p style="text-align: center;">${language}</p>
</div>
` : html``;
}

function renderLanguages (languages) {

return html`${renderLan(languages[0])}
${languages.length > 1 ? renderLanguages(languages.slice(1)) : html``}
`
}

17 changes: 16 additions & 1 deletion src/CVPresenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface Role {
export interface CVPresentation {
rolesByType: RolesByType;
skills: string[];
languages: string[];
}

export interface RolesByType {
Expand All @@ -36,6 +37,16 @@ export function skillAsText (store: Store, sk: Node):string {
return '¿¿¿ skill ???'
}

export function languageAsText (store: Store, lan: Node):string {
if (lan.termType === 'Literal') return lan.value // Not normal but allow this
const publicId = store.anyJS(lan as NamedNode, ns.solid('publicId'))
if (publicId) {
const name = store.anyJS(publicId, ns.schema('name'));
if (name) return name // @@ check language and get name in diff language if necessary
}
return '_'
}

export function datesAsText (startDate?:Literal, endDate?:Literal):string {
return startDate ? '(' + startDate.value.slice(0,4) + '-' +
( endDate ? endDate.value.slice(0,4) : '') +')'
Expand Down Expand Up @@ -107,5 +118,9 @@ export function presentCV(

const skills = store.each(subject, ns.schema('skills')).map(sk => skillAsText(store, sk))

return { rolesByType, skills }
const languagesInStore = store.anyJS(subject, ns.schema('knowsLanguage'))
let languages = []
if (languagesInStore) languages = languagesInStore.map(lan => languageAsText(store, lan))

return { rolesByType, skills, languages }
}
6 changes: 6 additions & 0 deletions src/integration-tests/cv.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ describe("profile-pane", () => {
it("renders error flag when missing skill text CV", () => {
expect(element).toContainHTML("¿¿¿ skill ???");
});
it("renders languages", () => {
expect(element).toContainHTML("French");
});

it("renders languages", () => {
expect(element).toContainHTML("germano");
});
});

});

0 comments on commit 678ce26

Please sign in to comment.