From c275d1a1bc9f2351b52d1734bc8c30f513fddb03 Mon Sep 17 00:00:00 2001 From: marcoalderighi Date: Thu, 4 May 2023 11:24:00 +0200 Subject: [PATCH] fix gestione comuni in creazione pratica ospedaliera --- .../portos/fe/portlet/FascicoloFePortlet.java | 22 ++++------ .../html/fascicolofe/edit_modal_fascicolo.jsp | 42 ++++++++++++++++--- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/FascicoloFePortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/FascicoloFePortlet.java index d6ae2c90..cd254514 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/FascicoloFePortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/FascicoloFePortlet.java @@ -154,20 +154,16 @@ public class FascicoloFePortlet extends MVCPortlet { } } writeJSON(request, response, jsonArray); - } else if ("comuniOspedaliera".equals(id)) { - String provinciaId = ParamUtil.getString(request, "provinciaId"); - JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); - if (Validator.isNotNull(provinciaId) && !provinciaId.equals("0")) { - List comuni = TerritorioLocalServiceUtil.getActiveComuniByCodiceProvincia_Ospedaliera(provinciaId); - for (long comuneId : comuni) { - JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); - Comune comune = ComuneLocalServiceUtil.getComune(comuneId); - jsonObject.put("comuneId", comune.getComuneId()); - jsonObject.put("descLong", comune.getDenominazione()); - jsonArray.put(jsonObject); - } + } else if ("ospedalieraEnabled".equals(id)) { + long comuneId = ParamUtil.getLong(request, "comuneId"); + Comune comune = ComuneLocalServiceUtil.fetchComune(comuneId); + JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); + if(Validator.isNotNull(comune)){ + jsonObject.put("ospedalieraEnabled", comune.getPraticaOspedali()); + } else { + jsonObject.put("ospedalieraEnabled", false); } - writeJSON(request, response, jsonArray); + writeJSON(request, response, jsonObject); } else if ("zoneFasce".equals(id)) { long comuneId = ParamUtil.getLong(request, "comuneId", 0L); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/edit_modal_fascicolo.jsp b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/edit_modal_fascicolo.jsp index f12ee7ea..c9a715cc 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/edit_modal_fascicolo.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/edit_modal_fascicolo.jsp @@ -50,8 +50,8 @@ - + var defaultFormValidator = A.config.FormValidator; var procedure = {}; @@ -113,12 +113,8 @@ }; var getComuni = function(callback, provinciaId) { - var requestURL = '<%= getComuniURL %>'; - if(isPraticaOspedaliera){ - requestURL = '<%= getComuniOspedalieraURL %>'; - } A.io.request( - requestURL, + '<%= getComuniURL %>', { data: { provinciaId: provinciaId @@ -156,6 +152,39 @@ } ); }; + + var evalAddOspedaliRadio = function() { + var comuneId = $('.add-new-project__comune select').val(); + + A.io.request( + '<%= isOspedalieraEnabledURL %>', + { + data: { + comuneId: comuneId + }, + dataType: 'json', + on: { + success: function() { + var rd = this.get('responseData'); + var ospedalieraRadio = $('.add-new-project__procedura input[value="<%= Constants.PROCEDURA_H %>"]'); + var ospedalieraId = ospedalieraRadio.attr("id"); + var ospedalieraLabel = ospedalieraRadio.closest('label[for="' + ospedalieraId + '"]'); + if(!rd.ospedalieraEnabled){ + ospedalieraRadio.prop('disabled', 'disabled').prop('checked', false); + if(!ospedalieraLabel.hasClass('hidden')){ + ospedalieraLabel.addClass('hidden'); + } + } else { + ospedalieraRadio.prop('disabled', false).removeClass('disabled'); + if(ospedalieraLabel.hasClass('hidden')){ + ospedalieraLabel.removeClass('hidden'); + } + } + } + } + } + ); + } new Liferay.DynamicSelect([ { @@ -213,6 +242,7 @@ $('.add-new-project__procedura div').removeClass('success'); }else if(val !== 0) { $('.add-new-project__procedura input').prop('disabled', false).removeClass('disabled').parent().css('display', 'block'); + evalAddOspedaliRadio(); } }); \ No newline at end of file