diff --git a/src/includes/entrepreneur/dashboard.pug b/src/includes/entrepreneur/dashboard.pug index 9d0a7953017fcedbbc485941b348aba88d1aff36..6d50f78ef44ed7be143bd0a39fb6213cdfcf78a6 100644 --- a/src/includes/entrepreneur/dashboard.pug +++ b/src/includes/entrepreneur/dashboard.pug @@ -13,27 +13,24 @@ section#home // and grouped by steps // From two different endpoints I guess //-Work on the page architecture - - - //TODO : investigate why we have to remove hidden attribute to see this even if we are on the right route. #entrepreneur-resource-list(hidden).no-sidebar.container include ./resources/list.pug - sib-router - sib-route( name='entrepreneur-request-create') - sib-route(id-prefix=`${endpoints.resources}`, name='entrepreneur-request-validation', use-id) - sib-route(id-prefix=`${endpoints.resources}`, name='entrepreneur-resource-detail', use-id) + sib-router + sib-route( name='entrepreneur-request-create') + sib-route(id-prefix=`${endpoints.resources}`, name='entrepreneur-request-validation', use-id) + sib-route(id-prefix=`${endpoints.resources}`, name='entrepreneur-resource-detail', use-id) - dialog#entrepreneur-request-create.no-sidebar.container - include ./requests/create.pug + dialog#entrepreneur-request-create.no-sidebar.container + include ./requests/create.pug - dialog#entrepreneur-request-validation.no-sidebar.container - p=`${data.YouRequestHasBeenSubmitted}` - p.flex - sib-link(next='entrepreneur-resource-list', class='button_base') Ok + dialog#entrepreneur-request-validation.no-sidebar.container + p=`${data.YouRequestHasBeenSubmitted}` + p.flex + sib-link(next='entrepreneur-resource-list', class='button_base') Ok - dialog#entrepreneur-resource-detail.no-sidebar - include resources/detail.pug + dialog#entrepreneur-resource-detail.no-sidebar + include resources/detail.pug #entrepreneur-account(hidden).no-sidebar.container include profile/detail.pug diff --git a/src/includes/entrepreneur/resources/detail.pug b/src/includes/entrepreneur/resources/detail.pug index 3efe7304ee9ac6281c504c5ca4c8e9ee347561d1..909cb8f81ee7b07aa925485a001eea128a73041d 100644 --- a/src/includes/entrepreneur/resources/detail.pug +++ b/src/includes/entrepreneur/resources/detail.pug @@ -1,5 +1,5 @@ .block_log.block_creat_count.no_shadow - sib-link(class="backlink", next="entrepreneur-resource-list") + sib-link(class="backlink", next="entrepreneur-dashboard") .like p.backlink i.fas.fa-times diff --git a/src/includes/head.pug b/src/includes/head.pug index d541cdd32e7a82afa30ac4018d54d1b264947f4e..9643a940b1bfe72d9add9db5741d5c922c6d8ca7 100644 --- a/src/includes/head.pug +++ b/src/includes/head.pug @@ -2,9 +2,10 @@ head title CoopStarter meta(charset="utf-8") script(src="https://unpkg.com/@webcomponents/webcomponentsjs@1.2.7/webcomponents-loader.js") + //- script(type="module" src="/scripts/sib-core/dist/index.js") script(type="module" src="https://unpkg.com/@startinblox/core@0.9") script(type="module" src="https://unpkg.com/@startinblox/router@0.7") - script(type="module" src="https://unpkg.com/@startinblox/oidc@0.8") + script(type="module" src="https://unpkg.com/@startinblox/oidc@0.8.4") 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") diff --git a/src/includes/mentor/dashboard.pug b/src/includes/mentor/dashboard.pug index 324fd8abe4f719a28dfbbe3b8aded862f9d713f5..3941aa8cb7372c69c61c305fa3a79915d9264500 100644 --- a/src/includes/mentor/dashboard.pug +++ b/src/includes/mentor/dashboard.pug @@ -15,42 +15,42 @@ section#home #mentor-resource-list(hidden).no-sidebar.container include resources/list.pug - sib-router - sib-ac-checker(permission="acl:Write" bind-resources) - sib-route(id-prefix=`${endpoints.resources}`, name='mentor-resource-validate', use-id) - sib-route(name='resource-validation-process') - sib-route(id-prefix=`${endpoints.resources}`, name='mentor-resource-detail', use-id) - - dialog#mentor-resource-validate.no-sidebar - include resources/validate.pug - - dialog#resource-validation-process.no-sidebar - include ./validation-process.pug - - dialog#mentor-resource-detail.no-sidebar - .block_log.block_creat_count.no_shadow - sib-link(class="backlink", next="mentor-resource-list") - .like - p.backlink - i.fas.fa-times - - div#detail-mentor-loader - hidden - i.fas.fa-spinner.fa-spin - - include resources/comment.pug - - include resources/detail.pug - - h2.title_form.related=`${data.RelatedResources}` - - sib-display( - bind-resources - fields="related" - multiple-related - widget-related='cs-display-mentor-related' - label-related='' - ) + sib-router + sib-ac-checker(permission="acl:Write" bind-resources) + sib-route(id-prefix=`${endpoints.resources}`, name='mentor-resource-validate', use-id) + sib-route(name='resource-validation-process') + sib-route(id-prefix=`${endpoints.resources}`, name='mentor-resource-detail', use-id) + + dialog#mentor-resource-validate.no-sidebar + include resources/validate.pug + + dialog#resource-validation-process.no-sidebar + include ./validation-process.pug + + dialog#mentor-resource-detail.no-sidebar + .block_log.block_creat_count.no_shadow + sib-link(class="backlink", next="mentor-dashboard") + .like + p.backlink + i.fas.fa-times + + div#detail-mentor-loader + hidden + i.fas.fa-spinner.fa-spin + + include resources/comment.pug + + include resources/detail.pug + + h2.title_form.related=`${data.RelatedResources}` + + sib-display( + bind-resources + fields="related" + multiple-related + widget-related='cs-display-mentor-related' + label-related='' + ) #mentor-database(hidden).no-sidebar.container include resources/database.pug @@ -79,11 +79,11 @@ section#home ) #mentor-resource-create(hidden).no-sidebar.container - sib-link(class="backlink", next="mentor-resource-list")=`${data.BackToDashboard}` + sib-link(class="backlink", next="mentor-dashboard")=`${data.BackToDashboard}` include resources/create.pug #mentor-resource-edit(hidden).no-sidebar.container - sib-link(class="backlink", next="mentor-resource-list")=`${data.BackToDashboard}` + sib-link(class="backlink", next="mentor-dashboard")=`${data.BackToDashboard}` include resources/edit.pug #resource-creation-confirmation(hidden).no-sidebar.container diff --git a/src/includes/public/dashboard.pug b/src/includes/public/dashboard.pug index 7d2ec083a18532b5b76e2aa9fc0524724c4c294a..ae990f15bb397e55214dedb584f0714d1bb1c100 100644 --- a/src/includes/public/dashboard.pug +++ b/src/includes/public/dashboard.pug @@ -11,11 +11,11 @@ section#home #public-resource-list.no-sidebar.container include ./resources/list.pug - sib-router - sib-route(id-prefix=`${endpoints.resources}`, name='public-resource-detail', use-id) + sib-router + sib-route(id-prefix=`${endpoints.resources}`, name='public-resource-detail', use-id) - dialog#public-resource-detail.no-sidebar - include resources/detail.pug + dialog#public-resource-detail.no-sidebar + include resources/detail.pug #user-account-view(hidden).no-sidebar.container include profile/view.pug diff --git a/src/includes/public/resources/detail.pug b/src/includes/public/resources/detail.pug index b462b5f0d87e626ad6894513aaff8abad44f7dfc..5673177a75557b585a9e6c72196cc07140da72c9 100644 --- a/src/includes/public/resources/detail.pug +++ b/src/includes/public/resources/detail.pug @@ -1,5 +1,5 @@ .block_log.block_creat_count.no_shadow - sib-link(class="backlink", next="public-resource-list") + sib-link(class="backlink", next="public-dashboard") .like p.backlink i.fas.fa-times @@ -120,7 +120,6 @@ bind-resources nested-field="conversations" ) - h2.title_form.related=`${data.RelatedResources}` diff --git a/src/index.pug b/src/index.pug index f80ce7881cce4bbd0dbfac0d0c363a322bed2dd9..d9b1358fc9a982bfcb4e866b291aef0705f0784b 100644 --- a/src/index.pug +++ b/src/index.pug @@ -18,70 +18,24 @@ html #entrepreneur-dashboard(hidden).no-sidebar include includes/entrepreneur/dashboard.pug + #public-dashboard(hidden).no-sidebar + include includes/public/dashboard.pug + #splash(hidden).no-sidebar.container.flex include includes/splash.pug #account-creation(hidden).no-sidebar.container include includes/account-creation.pug - - #public-dashboard(hidden).no-sidebar - include includes/public/dashboard.pug #main-loader(hidden) Loading… -sib-auth - sib-auth-provider( - class="sib-auth-provider" - data-authority=`${sdn}` - data-id="coopstarter" - ) - -script(type='module'). - import { store } from 'https://unpkg.com/@startinblox/core@0.8'; - const sibAuth = document.querySelector('sib-auth'); - - class CoopStarterLoginComponent extends HTMLElement { - async connectedCallback() { - mentor_login.onclick = () => this.triggerLogin(); - this.update(); - } - - async triggerLogin() { - let loader = document.getElementById('main-loader'); - loader.removeAttribute('hidden'); - await sibAuth.login(); - } - - async update() { - let loader = document.getElementById('main-loader'); - loader.removeAttribute('hidden'); - let user = await sibAuth.getUser(); - let idToken = await sibAuth.getUserIdToken(); + sib-auth + sib-auth-provider( + class="sib-auth-provider" + data-authority=`${sdn}` + data-id="coopstarter" + ) - if ( !user ) { - loader.setAttribute("hidden", true); - window.dispatchEvent( - new CustomEvent('requestNavigation', { detail: { route: 'splash' } }) - ); - } - user = await store.get(user); + script(type='module' src='/scripts/dispatch-space-n-user.js') - if (user && user.mentor_profile) { - window.dispatchEvent( - new CustomEvent('requestNavigation', { detail: { route: 'mentor-dashboard' } }) - ); - } else if (user && user.entrepreneur_profile) { - window.dispatchEvent( - new CustomEvent('requestNavigation', { detail: { route: 'entrepreneur-dashboard' } }) - ); - } else { - window.dispatchEvent( - new CustomEvent('requestNavigation', { detail: { route: 'account-creation' } }) - ); - } - } - empty(){} - populate(){} - } - customElements.define('cs-login', CoopStarterLoginComponent); diff --git a/src/scripts/dispatch-space-n-user.js b/src/scripts/dispatch-space-n-user.js new file mode 100644 index 0000000000000000000000000000000000000000..4af132f5240fd03c8bd6b8d4730900c9170b6fa1 --- /dev/null +++ b/src/scripts/dispatch-space-n-user.js @@ -0,0 +1,122 @@ +import { store } from 'https://unpkg.com/@startinblox/core@0.9'; +const sibAuth = document.querySelector('sib-auth'); + +const context = { + '@vocab': 'http://happy-dev.fr/owl/#', + rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', + rdfs: 'http://www.w3.org/2000/01/rdf-schema#', + ldp: 'http://www.w3.org/ns/ldp#', + foaf: 'http://xmlns.com/foaf/0.1/', + name: 'rdfs:label', + acl: 'http://www.w3.org/ns/auth/acl#', + permissions: 'acl:accessControl', + mode: 'acl:mode', + geo: "http://www.w3.org/2003/01/geo/wgs84_pos#", + lat: "geo:lat", + lng: "geo:long", + 'mentor_profile': 'http://happy-dev.fr/owl/#mentor_profile', + 'entrepreneur_profile': 'http://happy-dev.fr/owl/#entrepreneur_profile', +}; + +//We create a custom element +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(); + this.update(); + } + + async triggerLogin() { + let loader = document.getElementById('main-loader'); + loader.removeAttribute('hidden'); + await sibAuth.login(); + } + + decodeId(id) { + let slashReplace = '~_'; + let colonReplace = '~@'; + let dotReplace = '~!'; + let tildeReplace = '~~'; + if (!id) return ''; + return id.replace(new RegExp(`\\${colonReplace}`, 'g'), ':') + .replace(new RegExp(`\\${slashReplace}`, 'g'), '/') + .replace(new RegExp(`\\${dotReplace}`, 'g'), '.') + .replace(new RegExp(`\\${tildeReplace}`, 'g'), '~') + .replace(/^@/, ''); + } + + + async update() { + let loader = document.getElementById('main-loader'); + loader.removeAttribute('hidden'); + let user = await sibAuth.getUser(); + + //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(userFromStore) { + let is_mentor = await userFromStore.mentor_profile; + let is_entrepreneur = await userFromStore.entrepreneur_profile; + if (is_mentor) { + userPrefix = "mentor" + } else if(is_entrepreneur) { + userPrefix = "entrepreneur" + } + } + } + + //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 (newUrl !== window.location.href) { + var newRoute = new URL(newUrl).pathname.replace(/^\/([a-z]{2})\//, ""); + window.dispatchEvent( + new CustomEvent('requestNavigation', { + detail: { + route: newRoute.split(/\/(.*?)\//)[1], + resource: { "@id": this.decodeId(newRoute.split(/@(.+)/)[1]) } + } + }) + ); + window.location.href = newUrl; + loader.toggleAttribute('hidden', true); + } else { + loader.toggleAttribute('hidden', true); + } + } else { + //User is a mentor + if (userPrefix === "mentor") { + window.dispatchEvent( + new CustomEvent('requestNavigation', { detail: { route: 'mentor-dashboard' } }) + ); + //User is a entrepreneur + } else if (userPrefix === "entrepreneur") { + window.dispatchEvent( + new CustomEvent('requestNavigation', { detail: { route: 'entrepreneur-dashboard' } }) + ); + } else if(user) { + window.dispatchEvent( + new CustomEvent('requestNavigation', { detail: { route: 'account-creation' } }) + ); + loader.toggleAttribute('hidden', true); + } else { + window.dispatchEvent( + new CustomEvent('requestNavigation', { detail: { route: 'splash' } }) + ); + loader.toggleAttribute('hidden', true); + } + } + } + empty(){} + populate(){} +} +customElements.define('cs-login', CoopStarterLoginComponent); \ No newline at end of file diff --git a/src/styles/index.scss b/src/styles/index.scss index 31318f6a3c31beab2716685d255721e7bffac867..410a1f0ed79d6a79019c097d7b7e967ccfed63c6 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -1741,7 +1741,13 @@ sib-set-default[name="specifications"]>sib-multiple{ } cs-display-entrepreneur-related, cs-display-mentor-related, -cs-display-mentor-database-related, cs-display-public-related { +cs-display-public-related { + cursor: pointer; + margin-left: 1px; +} + +cs-display-mentor-database-related, cs-display-public-related, +cs-display-mentor-related, cs-display-entrepreneur-related { display: block; float: left; width: 33%; @@ -1815,24 +1821,30 @@ div#requests.tabcontent sib-display.request_accordion div div> sib-set-default > } cs-validate-action div{ - clear: both; - text-align: right; - } + clear: both; + text-align: right; +} #requests sib-set-default[name="content"] { padding: 0 18px; max-height: 0; overflow: hidden; transition: max-height 0.2s ease-out; - } -.fas.fa-times{ +} + +.fas.fa-times { font-size: 2rem; - &:before{ - position: absolute; - right: 18px; + &:before { + position: absolute; + right: 18px; } } +cs-display-mentor-link, cs-display-entrepreneur-link, +cs-display-user-link { + cursor: pointer; +} + /*XXXXXXXXXXXXXXXXXX Commentaires XXXXXXXXXXXXXXXXXXXXXXXXXXX*/ .sib-conversation div>.conversation-item{ @@ -2008,7 +2020,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/ #entrepreneur-resource-list container .step div sib-display >div, #public-resource-list container .step div sib-display >div, #mentor-database container .step div sib-display >div{ margin-top: 2rem; } -#mentor-account .block_list.flex{ +#mentor-account .block_list.flex, #mentor-account-view .block_list.flex, +#entrepreneur-account-view .block_list.flex, #user-account-view .block_list.flex{ margin-bottom: 19rem; } #entrepreneur-request-create sib-set-default[name="complementary_information"] cs-section_header[name="header_complementary"] h2{