diff --git a/src/includes/entrepreneur/components/header.pug b/src/includes/entrepreneur/components/header.pug index 2e707496280b4a80755342de18352d81684237b2..5d66d6b93471ae85848e6c8bc393cecbe83daa10 100644 --- a/src/includes/entrepreneur/components/header.pug +++ b/src/includes/entrepreneur/components/header.pug @@ -19,7 +19,7 @@ //- input.ico_droite.ico_search .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/list.pug b/src/includes/entrepreneur/resources/list.pug index 55cf9245bf94fed89141509ca1de121fd9cb4727..73f5a0eac262cd0049502e7296227a1d6c7477f2 100644 --- a/src/includes/entrepreneur/resources/list.pug +++ b/src/includes/entrepreneur/resources/list.pug @@ -87,7 +87,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/browseDatabase.pug b/src/includes/mentor/browseDatabase.pug index e2f32bf9e94a521b70fd7007a8040e05206f8ada..003205f11b19c29234fb8a61d36203d9f93843bb 100644 --- a/src/includes/mentor/browseDatabase.pug +++ b/src/includes/mentor/browseDatabase.pug @@ -81,7 +81,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 0f09c6476c9c75384edd320c7ebb8b509e9308be..7ea9889c09f5429d9a3c6965621f4e4dc3ffb812 100644 --- a/src/includes/mentor/components/header.pug +++ b/src/includes/mentor/components/header.pug @@ -19,7 +19,7 @@ //- input.ico_droite.ico_search .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 97f8d20a309e0a8b8d6754983f140501dc538f46..fe8eca5019afa050c8f8cbbe764a53ba2610af4e 100644 --- a/src/includes/public/resources/list.pug +++ b/src/includes/public/resources/list.pug @@ -73,7 +73,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/scripts/coopstarter.js b/src/scripts/coopstarter.js index c087e24c4864c3b27f8d6dc0039fb4f4015512db..7ed2b0c97c242c6006dec18a0ddfb3d60ebf6776 100644 --- a/src/scripts/coopstarter.js +++ b/src/scripts/coopstarter.js @@ -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); }); diff --git a/src/styles/index.scss b/src/styles/index.scss index 665ec505d677955d8eccdd35835c106315bb59fa..24d3f81b445f15714dafe2aacf83c6aa8a7d2258 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -1333,7 +1333,7 @@ sib-set-default[name="submitter_info"]{ } } } -#mentor-resource-detail, #entrepreneur-resource-detail, #mentor-resource-validate{ +#mentor-resource-detail, #entrepreneur-resource-detail, #mentor-resource-validate, #public-resource-detail{ border: none; top: 0; padding: 0;