diff --git a/src/includes/entrepreneur/components/header.pug b/src/includes/entrepreneur/components/header.pug index ced090f7aa80f16559a0927effacbb4f387798fd..30a3b8e757d50d7b803d451089f934335ceda341 100644 --- a/src/includes/entrepreneur/components/header.pug +++ b/src/includes/entrepreneur/components/header.pug @@ -20,7 +20,7 @@ input .dropdownWrapper - sib-display#user-account-picture.dropdownLabel( + sib-display#entrepreneur-account-picture.dropdownLabel( bind-user fields='account.picture', widget-account.picture='cs-account-picture' diff --git a/src/includes/entrepreneur/profile/detail.pug b/src/includes/entrepreneur/profile/detail.pug index 66884ff88bad4fd049c19e110e1625cefa60755a..e0099ead827d881b651c0edfca53d53d104f9637 100644 --- a/src/includes/entrepreneur/profile/detail.pug +++ b/src/includes/entrepreneur/profile/detail.pug @@ -25,8 +25,9 @@ div.block_list.flex sib-display#entrepreneur_info( bind-user - fields='name, entrepreneur_profile.organisation.name, registered_on' + fields='account.picture, name, entrepreneur_profile.organisation.name, registered_on' widget-name='cs-display-property' + widget-account.picture='cs-profile-picture' widget-entrepreneur_profile.organisation.name='cs-display-property' widget-entrepreneur_profile.registered_on='cs-display-property' ) diff --git a/src/includes/entrepreneur/profile/edit.pug b/src/includes/entrepreneur/profile/edit.pug index c18664c6a31bfcaffca86172e96f09e304d55eb7..8028caf09c60e8ccb345e18e769a6c85f47da8af 100644 --- a/src/includes/entrepreneur/profile/edit.pug +++ b/src/includes/entrepreneur/profile/edit.pug @@ -9,7 +9,6 @@ sib-form#entrepreneur_profile_edition.block_log.block_creat_count( label-first_name="Surname" label-last_name="Name" - label-username="Username" label-entrepreneur_profile.organisation="Organisation" label-account.picture="Profile picture" widget-username="sib-form-hidden" diff --git a/src/includes/entrepreneur/resources/detail.pug b/src/includes/entrepreneur/resources/detail.pug index 4fa44af4bc54d2051f0891a000729148b237916a..dbb6ea52497ec51c93319f1752fcccdfcc212f92 100644 --- a/src/includes/entrepreneur/resources/detail.pug +++ b/src/includes/entrepreneur/resources/detail.pug @@ -116,7 +116,7 @@ include ../../components/widgets widget-name='cs-display-property' label-detail='' widget-detail='sib-action' - action-detail='mentor-resource-detail' + action-detail='entrepreneur-resource-detail' ) diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug index c5615382f0a600fb278373dfc533cc59b5ba81b1..0212694713abd64051b0232787f642ba98ef365f 100644 --- a/src/includes/entrepreneur/resources/list.pug +++ b/src/includes/entrepreneur/resources/list.pug @@ -15,7 +15,6 @@ div.container_min //It will be great to have autocompletion on country //I'm waiting for a confirmation to suppress step field - container.block_list div.flex.flex_espace div.w_75.block-g-entre @@ -162,7 +161,7 @@ container.block_list next='entrepreneur-resource-detail' - paginate-by="5" + paginate-by="2" ) //Step 2 @@ -217,7 +216,7 @@ container.block_list class="panel" next='entrepreneur-resource-detail' - paginate-by="5" + paginate-by="2" ) div.step @@ -270,7 +269,7 @@ container.block_list class="panel" next='entrepreneur-resource-detail' - paginate-by="5" + paginate-by="2" ) //Step 4 diff --git a/src/includes/mentor/browseDatabase.pug b/src/includes/mentor/browseDatabase.pug index 56b20477f4b6ea78cd0455b4ee37252d0524b940..4b3d385ea11bef4c6d72bda027effc90a3bc39af 100644 --- a/src/includes/mentor/browseDatabase.pug +++ b/src/includes/mentor/browseDatabase.pug @@ -82,7 +82,7 @@ container.block_list.flex.flex_espace //Fake tabs to filter by type. div.tabs.flex_espace div(class='tablink filter_by_type active', onclick="openFakeTab(this)") - sib-display#type1( + sib-display.type1( data-src=`${endpoints.types}1/` fields='name' widget-name='fake-tabs' diff --git a/src/includes/mentor/components/header.pug b/src/includes/mentor/components/header.pug index 6dad49ec79b9daec658cdead557003b873842114..38761065b762e943e2a27d980065bee569fc3f4a 100644 --- a/src/includes/mentor/components/header.pug +++ b/src/includes/mentor/components/header.pug @@ -20,7 +20,7 @@ input .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/public/resources/list.pug b/src/includes/public/resources/list.pug index 5bf30626a2939762197dfe870486e0e777484a3c..4bcbb62babcb6df368eac1047208ad30b67fdb14 100644 --- a/src/includes/public/resources/list.pug +++ b/src/includes/public/resources/list.pug @@ -74,7 +74,7 @@ container.block_list.flex.flex_espace //Fake tabs to filter by type. div.tabs.flex_espace div(class='tablink filter_by_type active', onclick="openFakeTab(this)") - sib-display#type1( + sib-display.type1( data-src=`${endpoints.types}1/` fields='name' widget-name='fake-tabs' @@ -423,7 +423,6 @@ container.block_list.flex.flex_espace label-fields='' multiple-fields class="panel" - next='public-resource-detail' paginate-by="5" diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js index 2f43bc724231c9e91e2a0a11413422d0d76d7a15..7ed2b0c97c242c6006dec18a0ddfb3d60ebf6776 100644 --- a/src/scripts/coopstarter.js +++ b/src/scripts/coopstarter.js @@ -66,19 +66,19 @@ function loadFile(event) { /** * Fill datas to a form. - * @param {HTMLElment} detail - Element with the datas to retrieve. + * @param {HTMLElment} element - Element with the datas to retrieve. * @param {string} targetFormName - Id of the form to fill. - * @param {string} inputName - Name of the input to fill. + * @param {string} inputName - Name of the input to fill in the form. */ -function linkDatasetToField(detail, targetFormName, inputName) { +function linkDatasetToField(element, targetFormName, inputName) { let targetForm = document.getElementById(targetFormName); targetForm.addEventListener("populate", event => { let resourceField = targetForm.querySelector(`input[name="${inputName}"]`); if (resourceField) { - resourceField.value = JSON.stringify({ "@id": detail.dataset.src }); + resourceField.value = JSON.stringify({ "@id": element.dataset.src }); resourceField.setAttribute( "value", - JSON.stringify({ "@id": detail.dataset.src }) + JSON.stringify({ "@id": element.dataset.src }) ); } }); @@ -195,6 +195,40 @@ function selectHiddenManagementForType(tab, form) { } } +/** + * Init type to type 1 + */ +function InitManagementForType() { + var forms = document.querySelectorAll(".resource_by_step"); + + forms.forEach(form => { + form.addEventListener( + "populate", + e => { + window.setTimeout(() => { + let type_hidden_field = form.querySelectorAll('select[name="type"]'); + type_hidden_field.forEach(function(select_hidden) { + options_hidden = select_hidden.getElementsByTagName("option"); + for (let option_hidden of options_hidden) { + option_hidden.removeAttribute("selected"); + if (option_hidden.value == '{"@id": "http://localhost:8000/types/1/"}') { + //Actually selecting the option if it is the good one + option_hidden.setAttribute("selected", "selected"); + select_hidden.setAttribute("value", option_hidden.value); + } + } + //Trigerring a reload of the associated form + let parent_form = select_hidden.closest("sib-form"); + parent_form.component.inputChange(); + refreshPagination(); + }); + }); + }, + 3000 + ); + }); +} + /** * Manage the report broken links hidden form */ @@ -288,6 +322,24 @@ function manageLogoutButton() { } } +/** + * Initi the custom form file behaviour + * Todo : we can improve the performance adding param to reduce the loop + */ +function initFileUpload(){ + var previewImage = document.querySelectorAll( + "sib-form-file input[name='preview_image']+input" + ); + var previewlabel = document.querySelectorAll("sib-form-file div"); + for (let item of previewlabel) { + item.innerHTML = "Upload a file"; + } + + for (let item of previewImage) { + item.addEventListener("change", loadFile); + } +} + /** * For entrepreneur dashboard only : * As we cannot have multiple imbricated filtering with the native sib-display, we manage it manually. @@ -476,6 +528,9 @@ jQuery(document).ready(function($) { //Refresh pagination refreshPagination(); + //init the fitering by step + InitManagementForType(); + // Get the element with id="defaultOpen" and click on it document.getElementById("defaultOpen").click(); @@ -495,20 +550,24 @@ jQuery(document).ready(function($) { refreshList("improvement-dialog-form", "pending-resources"); refreshList("entrepreneur_profile_creation", "entrepreneur_info"); refreshList("entrepreneur_profile_creation", "entrepreneur_contact"); - refreshList("entrepreneur_profile_creation", "user-account-picture"); + refreshList("entrepreneur_profile_creation", "entrepreneur-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"); + refreshList("mentor_profile_creation", "mentor-account-picture"); refreshList("entrepreneur_profile_edition", "entrepreneur_info"); refreshList("entrepreneur_profile_edition", "entrepreneur_contact"); - refreshList("entrepreneur_profile_edition", "user-account-picture"); + refreshList("entrepreneur_profile_edition", "entrepreneur-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"); + refreshList("mentor_profile_edition", "mentor-account-picture"); refreshList("change_status_request", "request-list"); + addProperFilterToSearchComponents("entrepreneur-resource-list"); + addProperFilterToSearchComponents("mentor-database"); + addProperFilterToSearchComponents("public-resource-list"); + var header_dropdown = $(".dropdownWrapper"), drop_choices = header_dropdown.find(".dropdownLabel"); @@ -540,17 +599,8 @@ jQuery(document).ready(function($) { fillReportBrokenLinkForm(event, userWhoSubmitReport, formBrokenLink); }); - var previewImage = document.querySelectorAll( - "sib-form-file input[name='preview_image']+input" - ); - var previewlabel = document.querySelectorAll("sib-form-file div"); - for (let item of previewlabel) { - item.innerHTML = "Upload a file"; - } - - for (let item of previewImage) { - item.addEventListener("change", loadFile); - } + //Init the form file behaviour + initFileUpload() //Manage the accordion in request mentor dashboard. manageAccordionForRequest() @@ -596,11 +646,11 @@ jQuery(document).ready(function($) { window.setTimeout(() => { //Manage accordion by step manageAccordionByStep(); - refreshPagination(); - }, 2000); - //In the entrepreneur dashboard, we set data from the display form to the hidden ones. - addProperFilterToSearchComponents("entrepreneur-resource-list"); - addProperFilterToSearchComponents("mentor-database"); - addProperFilterToSearchComponents("public-resource-list"); + //Init the form file behaviour + initFileUpload(); + + //Correct the native default of pagination + refreshPagination(); + }, 3000); });