From 65f4651e9f2f6c86cb9f2e156339f6a5fcb75865 Mon Sep 17 00:00:00 2001 From: Mattia Gosetto Date: Fri, 21 May 2021 12:11:33 +0200 Subject: [PATCH] modal --- .../html/common/submit_form_window.jsp | 134 ++++++++++++++++++ .../docroot/html/pagamenti/view.jsp | 9 +- .../pagamenti/view_panel_form_bollettino.jsp | 6 +- 3 files changed, 144 insertions(+), 5 deletions(-) create mode 100644 liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/common/submit_form_window.jsp diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/common/submit_form_window.jsp b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/common/submit_form_window.jsp new file mode 100644 index 00000000..51b47fce --- /dev/null +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/common/submit_form_window.jsp @@ -0,0 +1,134 @@ +<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@include file="/html/init.jsp"%> +<% +String formName = ParamUtil.getString(request, "formName", "fm"); +String titolo = ParamUtil.getString(request, "titolo", "Invio"); +String buttonId = ParamUtil.getString(request, "buttonId", "sumbit-button"); +String buttonConferma = ParamUtil.getString(request, "buttonConferma", "Modifica"); +String buttonAnnulla = ParamUtil.getString(request, "buttonAnnulla", "Annulla"); +String width = ParamUtil.getString(request, "width", "700"); +String height = ParamUtil.getString(request, "height"); +String contentDiv = ParamUtil.getString(request, "contentDiv", "saveAndCloseDiv"); +boolean buttonBar = ParamUtil.getBoolean(request, "buttonBar", true); +String randomId = StringUtil.randomId(); +String onClick = ParamUtil.getString(request, "onClick"); +boolean externalForm = ParamUtil.getBoolean(request, "externalForm", false); +boolean okVisible = ParamUtil.getBoolean(request, "okVisible", true); +%> + +
+
+

+ +
+ + +AUI().ready('aui-modal', 'aui-io-request', 'aui-form-validator', function(A) { + var modal = new A.Modal({ + bodyContent: A.one('#<%=contentDiv%>'), + width: <%= width %>, + <% + if (!height.equals(StringPool.BLANK)) { + %> + height: <%= height %>, + <% + } + %> + centered: true, + destroyOnHide: false, + headerContent: '

<%= titolo %>

', + modal: true, + render: '#saveAndCloseModal_<%= randomId %>', + visible: false, + close: false, + }).render(); + <% + if (buttonBar) { + %> + modal.addToolbar( + [ + { + label: '<%= buttonAnnulla %>', + on: { + click: function() { + modal.hide(); + } + } + }, + <% + if (okVisible) { + %> + { + label: '<%= buttonConferma %>', + cssClass: 'btn-primary', + on: { + click: function() { + <% + if (Validator.isNotNull(onClick)) { + out.print(onClick); + } else { + %> + submitForm(document.<%= formName %>); + var formValidator = Liferay.Form.get('<%= formName %>') + .formValidator; + <% + if (externalForm) { + %> + if (!formValidator.hasErrors()) { + A.one('#confirmClose_<%= randomId %>') + .set('value', 'true'); + } else { + alert("Attenzione!\nCampi richiesti non compilati correttamente"); + } + modal.hide(); + <% + } else { + %> + if (!formValidator.hasErrors()) { + modal.hide(); + A.one('#confirmClose_<%= randomId %>') + .set('value', 'true'); + } + <% + } + %> + <% + } + %> + } + } + } + <% + } + %> + ] + ); + <% + } + %> + + A.one('#<%= buttonId %>').on('click', function() { + A.one('#<%=contentDiv%>').show(); + modal.show(); + }); + + window.alert = function(msg) { + $('.message').text(msg); + $('.customAlert').css('animation', 'fadeIn 0.3s linear'); + $('.customAlert').css('display', 'inline'); + setTimeout(function() { + $('.customAlert').css('animation', 'none'); + }, 100); + }; + + $(function(){ + $('.confirmButton').click(function(){ + $('.customAlert').css('animation', 'fadeOut 0.3s linear'); + setTimeout(function(){ + $('.customAlert').css('animation', 'none'); + $('.customAlert').css('display', 'none'); + }, 100); + }); + }); +}); +
\ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/pagamenti/view.jsp b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/pagamenti/view.jsp index bada833c..7597c874 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/pagamenti/view.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/pagamenti/view.jsp @@ -88,6 +88,7 @@ <% String buttonFormId = "pagamentoFormButton_"+index; String contentFormId = "pagamentoFormContent_"+index; + String formNameBollettino = "fmPagamenti_"+index; %> + - - + + + + @@ -155,6 +159,7 @@ + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/pagamenti/view_panel_form_bollettino.jsp b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/pagamenti/view_panel_form_bollettino.jsp index 0aabe85d..7da407f8 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/pagamenti/view_panel_form_bollettino.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/pagamenti/view_panel_form_bollettino.jsp @@ -13,6 +13,7 @@ <% long dettPraticaId = ParamUtil.getLong(request, "dettPraticaId",0l); long idPagamento = ParamUtil.getLong(request, "idPagamento", 0l); + String formName = ParamUtil.getString(request, "formName", "fm"); DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(dettPraticaId); Pagamento objPagamento = PagamentoLocalServiceUtil.fetchPagamento(idPagamento); @@ -21,7 +22,7 @@ String portletNamespace = renderResponse.getNamespace(); String redirect = currentURL+"#"+portletNamespace+"tab="+portletNamespace+"page_pagamenti"; - + %> @@ -33,10 +34,9 @@ - + - \ No newline at end of file