diff --git a/src/includes/components/widgets.pug b/src/includes/components/widgets.pug index 219dc85e81015d613f7f7842bb2e1e85ddd77891..405c3e931108c1bc75f4c358137ee2d04e8fde64 100644 --- a/src/includes/components/widgets.pug +++ b/src/includes/components/widgets.pug @@ -39,7 +39,7 @@ sib-widget(name='cs-display-user-link') sib-widget(name='cs-display-property') template - p ${value} + p ${await value} sib-widget(name='cs-display-page-title') template diff --git a/src/includes/entrepreneur/profile/view.pug b/src/includes/entrepreneur/profile/view.pug index 6bad6b206b8c5d36a6d5e4f57d8413d9a3422312..fe9af731e9c7db8525cdce753a4aac7ffc10b843 100644 --- a/src/includes/entrepreneur/profile/view.pug +++ b/src/includes/entrepreneur/profile/view.pug @@ -12,7 +12,7 @@ div.block_list.flex div.button_base.ico_gauche.ico_database=`${data.BrowseDatabase}` div.profile_information.block_log.w_75 - sib-display#mentor_info( + sib-display.user_info( bind-resources fields='account.picture, name, mentorProfile.headline, mentorProfile.city, mentorProfile.country.name, registered_on' widget-account.picture='cs-profile-picture' @@ -30,7 +30,7 @@ div.block_list.flex bind-resources ) - sib-display#mentor_complementary( + sib-display.user_complementary( bind-resources fields='biography_label, mentorProfile.biography, skills_label, mentorProfile.skills' widget-biography_label='cs-display-label' @@ -41,7 +41,7 @@ div.block_list.flex widget-mentorProfile.biography='cs-display-property' ) - sib-display#mentor_contact( + sib-display.user_contact( bind-resources fields='email, mentorProfile.phone, mentorProfile.linkedin, mentorProfile.twitter' label-email=`${data.Email} : ` diff --git a/src/includes/head.pug b/src/includes/head.pug index 11241e4f5f30f052061421a7afb0b58df97042ec..73072a18521c4dcad05662cc4492b1946bdd4d0e 100644 --- a/src/includes/head.pug +++ b/src/includes/head.pug @@ -6,7 +6,7 @@ head script(type="module" src="https://unpkg.com/@startinblox/core@0.9.27") script(type="module" src="https://unpkg.com/@startinblox/router@0.7") //- script(type="module" src="/scripts/sib-auth/index.js") - script(type="module" src="https://unpkg.com/@startinblox/oidc@0.8.4") + script(type="module" src="https://unpkg.com/@startinblox/oidc@0.8") script(type="module" src="https://unpkg.com/@startinblox/component-conversation@0.4") script(src="https://kit.fontawesome.com/48014d2af3.js") script(src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous") @@ -14,6 +14,11 @@ head script(async src="https://platform.twitter.com/widgets.js" charset="utf-8") script(src="https://browser.sentry-cdn.com/5.15.5/bundle.min.js" integrity="sha384-wF7Jc4ZlWVxe/L8Ji3hOIBeTgo/HwFuaeEfjGmS3EXAG7Y+7Kjjr91gJpJtr+PAT" crossorigin="anonymous") link(rel="stylesheet" href="/styles/index.css") + sib-analytics( + type="matomo" + url="https://sib.matomo.cloud/" + id="1" + ) script(data-default-context type="application/ld+json" ). diff --git a/src/includes/mentor/components/header.pug b/src/includes/mentor/components/header.pug index ac47ea5f939a47bc44f16bf6094eae6acfc06e4f..628c69be2912d7cd4f662df44f9f427256ba27c7 100644 --- a/src/includes/mentor/components/header.pug +++ b/src/includes/mentor/components/header.pug @@ -17,7 +17,7 @@ naked ) .dropdownWrapper - sib-display#user_account_picture.dropdownLabel( + sib-display#mentor_account_picture.dropdownLabel( bind-user fields='account.picture', widget-account.picture='cs-account-picture' diff --git a/src/includes/mentor/profile/view.pug b/src/includes/mentor/profile/view.pug index 279c4e7ef3914ad884ed4418f77e9ea7ed00ea82..1525ae111fca72971329767a3354594f659c5fc7 100644 --- a/src/includes/mentor/profile/view.pug +++ b/src/includes/mentor/profile/view.pug @@ -12,7 +12,7 @@ div.block_list.flex div.button_base.ico_gauche.ico_database=`${data.BrowseDatabase}` div.profile_information.block_log - sib-display#mentor_info( + sib-display.user_info( bind-resources fields='account.picture, name, mentorProfile.headline, mentorProfile.city, mentorProfile.country.name, registered_on' widget-account.picture='cs-profile-picture' @@ -30,7 +30,7 @@ div.block_list.flex bind-resources ) - sib-display#mentor_complementary( + sib-display.user_complementary( bind-resources fields='biography_label, mentorProfile.biography, skills_label, mentorProfile.skills' widget-biography_label='cs-display-label' @@ -41,7 +41,7 @@ div.block_list.flex widget-mentorProfile.biography='cs-display-property' ) - sib-display#mentor_contact( + sib-display.user_contact( bind-resources fields='email, mentorProfile.phone, mentorProfile.linkedin, mentorProfile.twitter' label-email=`${data.Email} : ` diff --git a/src/includes/mentor/resources/list.pug b/src/includes/mentor/resources/list.pug index cac962f6d30b30b1285052f5aec552bbaa972f58..343602564520963a6f032cec3a881c6ddf55a590 100644 --- a/src/includes/mentor/resources/list.pug +++ b/src/includes/mentor/resources/list.pug @@ -98,6 +98,7 @@ div.block_list div#loader-history-mentor hidden i.fas.fa-spinner.fa-spin + sib-display#resources_history( loader-id="loader-history-mentor" bind-user diff --git a/src/includes/public/profile/view.pug b/src/includes/public/profile/view.pug index 890c3edca36c5b0bfcb4a5b61736feb203701eea..0ee6b03caee1a88bed52c70c30671f80c9b4a3fb 100644 --- a/src/includes/public/profile/view.pug +++ b/src/includes/public/profile/view.pug @@ -12,7 +12,7 @@ div.block_list.flex div.button_base.ico_gauche.ico_database=`${data.BrowseDatabase}` div.profile_information.block_log - sib-display#mentor_info( + sib-display.user_info( bind-resources fields='account.picture, name, mentorProfile.headline, mentorProfile.city, mentorProfile.country.name, registered_on' widget-account.picture='cs-profile-picture' @@ -30,7 +30,7 @@ div.block_list.flex bind-resources ) - sib-display#mentor_complementary( + sib-display.user_complementary( bind-resources fields='biography_label, mentorProfile.biography, skills_label, mentorProfile.skills' widget-biography_label='cs-display-label' @@ -41,7 +41,7 @@ div.block_list.flex widget-mentorProfile.biography='cs-display-property' ) - sib-display#mentor_contact( + sib-display.user_contact( bind-resources fields='email, mentorProfile.phone, mentorProfile.linkedin, mentorProfile.twitter' label-email=`${data.Email} : ` diff --git a/src/includes/splash.pug b/src/includes/splash.pug index 3f87edfb5d184a66a6fb54f90bd859c0078d6844..576d2d6f12a6a308030ddc1b13143f4b4a58524e 100644 --- a/src/includes/splash.pug +++ b/src/includes/splash.pug @@ -12,7 +12,7 @@ h2.title_lead=`${data.welcome}` alt="Connect as mentor") cs-login(bind-user) - button#mentor_login.button_base=`${data.ConnectKnowledgeBase}` + button#kldb_login.button_base=`${data.ConnectKnowledgeBase}` sib-link(next='public-dashboard') button#public-access.button_base=`${data.AccessWithoutRegistration}` diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js index 93d392a46081c152cce231815e07eb72f2bb2cec..63419cdf47818405f2532061f7a96647a8293b8d 100644 --- a/src/scripts/coopstarter.js +++ b/src/scripts/coopstarter.js @@ -99,9 +99,12 @@ async function refreshList(formId, listId) { let form = document.getElementById(formId); form.addEventListener("save", async function() { let list = document.getElementById(listId); - let listProxy = await list.component.resource - listProxy.clearCache(); - list.dataset.src = list.dataset.src; + + if (list) { + let listProxy = await list.component.resource + listProxy.clearCache(); + list.dataset.src = list.dataset.src; + } }); } @@ -200,8 +203,10 @@ function selectHiddenManagementForType(tab, form) { //Trigerring a reload of the associated form let parent_form = select_hidden.closest("sib-form"); - parent_form.component.inputChange(); - refreshPagination(); + if (parent_form) { + parent_form.component.inputChange(); + refreshPagination(); + } }); } } @@ -362,7 +367,6 @@ function manageSelectLanguage() { }) } - } /** @@ -679,7 +683,6 @@ jQuery(document).ready(function($) { submitInput.disabled = true; submitInput.classList.add('disabled'); let inputs = mentorResourceCreationForm.querySelectorAll('input[type="text"]' + ',select' + ',textarea'); - console.log(inputs); inputs.forEach(function(input) { input.addEventListener('focusout', (() => { listenToInputChangeOnResourceCreation(mentorResourceCreationForm); @@ -695,9 +698,7 @@ jQuery(document).ready(function($) { let submitInput = mentorResourceEditionForm.querySelectorAll('input[type=submit]')[0]; submitInput.disabled = true; submitInput.classList.add('disabled'); - console.log(submitInput); let inputs = mentorResourceEditionForm.querySelectorAll('input[type="text"]' + ',select' + ',textarea'); - console.log(inputs); inputs.forEach(function(input) { input.addEventListener('focusout', (() => { listenToInputChangeOnResourceCreation(mentorResourceEditionForm); @@ -733,41 +734,41 @@ jQuery(document).ready(function($) { document.getElementById("defaultOpen").click(); //Retrieve the current user - let userAccountDataSrc = document.getElementById("user_account_picture"); + let mentorAccountDataSrc = document.getElementById("mentor_account_picture"); - if (userAccountDataSrc) { + if (mentorAccountDataSrc) { //Add the current user as reviewer. - linkDatasetToField(userAccountDataSrc, "validation_form", "reviewer"); - linkDatasetToField(userAccountDataSrc, "improvement_dialog_form", "reviewer"); - linkDatasetToField(userAccountDataSrc, "refusal_dialog_form", "reviewer"); - linkDatasetToField(userAccountDataSrc, "change_status_request", "reviewer"); + linkDatasetToField(mentorAccountDataSrc, "validation_form", "reviewer"); + linkDatasetToField(mentorAccountDataSrc, "improvement_dialog_form", "reviewer"); + linkDatasetToField(mentorAccountDataSrc, "refusal_dialog_form", "reviewer"); + linkDatasetToField(mentorAccountDataSrc, "change_status_request", "reviewer"); // linkDatasetToField(userAccountDataSrc, "add-like", "sender"); // linkDatasetToField(userAccountDataSrc, "add-dislike", "sender"); } - //On form submission, we sometime have to refresh a list. + //On form submission, we sometimes have to refresh a list. refreshList("resource_creation_form", "resources_history"); refreshList("validation_form", "pending_resources"); refreshList("refusal_dialog_form", "pending_resources"); refreshList("improvement_dialog_form", "pending_resources"); + initFileUpload("entrepreneur_profile_creation", "account.picture"); refreshList("entrepreneur_profile_creation", "entrepreneur_info"); refreshList("entrepreneur_profile_creation", "entrepreneur_contact"); refreshList("entrepreneur_profile_creation", "entrepreneur_account_picture"); - initFileUpload("entrepreneur_profile_creation", "account.picture"); + initFileUpload("mentor_profile_creation", "account.picture"); refreshList("mentor_profile_creation", "mentor_info"); refreshList("mentor_profile_creation", "mentor_complementary"); refreshList("mentor_profile_creation", "mentor_contact"); - refreshList("mentor_profile_creation", "user_account_picture"); - initFileUpload("mentor_profile_creation", "account.picture"); + refreshList("mentor_profile_creation", "mentor_account_picture"); + initFileUpload("entrepreneur_profile_edition", "account.picture"); refreshList("entrepreneur_profile_edition", "entrepreneur_info"); refreshList("entrepreneur_profile_edition", "entrepreneur_contact"); refreshList("entrepreneur_profile_edition", "entrepreneur_account_picture"); - initFileUpload("entrepreneur_profile_edition", "account.picture"); + initFileUpload("mentor_profile_edition", "account.picture"); refreshList("mentor_profile_edition", "mentor_info"); refreshList("mentor_profile_edition", "mentor_complementary"); refreshList("mentor_profile_edition", "mentor_contact"); - refreshList("mentor_profile_edition", "user_account_picture"); - initFileUpload("mentor_profile_edition", "account.picture"); + refreshList("mentor_profile_edition", "mentor_account_picture"); refreshRequestList("change_status_request", "request_list"); addProperFilterToSearchComponents("entrepreneur-resource-list"); @@ -808,7 +809,7 @@ jQuery(document).ready(function($) { //Manage the form to report broken link. let detailsContributor = document.getElementById("detail-mentor"); detailsContributor.addEventListener("populate", event => { - var userWhoSubmitReport = userAccountDataSrc.dataset.src + var userWhoSubmitReport = mentorAccountDataSrc.dataset.src var formBrokenLink = document.getElementById("report-broken-link-mentor"); fillReportBrokenLinkForm(event, userWhoSubmitReport, formBrokenLink); @@ -871,12 +872,15 @@ jQuery(document).ready(function($) { ); }); }; - + + //Retrieve the current user + let searcherAccountDataSrc = document.getElementById("entrepreneur_account_picture"); + //Manage the form to report broken link. let detailsSearcher = document.getElementById("detail-entrepreneur"); detailsSearcher.addEventListener("populate", event => { var formBrokenLink = document.getElementById("report-broken-link-entrepreneur"); - var userWhoSubmitReport = userAccountDataSrc.dataset.src + var userWhoSubmitReport = searcherAccountDataSrc.dataset.src fillReportBrokenLinkForm(event, userWhoSubmitReport, formBrokenLink); }); diff --git a/src/scripts/dispatch-space-n-user.js b/src/scripts/dispatch-space-n-user.js index 4ccb9829575d31416df48623b01de7325732cd8d..0049a14e67af2448ad12e16547e470b90a6560f5 100644 --- a/src/scripts/dispatch-space-n-user.js +++ b/src/scripts/dispatch-space-n-user.js @@ -23,7 +23,7 @@ class CoopStarterLoginComponent extends HTMLElement { // Those function will be call the element is connected to the dom async connectedCallback() { - document.getElementById("mentor_login").onclick = () => this.triggerLogin(); + kldb_login.onclick = () => this.triggerLogin(); this.update(); } @@ -46,21 +46,24 @@ class CoopStarterLoginComponent extends HTMLElement { .replace(/^@/, ''); } - async update() { let loader = document.getElementById('main-loader'); loader.removeAttribute('hidden'); let user = await sibAuth.getUser(); + if (!user) { + loader.toggleAttribute('hidden', true); + return; + } - //Set a userprefix default status + // console.log("Users get from the store", user); + // Set a userprefix default status var userPrefix = "public" // Idenfify the space we should go if (user) { await store.initGraph(user['@id'], context); let userFromStore = await store.get(user['@id']); - - //If the user is a mentor or an entreprenur, change user prefix + // If the user is a mentor or an entreprenur, change user prefix if(userFromStore) { let is_mentor = await userFromStore.mentor_profile; let is_entrepreneur = await userFromStore.entrepreneur_profile; @@ -72,11 +75,11 @@ class CoopStarterLoginComponent extends HTMLElement { } } - //If the url asked pointed to a resource + // If the url asked pointed to a resource if (window.location.href.indexOf('resource-detail') > -1) { var newUrl = window.location.href.replace(/\/([a-z]+)-dashboard\/([a-z]+)-resource-detail/, `/${userPrefix}-dashboard/${userPrefix}-resource-detail`) - //If the url is different after the treatment, we reload with the good url + // If the url is different after the treatment, we reload with the good url if (newUrl !== window.location.href) { var newRoute = new URL(newUrl).pathname.replace(/^\/([a-z]{2})\//, ""); window.dispatchEvent( @@ -93,26 +96,26 @@ class CoopStarterLoginComponent extends HTMLElement { loader.toggleAttribute('hidden', true); } } else { - //User is a mentor + // User is a mentor if (userPrefix === "mentor") { window.dispatchEvent( new CustomEvent('requestNavigation', { detail: { route: 'mentor-dashboard' } }) ); - //User is a entrepreneur + // User is a entrepreneur } else if (userPrefix === "entrepreneur") { window.dispatchEvent( new CustomEvent('requestNavigation', { detail: { route: 'entrepreneur-dashboard' } }) ); } else if(user) { + loader.toggleAttribute('hidden', true); window.dispatchEvent( new CustomEvent('requestNavigation', { detail: { route: 'account-creation' } }) ); - loader.toggleAttribute('hidden', true); - } else { + } else { + loader.toggleAttribute('hidden', true); window.dispatchEvent( new CustomEvent('requestNavigation', { detail: { route: 'splash' } }) ); - loader.toggleAttribute('hidden', true); } } }