From 64d212a4c8a215128af186f5142750674b5070f2 Mon Sep 17 00:00:00 2001 From: Yecksin Mauricio <53352977+yecksin@users.noreply.github.com> Date: Wed, 21 Feb 2024 16:29:39 -0500 Subject: [PATCH 1/4] :wrench: chore(deliverableShfrm): Disable options when select it --- .../projects/deliverables/deliverableShfrm.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js index db5e0c046a..9d874047f9 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -66,6 +66,7 @@ function init() { $("textarea[id!='justification']").autoGrow(); $(".deliverableList").on("change", addDeliverable); + autoEnableOptions(); } // Add a new deliverable element @@ -108,6 +109,22 @@ function addDeliverable() { updateActionsAndSubActionsIndexes(); checkItems($list); + disabledOption(this, option.val()); +} + +function disabledOption(element, value) { + console.clear() + $(element).find(`option[value="${value}"]`).attr('disabled', true); + $(element).select2("destroy").select2(); +} + +function enablesOption(element, value) { + $(element).parents('.subSectionsSelector').find('select').find(`option[value="${value}"]`).removeAttr('disabled'); + $(element).parents('.subSectionsSelector').find('select').select2("destroy").select2(); +} + +function autoEnableOptions() { + console.log("autoEnableOptions") } function checkItems(block) { @@ -603,8 +620,11 @@ function updateActionsAndSubActionsIndexes() { } function removeSubActionEvent() { - $(this).parents('.deliverableActivity').remove(); + const value = $(this).parents('.deliverableActivity').find('input.id').val(); updateActionsAndSubActionsIndexes(); + enablesOption(this, value); + $(this).parents('.deliverableActivity').remove(); + } function addPartnerEvent(e) { From cdfbf0cc44b61b843a19fa6e1af8f8c1e1a9ac7a Mon Sep 17 00:00:00 2001 From: JhonSGIzquierdo Date: Thu, 16 May 2024 10:58:39 -0500 Subject: [PATCH 2/4] :bug: fix(SHFRM): Display subactions selector --- .../projects/deliverables/deliverableShfrm.js | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js index 9d874047f9..962ac68974 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -64,13 +64,18 @@ function init() { setViewMore(); }); + // $(".deliverableList").select2(); + $("textarea[id!='justification']").autoGrow(); - $(".deliverableList").on("change", addDeliverable); + $(".deliverableList").on("change", addSubactionsEvent); + $(".deliverableList").on("click", function () { + console.log("click in selection") + }); autoEnableOptions(); } -// Add a new deliverable element -function addDeliverable() { +// Add a new subAction element +function addSubactionsEvent() { var option = $(this).find("option:selected"); var canAdd = true; if (option.val() == "-1") { @@ -91,6 +96,7 @@ function addDeliverable() { // Reset select $(this).val("-1"); $(this).trigger('change.select2'); + $(this).select2("destroy").select2(); if (!canAdd) { return; @@ -103,6 +109,7 @@ function addDeliverable() { $item.find(".id").val(option.val()); $list.append($item); $item.show('slow'); + // var $actionContainer = $(this).parents(".fullPartBlock"); // var activityIndex = $activity.find(".index").html(); // updateDeliverable(this); @@ -214,7 +221,7 @@ function attachEvents() { * Project partner Events */ // Add a project partner Event - $(".elementType-shfrmPriorityAction-deliverablePriorityActions").on("change", addPartnerEvent); + $(".elementType-shfrmPriorityAction-deliverablePriorityActions").on("change", addActionEvent); $(".removeElementType-shfrmPriorityAction-deliverablePriorityActions").on('click', removePartnerEvent); $(".removeElementType-shfrmPriorityAction-deliverablePriorityActions").on('mouseenter', function () { currentDeleteActionId = $(this).parent('.relationElement').find('.elementRelationID').val(); @@ -627,7 +634,7 @@ function removeSubActionEvent() { } -function addPartnerEvent(e) { +function addActionEvent(e) { var option = $(this).find("option:selected"); var $newElement = $("#projectPartner-template").clone(true).removeAttr("id"); $newElement.find(".actionidvalue").val(option.val()); @@ -635,23 +642,31 @@ function addPartnerEvent(e) { let itemsSize = Number($('#projectPartnersBlock').find('.projectPartner').length ?? 0); itemsSize && itemsSize++; + $newElement.find(".id").val(option.val()); $newElement.find(".index_number").html(itemsSize); $newElement.find(".priorityActionTitle").html($(option).text()); $newElement.find(".subActionsSelector").html(cloneSubActionSelect(option.val())); console.log($('#projectPartnersBlock')) $('#projectPartnersBlock').append($newElement); + $newElement.find("select").find('select').select2("destroy").select2(); + $newElement.show("slow", function () { $(document).trigger('updateComponent'); - $newElement.find("select").select2(); + $newElement.trigger('change.select2'); }); updateActionsAndSubActionsIndexes(); + checkItems($('#projectPartnersBlock')); } function cloneSubActionSelect(value) { - var $select = $(`#subactionSelect-${value}`).find('.baseselect').clone(true); + var $original =$(`#subactionSelect-${value}`).find('.baseselect'); + $original.find('select').select2("destroy"); + var $select = $original.clone(true); $select.removeClass('hideSelect'); + $original.find('select').select2(); + $select.find('select').select2(); return $select; } @@ -820,7 +835,6 @@ function addSelect2() { $("form select.setSelect2 ").select2({ width: '100%' }); - } /** From 2156745ebf49f6da858d7c144f6dfba5f87a3927 Mon Sep 17 00:00:00 2001 From: JhonSGIzquierdo Date: Thu, 16 May 2024 14:48:29 -0500 Subject: [PATCH 3/4] :art: style(homepage): methods name change and remove --- .../js/projects/deliverables/deliverableShfrm.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js index 962ac68974..f3591eabc7 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableShfrm.js @@ -68,10 +68,6 @@ function init() { $("textarea[id!='justification']").autoGrow(); $(".deliverableList").on("change", addSubactionsEvent); - $(".deliverableList").on("click", function () { - console.log("click in selection") - }); - autoEnableOptions(); } // Add a new subAction element @@ -120,9 +116,8 @@ function addSubactionsEvent() { } function disabledOption(element, value) { - console.clear() $(element).find(`option[value="${value}"]`).attr('disabled', true); - $(element).select2("destroy").select2(); + $(element).find('select').select2("destroy").select2(); } function enablesOption(element, value) { @@ -130,10 +125,6 @@ function enablesOption(element, value) { $(element).parents('.subSectionsSelector').find('select').select2("destroy").select2(); } -function autoEnableOptions() { - console.log("autoEnableOptions") -} - function checkItems(block) { console.log(block); var items = $(block).find('.deliverableActivity').length; @@ -222,7 +213,7 @@ function attachEvents() { */ // Add a project partner Event $(".elementType-shfrmPriorityAction-deliverablePriorityActions").on("change", addActionEvent); - $(".removeElementType-shfrmPriorityAction-deliverablePriorityActions").on('click', removePartnerEvent); + $(".removeElementType-shfrmPriorityAction-deliverablePriorityActions").on('click', removeActionEvent); $(".removeElementType-shfrmPriorityAction-deliverablePriorityActions").on('mouseenter', function () { currentDeleteActionId = $(this).parent('.relationElement').find('.elementRelationID').val(); }); @@ -609,7 +600,7 @@ function setPartnerTypeToDefault(type) { } let currentDeleteActionId = null; -function removePartnerEvent(e) { +function removeActionEvent() { $(`input.actionidvalue[value="${currentDeleteActionId}"]`).parents('.projectPartner').remove(); updateActionsAndSubActionsIndexes(); } From 620baaa16e53792858fea702a933d2d287c4ddba Mon Sep 17 00:00:00 2001 From: JhonSGIzquierdo Date: Thu, 16 May 2024 15:45:52 -0500 Subject: [PATCH 4/4] :bug: fix(SHFRM): same bug repair in other parnters --- .../webapp/crp/js/projects/deliverables/deliverableInfo.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js index c764d5a908..bd70f2c015 100644 --- a/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js +++ b/marlo-web/src/main/webapp/crp/js/projects/deliverables/deliverableInfo.js @@ -749,7 +749,12 @@ var deliverablePartnersModule = (function () { function addPartnerItem() { var $listBlock = $('.otherDeliverablePartners'); - var $newItem = $('#deliverablePartnerItem-template').clone(true).removeAttr('id'); + var $template = $('#deliverablePartnerItem-template'); + $template.find('select').select2("destroy"); + var $newItem = $template.clone(true).removeAttr('id'); + + $template.find('select').select2(); + $newItem.find('select').select2(); $listBlock.append($newItem); $newItem.show(); updateIndexes();