From 506951b37717b1f74e0c75f2cb288bcecba10810 Mon Sep 17 00:00:00 2001 From: senza <maximesenzamici@gmail.com> Date: Wed, 5 Aug 2020 14:10:39 +0200 Subject: [PATCH] fix conversation & js issues + share poll js --- etuc-voting.html | 8 ++++---- form.html | 6 +++--- index.html | 2 +- js/main.js | 23 ++++++++++++++++++----- js/polls-math.js | 2 +- sib-polls.js | 38 +++++++++++++++++--------------------- 6 files changed, 44 insertions(+), 35 deletions(-) diff --git a/etuc-voting.html b/etuc-voting.html index ffdabcf..240e938 100644 --- a/etuc-voting.html +++ b/etuc-voting.html @@ -8,13 +8,13 @@ <script type="module" src="https://unpkg.com/@startinblox/router"></script> <script type="module" src="https://unpkg.com/@startinblox/core@0.10"></script> - <script type="module" src="https://unpkg.com/@startinblox/component-conversation"></script> + <script type="module" src="https://unpkg.com/@startinblox/component-conversation@0.3"></script> <link rel="stylesheet" href="/css/main.css"> <script type="module" src="solid-polls.js"></script> - <script type="text/javascript" src="main.js"></script> - <script type="text/javascript" src="polls-math.js"></script> + <script type="text/javascript" src="/js/main.js"></script> + <script type="text/javascript" src="/js/polls-math.js"></script> <script type="module" src="./solid-polls-widget.js"></script> </head> <body> @@ -152,7 +152,7 @@ </section> <h1>test convo</h1> <solid-conversation - data-src="http://127.0.0.1:8000/polls/1/" + data-src="http://127.0.0.1:8000/polls/7/" nested-field="debate"> </solid-conversation> diff --git a/form.html b/form.html index b19b0e6..5a16edf 100644 --- a/form.html +++ b/form.html @@ -38,7 +38,7 @@ widget-title="solid-form-label-text" label-title="Survey title*" - widget-titleNote="sib-display-div" + widget-titleNote="solid-display-div" value-titleNote="Be clear on your survey title to helps users understand what is it about" class-titleNote="form-tips" @@ -55,9 +55,9 @@ multiple-pollOptions label-pollOptions="" - widget-image="solid-form-file" + widget-image="solid-form-file-image" label-image="Photo :" - upload-url="http://127.0.0.1:8000/upload/" + upload-url-image="http://127.0.0.1:8000/upload/" widget-sectionOptionTitle="solid-display-div" value-sectionOptionTitle="Vote options" diff --git a/index.html b/index.html index b5c53e7..f84342b 100644 --- a/index.html +++ b/index.html @@ -22,7 +22,7 @@ <body> <h1>Demo of the polls component</h1> <solid-poll - data-src="http://localhost:8000/polls/" + data-src="http://localhost:8000/" > </solid-poll> diff --git a/js/main.js b/js/main.js index 5e9d58c..271f37e 100644 --- a/js/main.js +++ b/js/main.js @@ -53,7 +53,7 @@ function showHideBlocks(activeCTAClass,inactiveCTAClass,diplayBlockClass,hideBlo window.addEventListener('load', () => { //set the domain source constant - console.log("loading"); + console.log("loading here"); //update poll ID's setTimeout(function(){ try { @@ -61,9 +61,11 @@ window.addEventListener('load', () => { } catch (error) { console.log(error); } - }, 500); - document.querySelectorAll("div[id=add-survey]")[0].addEventListener("navigate",()=> { - newOptionContent(); + }, 1500); + + document.querySelectorAll("solid-router")[0].addEventListener("navigate",()=> { + console.log("navigating"); + //newOptionContent(); }); }); @@ -93,4 +95,15 @@ function newOptionContent(){ } } - +/* + SHARE POLL BY EMAIL +*/ +function sharePollEmail(){ + let shareEmails = document.querySelector("#share-poll").value; + let emailTitle = document.querySelector("h1").innerText; + let emailSubject = "Donnez votre avis sur " + emailTitle; + let pollURL = window.location.href; + let emailContent = "Bonjour, je vous invite à participer au vote sur " + emailTitle + ". \n Venez sur la page suivante pour voter : "+ pollURL; + emailContent = encodeURIComponent(emailContent); + window.open("mailto:"+shareEmails+"?subject="+emailSubject+"&body="+emailContent); +} \ No newline at end of file diff --git a/js/polls-math.js b/js/polls-math.js index a29e2c2..6abfe18 100644 --- a/js/polls-math.js +++ b/js/polls-math.js @@ -13,6 +13,7 @@ window.addEventListener('load', () => { //set the domain source constant console.log("loading"); const dataSourceURI = document.querySelector("solid-display").dataset.src; + const urlComponents = new URL(dataSourceURI); const dataSourceDomain = urlComponents.origin; console.log("the data domain is",dataSourceDomain); @@ -39,7 +40,6 @@ window.addEventListener('load', () => { for (let i = 0; i < pageTitle.length; i++){ //get the data src node of first sib display & extract the url const dataSrc = pageTitle[i].dataset.src; - //extract current poll ID from the data src const pollId = dataSrc.match(/\/([0-9]+)\/$/)[1]; /*push to function that will take the value of ID diff --git a/sib-polls.js b/sib-polls.js index 42221cf..351f26a 100644 --- a/sib-polls.js +++ b/sib-polls.js @@ -1,5 +1,5 @@ import { SolidTemplateElement, Helpers } from 'https://unpkg.com/@startinblox/core@0.10'; -import { SIBConversation } from "https://unpkg.com/@startinblox/component-conversation@0.3"; +import { SIBConversation } from "https://unpkg.com/@startinblox/component-conversation@0.5"; /* WORKAROUT NOTE : *All data-src or range URL's hard coded in the component with a 127.0.0.1 : @@ -65,19 +65,11 @@ export class SolidPoll extends SolidTemplateElement { template({dataSrc, nestedField}) { if (!dataSrc) return ''; let sourceUrl = dataSrc + (nestedField ? nestedField + '/' : ''); - + + console.log("datasrc is ", dataSrc); + console.log("source url is", sourceUrl); return ` - <solid-widget name="etuc-display-votetags"> - <template> - <div> - <p> - \${await value.name} - </p> - </div> - </template> - </solid-widget> - <solid-router use-hash default-route="pollListing"> <solid-route class="d-none" name="pollListing" active=""></solid-route> <solid-route use-id name="pollPage"></solid-route> @@ -88,7 +80,7 @@ export class SolidPoll extends SolidTemplateElement { <solid-link next="add-survey">Add Poll</solid-link> <solid-display class="all-polls" - data-src="${sourceUrl}" + data-src="${sourceUrl}polls/" fields="banner(image),topline(title,orgLine(orgImage,hostingOrganisation),dateLine(dateImage,endDate)), body(shortDescription,tags)" @@ -223,23 +215,27 @@ export class SolidPoll extends SolidTemplateElement { <div class="share-vote"> <h3>Invite someone to vote</h3> - <p>email</p> - <p>field</p> + <p>Email :</p> + <input id="share-poll"></input> <p>To invite several people seperate the email with a semicolon (;).</p> - <input type="submit" value="SEND INVITES"> + <div> + <a id="share-emails" onclick="sharePollEmail()" type="submit" value="SEND INVITES"> + Share + </a> + </div> </div> </div> <div class="debate-tab-content" style="display: none;"> - <solid-conversation - data-src="${sourceUrl}polls/1/" + <sib-conversation + bind-resources nested-field="debate" date-format="DD/MM/YYYY - kk:mm" > - </solid-conversation> + </sib-conversation> </div> </div> @@ -281,9 +277,9 @@ export class SolidPoll extends SolidTemplateElement { multiple-pollOptions label-pollOptions="" - widget-image="solid-form-file" + widget-image="solid-form-file-image" label-image="Photo :" - upload-url="${sourceUrl}upload/" + upload-url-image="${sourceUrl}upload/" widget-sectionOptionTitle="solid-display-div" value-sectionOptionTitle="Vote options" -- GitLab