From 1e05637b699fad5ecb4c4e27c081f2b630a2a3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Dupr=C3=A9?= <ant.dupre@gmail.com> Date: Thu, 15 Jun 2023 10:45:32 +0200 Subject: [PATCH] feature: add display for points parts --- src/widjets-display-evaluation-tzcld.js | 136 ++++++++++++++++++++++-- 1 file changed, 130 insertions(+), 6 deletions(-) diff --git a/src/widjets-display-evaluation-tzcld.js b/src/widjets-display-evaluation-tzcld.js index 37b922c..349bbf4 100644 --- a/src/widjets-display-evaluation-tzcld.js +++ b/src/widjets-display-evaluation-tzcld.js @@ -76,6 +76,88 @@ import("./utils.js").then((utils) => { } } ); + + + core.Sib.register({ + name: "tzcld-autoeval-points", + 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 = { + community: await this.resource, + name: await this.resource.name, + }; + console.log(this.element.getAttribute('parts') ); + console.log(await tzcldprofile.community) ; + + if("label" in this.element.attributes) { + for(let ignore of this.element.attributes['label'].value.split(',')) { + tzcldprofile[ignore.trim()] = null; + } + } + let render = ` + + <solid-display solid-resource bind-resources fields="name reponse" data-src="${this.element.getAttribute('data-src')}" widget-name="div" + + ></solid-display>`; + + this.element.innerHTML = render; + } + }); + + core.Sib.register({ + name: "tzcld-autoeval", + 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 = { + community: await this.resource, + name: await this.resource.name, + }; + console.log(this.element.getAttribute('parts') ); + console.log(await tzcldprofile.community) ; + + if("label" in this.element.attributes) { + for(let ignore of this.element.attributes['label'].value.split(',')) { + tzcldprofile[ignore.trim()] = null; + } + } + let render = `<div>${await tzcldprofile.name}</div> + <solid-display solid-resource bind-resources data-src="${this.element.getAttribute('parts')}" parts-points="${this.element.getAttribute('parts-points')}" fields="name, title, subtitle, part_points" + multiple-part_points="tzcld-autoeval-points", + widget-name="div", + widget-title="div", + widget-subtitle="div", + widget-part_points="tzcld-autoeval-points", + ></solid-display>`; + + this.element.innerHTML = render; + } + }); customElements.define( "solid-tzcld", class extends core.SolidTemplateElement { @@ -97,8 +179,9 @@ import("./utils.js").then((utils) => { routeurs() { let render = ` - <solid-router default-route="${this.route}-answers"> - <solid-route name="${this.route}-answers"></solid-route> + <solid-router default-route="${this.route}-my-communities"> + <solid-route name="${this.route}-answers" use-id></solid-route> + <solid-route name="${this.route}-my-communities"></solid-route> </solid-router> `; @@ -110,6 +193,44 @@ import("./utils.js").then((utils) => { return render; } + viewMyCommunities() { + + + let render = ` + <div id="${this.route}-my-communities" data-view="${this.route}-my-communities" class="tzcld-my-communities"> + <div class="segment full padding-large border-bottom border-color-grey" style="padding-top: 0;"> + <div class="segment full sm-hidden text-right"> + <solid-link class="backlink" next="${this.route}-community-profile">${this.localize("back")}</solid-link> + </div> + </div> + + <div class="segment block shadow bg-color-white margin-right-xxsmall margin-left-xxsmall sm-margin-none"> + + <div class="loader" id="loader-${this.route}-my-communities"> + <div></div> + <div></div> + <div></div> + <div></div> + </div> + + <solid-display + bind-resources="" + loader-id="loader-${this.route}-my-communities" + data-src ="${this.communities}" + fields="name" + next="${this.route}-answers" + + `; + + render += `> + </solid-display>`; + + + render += ` + </div> + </div>`; + return render; + } viewCommunityAnswers() { @@ -130,15 +251,17 @@ import("./utils.js").then((utils) => { <div></div> </div> - <solid-display + <tzcld-autoeval bind-resources="" loader-id="loader-${this.route}-answer" - data-src ="${this.parts}" - + parts ="${this.parts}" + parts-points ="${this.partsPoints}" + point-answers ="${this.pointAnswers}" + solid-resource `; render += `> - </solid-display>`; + </tzcld-autoeval>`; render += ` @@ -162,6 +285,7 @@ import("./utils.js").then((utils) => { ${this.routeurs()} ${this.viewWidgets()} ${this.viewCommunityAnswers()} + ${this.viewMyCommunities()} `; return render; -- GitLab