From 7273f3f1f87bf434ebc29cd8651a88f63643ce9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Dupr=C3=A9?= <ant.dupre@gmail.com> Date: Thu, 1 Jun 2023 16:46:33 +0200 Subject: [PATCH] feature: add user profil first job short widget --- src/widjets-display-user-tzcld.js | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/widjets-display-user-tzcld.js b/src/widjets-display-user-tzcld.js index 43f1651..29b4786 100644 --- a/src/widjets-display-user-tzcld.js +++ b/src/widjets-display-user-tzcld.js @@ -215,6 +215,51 @@ import("./utils.js").then((utils) => { render += `</div>`; + this.element.innerHTML = render; + }, + }); + core.Sib.register({ + name: "customtzcld-display-user-profile-first-job-short", + use: [core.StoreMixin], + + empty() { + console.debug(); + this.element.innerHTML = ""; + }, + + async populate() { + this.element.innerHTML = ` + <div class="loader"> + <div></div> + <div></div> + <div></div> + <div></div> + </div>`; + let tzcldprofile = { + jobs: await this.resource["ldp:contains"] + }; + if("label" in this.element.attributes) { + for(let ignore of this.element.attributes['label'].value.split(',')) { + tzcldprofile[ignore.trim()] = null; + } + } + let render = `<div class="segment full margin-top-xxsmall margin-bottom-xxsmall user-first-job whitespace-normal">`; + for(let job of tzcldprofile.jobs) { + if(await job.organisation !="") { + if(await job.link !="") { + render += `<h4 class="position text-medium padding-bottom-large">${await job.position} - <a class="link text-top" target="_blank" href="${await job.link}">${await job.organisation}</a></h4>`; + } else { + render += `<h4 class="position text-medium padding-bottom-large">${await job.position} - ${await job.organisation}</h4>`; + } + } else { + render += `<h4 class="position text-medium padding-bottom-large">${await job.position}</h4>`; + } + + break ; + } + + render += `</div>`; + this.element.innerHTML = render; }, }); -- GitLab