diff --git a/src/includes/components/widgets.pug b/src/includes/components/widgets.pug index 3cfc84ad0df1f5fef86db92a3487690bc6b15adb..b8de6880ae50035538ff0cde33e4dcdcd9f109c9 100644 --- a/src/includes/components/widgets.pug +++ b/src/includes/components/widgets.pug @@ -98,7 +98,7 @@ sib-widget(name='cs-delete-action') div sib-link( data-src="\${src}" - next="\${value}" + next="confirm_suppress" ) <i class="fas fa-trash-alt"></i> sib-widget(name='cs-broken-action') diff --git a/src/includes/entrepreneur/dashboard.pug b/src/includes/entrepreneur/dashboard.pug index e91bebd00b6ce36ef844d0efce9bdcbc8a8faddb..106a3a9963c677f1abb6f98ab305e1894a2420ab 100644 --- a/src/includes/entrepreneur/dashboard.pug +++ b/src/includes/entrepreneur/dashboard.pug @@ -7,9 +7,6 @@ header#header(role='banner') include ./components/header.pug section#home - div#coopstarter-loader - hidden Loading, please wait... - //TODO: //-Distinguish the search form from the listing //-Create two Sib-displays getting the resources by "types" diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug index e851f7336a0e68f7d825777e7d30df9ee5094c30..484ccf810af16637cf7779bad6babaf4121384af 100644 --- a/src/includes/entrepreneur/resources/list.pug +++ b/src/includes/entrepreneur/resources/list.pug @@ -14,9 +14,12 @@ container.block_list.flex.flex_espace div.w_75.block-g-entre div h2.title_form Search for a resource + div#resources-loader + hidden Loading resources, please wait... + sib-form#search-by-keyword( data-src=`${endpoints.resources}`, - loader-id="coopstarter-loader" + loader-id="resources-loader" fields='keyword(name_keyword, description, author)' label-keyword="Search by author, name..." widget-keyword="sib-form-placeholder-text" @@ -75,21 +78,19 @@ container.block_list.flex.flex_espace div div.button_base Make a request - div#resources-loader - hidden Loading resources, please wait... - + //Fake tabs to filter by type. div.tabs.flex_espace div(class='tablink filter_by_type active', onclick="openFakeTab(this)") sib-display#type1( - data-src="https://api.coopstarter.happy-dev.fr/types/1/" + data-src=`${endpoints.types}1/` fields='name' widget-name='fake-tabs' ) div(class='tablink filter_by_type', onclick="openFakeTab(this)") sib-display#type2( - data-src="https://api.coopstarter.happy-dev.fr/types/2/" + data-src=`${endpoints.types}2/` fields='name' widget-name='fake-tabs' ) @@ -119,6 +120,7 @@ container.block_list.flex.flex_espace search-widget-search_for_a_resource="hidden-widget" + search-widget-more_criterias_hidden="hidden-widget" search-multiple-type='sib-form-dropdown' search-widget-type='sib-form-auto-completion' search-multiple-format='sib-form-dropdown' diff --git a/src/includes/mentor/dashboard.pug b/src/includes/mentor/dashboard.pug index 89ed339e2dc34f09ccef2499aa86e20585e713ce..d27b1086ffc92656efe1fc7fdea92a04c4dbe13d 100644 --- a/src/includes/mentor/dashboard.pug +++ b/src/includes/mentor/dashboard.pug @@ -18,6 +18,7 @@ section#home sib-ac-checker(permission="acl:Write" bind-resources) sib-route(id-prefix=`${endpoints.resources}`, name='mentor-resource-detail', use-id) sib-route(id-prefix=`${endpoints.resources}`, name='mentor-resource-validate', use-id) + sib-route(name='resource-validation-process') dialog#mentor-resource-detail.no-sidebar include resources/detail.pug @@ -26,6 +27,10 @@ section#home include resources/validate.pug sib-link(class="backlink", next="mentor-resource-list") Back to the dashboard + dialog#resource-validation-process + h1 What is a validation process ? + sib-link(class="backlink pull-right", next="mentor-resource-list") X + #mentor-resource-create(hidden).no-sidebar.container sib-link(class="backlink", next="mentor-resource-list") Back to the dashboard include resources/create.pug @@ -46,5 +51,7 @@ section#home #mentor-account-edit(hidden).no-sidebar.container include profile/edit.pug + + diff --git a/src/includes/mentor/profile/edit.pug b/src/includes/mentor/profile/edit.pug index d2318a2913901b3d70b91b8371059dd2d3da1c84..d5b10e3bdbd6e239583655ba3b2947598f514c45 100644 --- a/src/includes/mentor/profile/edit.pug +++ b/src/includes/mentor/profile/edit.pug @@ -58,7 +58,8 @@ sib-form#mentor_profile_edition.block_log.block_creat_count( class-headline='w_75' submit-button="Save modifications" - next='mentor-dashboard' + next='mentor-resource-list' ) sib-link(class="backlink", next="mentor-resource-list") Back to the dashboard +sib-link(class="backlink", next="mentor-account") Back to the profile diff --git a/src/includes/mentor/resources/confirmation.pug b/src/includes/mentor/resources/confirmation.pug index 2e2bd1aa3fa235e6a64a914cee379d3185bedf9a..964d2811175285abc28c892dfb73615d595c3d7b 100644 --- a/src/includes/mentor/resources/confirmation.pug +++ b/src/includes/mentor/resources/confirmation.pug @@ -10,7 +10,15 @@ div.block_list div p.flex - sib-link(next="resource-validation-process") What is the validation process ? + + sib-router + sib-route(name='resource-validation-process_confirmation') + + dialog#resource-validation-process_confirmation + h1 What is a validation process ? + sib-link(class="backlink pull-right", next="resource-creation-confirmation") X + + sib-link(class="backlink pull-right", next="resource-validation-process_confirmation") What is a validation process ? div.flex h3.button_base diff --git a/src/includes/mentor/resources/create.pug b/src/includes/mentor/resources/create.pug index 98488b194084c93325ce403a3a86be2cbf0c7599..bc9083862429f6cb1788c5fd9ce5c17dc4f691af 100644 --- a/src/includes/mentor/resources/create.pug +++ b/src/includes/mentor/resources/create.pug @@ -8,7 +8,7 @@ p.p_entete Thank you for enriching our database ! sib-form#resource-creation-form( data-src=`${endpoints.resources}` fields="mandatory_information(header_mandatory, name, country, language, uri,\ - format, field, author, publication_year, skills),\ + format, fields, author, publication_year, skills),\ complementary_information(header_complementary, description, iframe_link,\ preview_image, tags),classification(header_classification, target, type, steps),\ access(header_access, sharing),related_section(header_related, related)" @@ -23,7 +23,7 @@ p.p_entete Thank you for enriching our database ! range-format=`${endpoints.formats}` range-steps=`${endpoints.steps}` range-language=`${endpoints.languages}` - range-field=`${endpoints.fields}` + range-fields=`${endpoints.fields}` range-related=`${endpoints.resources}` label-header_mandatory='Mandatory information' @@ -37,7 +37,7 @@ p.p_entete Thank you for enriching our database ! label-language='Language*' label-uri='Location/weblink*' label-format='Format*' - label-field='Field*' + label-fields='Field*' label-author='Resource author*' label-publication_year='Year of publication*' label-skills='Learning outcomes, skills*' @@ -54,8 +54,8 @@ p.p_entete Thank you for enriching our database ! label-related='Add a resource' - multiple-field='sib-multiple-select' - widget-field='sib-form-auto-completion' + multiple-fields='sib-multiple-select' + widget-fields='sib-form-auto-completion' multiple-type='sib-multiple-select' widget-type='sib-form-auto-completion' diff --git a/src/includes/mentor/resources/detail.pug b/src/includes/mentor/resources/detail.pug index 03b72aa6a42ea6d03e57675dac557b93076557f6..4dd59199a3c9d02a41bbda48243a47a5f693962c 100644 --- a/src/includes/mentor/resources/detail.pug +++ b/src/includes/mentor/resources/detail.pug @@ -116,4 +116,5 @@ include ../../components/widgets ) + \ No newline at end of file diff --git a/src/includes/mentor/resources/list.pug b/src/includes/mentor/resources/list.pug index 8fcfea89d469221d74f8c25c993577c3b7bf8823..f5bcf2f2e5c2a07703beb9171c92fbe7472db0d7 100644 --- a/src/includes/mentor/resources/list.pug +++ b/src/includes/mentor/resources/list.pug @@ -1,5 +1,14 @@ include ../../components/widgets +sib-router + sib-route( name='confirm_suppress', use-id) + +dialog#confirm_suppress + h1 confirm_suppress + sib-delete(data-label="Die bitch, die !!" bind-resources) + sib-link(class="backlink pull-right", next="mentor-resource-list") X + + div.container_min h2.title_lead.fd_bleu International index of resources for cooperative mentors and entrepreneurs button.button_dark.pull-right Watch the presentation @@ -24,8 +33,13 @@ div.block_list h2 History of your resources div.block_log.block_list + div#reviews.tabcontent + div#loader-review-mentor + hidden Loading, please wait... + sib-link(class="backlink pull-right", next="resource-validation-process") What is a validation process ? sib-display#pending-resources( + loader-id="loader-review-mentor" data-src=`${endpoints.resources}pending/` fields='content(name, info(author, publication_year)), validate', @@ -41,8 +55,12 @@ div.block_list widget-validate='cs-validate-action' ) + div(id='requests', class="tabcontent") + div#loader-requests-mentor + hidden Loading, please wait... sib-display.request_accordeon( + loader-id="loader-requests-mentor" data-src=`${endpoints.requests}` fields='content(name, description), info(fields, language.name, target), create', @@ -60,17 +78,48 @@ div.block_list widget-create='cs-validate-action' ) + div(id='history', class="tabcontent") + div#loader-history-mentor + hidden Loading, please wait... sib-display#resources-history( + loader-id="loader-history-mentor" bind-user nested-field='resources' - fields='content(name, format, publication_year), actions(review.status, detail, edit, delete)', + fields='search_for_a_resource(name, description, author),content(name, format, publication_year), actions(review.status, detail, edit, delete)', + search-fields='search_for_a_resource, header_criterias, more_criterias_hidden(format, publication_year, country, language, fields)', + search-range-format=`${endpoints.formats}` + search-range-language=`${endpoints.languages}` + search-range-fields=`${endpoints.fields}` + + search-label-search_for_a_resource="Search by author, name..." + search-widget-search_for_a_resource="sib-form-placeholder-text" + widget-search_for_a_resource="hidden-widget" + + + search-multiple-format='sib-form-dropdown' + search-widget-format='sib-form-auto-completion' + search-multiple-language='sib-form-dropdown' + search-widget-language='sib-form-auto-completion' + search-multiple-fields='sib-form-dropdown' + search-widget-fields='sib-form-auto-completion' + widget-review.status='cs-resource-status', + search-widget-header_criterias="cs-section_header" + search-label-header_criterias="More criterias" + + search-label-format='Format' + search-label-publication_year='Year of publication' + search-label-country='Country of publication' + search-label-language='Language' + search-label-fields='Field' class-name="tit_element_list" + + widget-format='cs-display-multiple-property' - label-format='Formats:' + label-format='Formats' class-format="contenu_list" each-label-format='' @@ -93,3 +142,5 @@ div.block_list widget-delete='cs-delete-action' action-delete='delete' ) + + diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js index c998511eb3d02e9103493d41fb00077cd93283c4..910ba261a72963e26e5326820a8c56c1e25526a8 100644 --- a/src/scripts/coopstarter.js +++ b/src/scripts/coopstarter.js @@ -40,6 +40,7 @@ function linkDatasetToField(detail, targetFormName, inputName) { }); } +//Refresh information after a form submission function refreshList(formId, listId) { let form = document.getElementById(formId); form.addEventListener("save", event => { @@ -49,7 +50,7 @@ function refreshList(formId, listId) { } //Remove pagination when there is no resource in a step group -function actualizePagination() { +function refreshPagination() { var resources_containers = document.querySelectorAll( ".resource_by_step sib-form+div" ); @@ -67,13 +68,68 @@ function actualizePagination() { } //Manage select hidden to fullfill them with more "more criterias" selection -function selectHiddenManagement() { - //Need to refactor the part +function selectHiddenManagement(select_hidden, option_selected, form) { + options_hidden = select_hidden.getElementsByTagName("option"); + for (let option_hidden of options_hidden) { + //Removing the selected attribute from previous selection + option_hidden.removeAttribute("selected"); + + if (option_hidden.value == option_selected.value) { + //Actually selecting the option if it is the good one + option_hidden.setAttribute("selected", "selected"); + select_hidden.setAttribute("value", option_selected.value); + } + + //Trigerring a reload of the associated form + let parent_form = select_hidden.closest("sib-form"); + parent_form.component.inputChange(); + } + form.querySelector("sib-form").component.inputChange(); + refreshPagination(); +} + +//Manage input hidden field to fullfill them with more "more criterias" selection +function inputHiddenManagement(field, field_search, form) { + field.setAttribute("value", field_search.value); + form.querySelector("sib-form").component.inputChange(); + refreshPagination(); +} + +//Manage select hidden for type to fullfill them with more "more criterias" selection +function selectHiddenManagementForType(tab, form) { + let type_hidden_field = document.querySelectorAll( + 'hidden-widget[name="more_criterias_hidden"] select[name="type"]' + ); + if (tab.classList.contains("active")) { + //Fullfill hidden field + let type_field_search = tab + .querySelector(`sib-display`) + .getAttribute("data-src"); + + 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": "' + type_field_search + '"}') { + //Actually selecting the option if it is the good one + option_hidden.setAttribute("selected", "selected"); + select_hidden.setAttribute("value", option_hidden.value); + form.querySelector("sib-form").component.inputChange(); + refreshPagination(); + } + } + //Trigerring a reload of the associated form + let parent_form = select_hidden.closest("sib-form"); + parent_form.component.inputChange(); + refreshPagination(); + }); + } } jQuery(document).ready(function($) { - //Actualize pagination - actualizePagination() + //Refresh pagination + refreshPagination(); + // Get the element with id="defaultOpen" and click on it document.getElementById("defaultOpen").click(); @@ -118,8 +174,15 @@ jQuery(document).ready(function($) { forms.forEach(form => { form.addEventListener("populate", e => { + //Manage fake tabs + let tabs = document.getElementsByClassName("filter_by_type"); + for (let tab of tabs) { + selectHiddenManagementForType(tab, form); + } + //On load in dashbord Entrepreneur - actualizePagination(); + refreshPagination(); + //SEARCH BY KEYWORD //To retrieve keyword //https://git.happy-dev.fr/startinblox/framework/sib-core/issues/379 @@ -135,8 +198,8 @@ jQuery(document).ready(function($) { keyword_submit.addEventListener("click", function() { keyword_hidden_fields.forEach(hidden_field => { hidden_field.setAttribute("value", keyword_field.value); - actualizePagination(); form.querySelector("sib-form").component.inputChange(); + refreshPagination(); }); }); @@ -152,43 +215,45 @@ jQuery(document).ready(function($) { }; //MORE CRITERIAS - //TODO: Refactor this section ? const more_criterias_form = document.getElementById("more_criterias"); // https://git.happy-dev.fr/startinblox/framework/sib-core/issues/453 window.setTimeout(() => { - //Manage fake tabs + //Refresh data list on delete resources + const deleteButton = document.querySelectorAll("sib-delete"); + for (var i = 0; i < deleteButton.length; i++) { + deleteButton[i].addEventListener("resourceDeleted", e => { + const historyList = document.getElementById("resources-history"); + historyList.dataset.src = historyList.dataset.src; + + let confirm_suppress = document.getElementById("confirm_suppress"); + confirm_suppress.setAttribute("hidden", "hidden"); + + //If we supress from the detail resource view, we close this view. + let mentor_resource_detail = document.getElementById( + "mentor-resource-detail" + ); + mentor_resource_detail.setAttribute("hidden", "hidden"); + this.dispatchEvent( + new CustomEvent("requestNavigation", { + bubbles: true, + detail: { route: "actions" } + }) + ); + }); + } + + //Manage fake tabs for type let tabs = document.getElementsByClassName("filter_by_type"); - let type_hidden_field = document.querySelectorAll( - 'hidden-widget[name="more_criterias_hidden"] select[name="type"]' - ); for (let tab of tabs) { - tab.addEventListener("click", function() { - if (tab.classList.contains("active")) { - - //Fullfill hidden field - let type_field_search = tab - .querySelector(`sib-display`) - .getAttribute("data-src"); - - type_hidden_field.forEach(function(select_hidden) { - options_hidden = select_hidden.getElementsByTagName("option"); - for (let option_hidden of options_hidden) { - if (option_hidden.value == '{"@id": "'+type_field_search+'"}') { - //Actually selecting the option if it is the good one - option_hidden.setAttribute("selected", "selected"); - select_hidden.setAttribute("value", option_hidden.value); - } - } - }); - } - }); + tab.addEventListener( + "click", + selectHiddenManagementForType(tab, form) + ); } //To retrieve format - //TODO: How we should filled the hidden field with multiple value? - //TODO: The hidden search field set with one value doesn't work let format_field_search = more_criterias_form.querySelector( `select[name="format"]` ); @@ -203,22 +268,7 @@ jQuery(document).ready(function($) { ); format_hidden_field.forEach(function(select_hidden) { - options_hidden = select_hidden.getElementsByTagName("option"); - for (let option_hidden of options_hidden) { - //Removing the selected attribute from previous selection - option_hidden.removeAttribute("selected"); - if (option_hidden.value == option_selected.value) { - //Actually selecting the option if it is the good one - option_hidden.setAttribute("selected", "selected"); - select_hidden.setAttribute("value", option_selected.value); - } - - //Trigerring a reload of the associated form - let parent_form = select_hidden.closest("sib-form"); - parent_form.component.inputChange(); - } - actualizePagination(); - form.querySelector("sib-form").component.inputChange(); + selectHiddenManagement(select_hidden, option_selected, form); }); }; @@ -236,23 +286,7 @@ jQuery(document).ready(function($) { ); language_hidden_field.forEach(function(select_hidden) { - options_hidden = select_hidden.getElementsByTagName("option"); - for (let option_hidden of options_hidden) { - //Removing the selected attribute from previous selection - option_hidden.removeAttribute("selected"); - - if (option_hidden.value == option_selected.value) { - //Actually selecting the option if it is the good one - option_hidden.setAttribute("selected", "selected"); - select_hidden.setAttribute("value", option_selected.value); - } - - //Trigerring a reload of the associated form - let parent_form = select_hidden.closest("sib-form"); - parent_form.component.inputChange(); - } - actualizePagination(); - form.querySelector("sib-form").component.inputChange(); + selectHiddenManagement(select_hidden, option_selected, form); }); }; @@ -270,23 +304,7 @@ jQuery(document).ready(function($) { ); field_hidden_field.forEach(function(select_hidden) { - options_hidden = select_hidden.getElementsByTagName("option"); - for (let option_hidden of options_hidden) { - //Removing the selected attribute from previous selection - option_hidden.removeAttribute("selected"); - - if (option_hidden.value == option_selected.value) { - //Actually selecting the option if it is the good one - option_hidden.setAttribute("selected", "selected"); - select_hidden.setAttribute("value", option_selected.value); - } - - //Trigerring a reload of the associated form - let parent_form = select_hidden.closest("sib-form"); - parent_form.component.inputChange(); - } - actualizePagination(); - form.querySelector("sib-form").component.inputChange(); + selectHiddenManagement(select_hidden, option_selected, form); }); }; @@ -301,10 +319,8 @@ jQuery(document).ready(function($) { ); year_field_search.addEventListener("input", function() { - year_hidden_fields.forEach(year_field => { - year_field.setAttribute("value", year_field_search.value); - actualizePagination(); - form.querySelector("sib-form").component.inputChange(); + year_hidden_fields.forEach(field => { + inputHiddenManagement(field, year_field_search, form); }); }); @@ -317,10 +333,8 @@ jQuery(document).ready(function($) { ); country_field_search.addEventListener("input", function() { - country_hidden_fields.forEach(country_field => { - country_field.setAttribute("value", country_field_search.value); - actualizePagination(); - form.querySelector("sib-form").component.inputChange(); + country_hidden_fields.forEach(field => { + inputHiddenManagement(field, country_field_search, form); }); }); }, 4000); diff --git a/src/styles/index.scss b/src/styles/index.scss index 93df0a0aba6652c75e05f0c64aa1216bf29f980f..4681eb3a6f034e582059e8f5427bd667e9aa054b 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -399,7 +399,7 @@ ico_droite:before{ display: block; } -sib-form-label-text, sib-multiple-select,cs-form-password{ +sib-form-label-text, sib-form-dropdown, sib-multiple-select,cs-form-password{ display: block; width: 48.5%; }