From 7a09bbd2c58ee3d57b33a0f89d132066be9393f5 Mon Sep 17 00:00:00 2001
From: antoine37120 <ant.dupre@gmail.com>
Date: Thu, 11 Jan 2024 16:09:31 +0100
Subject: [PATCH] feature: add widget display user job on edit circle memebers

---
 src/styles/circles.scss           | 26 +++++++++++---
 src/widjets-display-user-tzcld.js | 57 +++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/src/styles/circles.scss b/src/styles/circles.scss
index 2c8ae66..b5a05aa 100644
--- a/src/styles/circles.scss
+++ b/src/styles/circles.scss
@@ -201,10 +201,26 @@
         }
     }
 }
-    #circles-chat #conversejs {
-        .chat-msg__content {
-            .badge {
-                display: none;
-            }
+#circles-chat #conversejs {
+    .chat-msg__content {
+        .badge {
+            display: none;
         }
     }
+}
+.user-first-job-circle {
+    h4 {
+        display: block;
+        margin: 0;
+        a.link {
+            vertical-align: baseline;
+        }
+    }
+    .tag {
+        font-size: 10px;
+        padding: 0 5px;
+        line-height: 14px;
+        height: auto;
+        margin-left: 0;
+    }
+}
diff --git a/src/widjets-display-user-tzcld.js b/src/widjets-display-user-tzcld.js
index f021831..b1f9a9c 100644
--- a/src/widjets-display-user-tzcld.js
+++ b/src/widjets-display-user-tzcld.js
@@ -355,5 +355,62 @@ import("./utils.js").then((utils) => {
           this.element.innerHTML = render;
           },
       });
+
+      
+      core.Sib.register({
+        name: "customtzcld-display-user-profile-first-job-circle",
+        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 userEntity = {
+            user: await this.resource.tzcld_profile
+        }
+        let tzcldUserProfile = {
+            profile: await userEntity.user.jobs,
+            regions: await userEntity.user.regions,
+        };
+
+        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-bottom-xxsmall user-first-job-circle whitespace-normal">`;
+        for(let job of tzcldUserProfile.profile["ldp:contains"]) {
+            if(await job.organisation !="") {
+                if(await job.link !="") {
+                    render +=  `<h4 class="position text-small text-normal padding-bottom-xxsmall">${await job.position} - <a class="link" target="_blank" href="${await job.link}">${await job.organisation}</a></h4>`;
+                } else {
+                    render +=  `<h4 class="position text-small text-normal padding-bottom-xxsmall">${await job.position} - ${await job.organisation}</h4>`;
+                }
+            } else {
+                render +=  `<h4 class="position text-small text-normal padding-bottom-xxsmall">${await job.position}</h4>`;
+            }
+            
+            break ;
+        }
+
+        for(let region of await tzcldUserProfile.regions["ldp:contains"]) {
+          render +=  `<div class="region segment tag color-fourth">${await region.name}</div>`;
+        }
+        
+        render +=  `</div>`;
+        
+        this.element.innerHTML = render;
+        },
+      });
+
     });
 });
\ No newline at end of file
-- 
GitLab