diff --git a/src/main/webapp/WEB-INF/tags/form/fields/table.tagx b/src/main/webapp/WEB-INF/tags/form/fields/table.tagx index 6e14dae547bf76970e9ccb3e627631d7da84fc35..258465a99c16f76807a267a65c5f8c83c217c275 100644 --- a/src/main/webapp/WEB-INF/tags/form/fields/table.tagx +++ b/src/main/webapp/WEB-INF/tags/form/fields/table.tagx @@ -69,6 +69,85 @@ } document.getElementById(id).id=id+"_stylized"; } + + function showRedirect(){ + var radioElements = document.getElementsByName("radioButton"); + console.log("${path}"); + for (var i=0; i < radioElements.length; i++) + if(radioElements[i].checked == true) { + var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}")); + if ("${select}" == "false") + window.location.href=pathHeader+"${path}/"+radioElements[i].value; + else { + var str = "${pathShow}"; + pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("programas/")); + window.location.href=pathHeader+str+"/"+radioElements[i].value; + } + } + } + + function updateRedirect(){ + var radioElements = document.getElementsByName("radioButton"); + + for (var i=0; i < radioElements.length; i++) + if(radioElements[i].checked == true) { + var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}")); + var form = "${path}".indexOf("ocorrenciamunicipais") != -1 ? "?formUpdate" : "?form"; + window.location.href=pathHeader+"${path}/"+radioElements[i].value+form; + } + } + + function deleteRedirect(){ + var radioElements = document.getElementsByName("radioButton"); + + for (var i=0; i < radioElements.length; i++) + if(radioElements[i].checked == true) { + var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}")); + document.deleteForm.action = pathHeader+"${path}/"+radioElements[i].value; + return confirm('${delete_confirm_msg}'); + } + } + + function post(){ + var form = document.getElementById("programa") == null ? document.getElementById("ocorrenciaMunicipal") : document.getElementById("programa"); + console.log(form); + form.action = selectRedirect(); + form.submit(); + + } + + function selectRedirect(){ + var radioElements = document.getElementsByName("radioButton"); + var selected =""; + + for (var i=0; i < radioElements.length; i++){ + if(radioElements[i].checked == true) { + selected += radioElements[i].value + "+"; + } + } + + selected = selected.substring(0,selected.lastIndexOf("+")); + + var progIndex = window.location.pathname.indexOf("/programas"); + if(progIndex == -1){ + progIndex = window.location.pathname.indexOf("/ocorrenciamunicipais"); + var pathHeader = window.location.pathname.substring(0,progIndex)+"/ocorrenciamunicipais"; + }else{ + var pathHeader = window.location.pathname.substring(0,progIndex)+"/programas"; + } + + pathHeader = pathHeader.charAt(pathHeader.length - 1) == "/" ? pathHeader.slice(0,pathHeader.length-1) : pathHeader; + if(window.location.pathname.indexOf("pesquisa") != -1){ + pathHeader += "/pesquisa"; + } + var form = ""; + if("${Itinerante}"=="true"){ + form = "/formItinerante/"; + }else{ + form = "/form/"; + } + return pathHeader+form+selected; + } </script> @@ -287,91 +366,6 @@ </table> - <script type="text/javascript"> - - - function showRedirect(){ - var radioElements = document.getElementsByName("radioButton"); - console.log("${path}"); - for (var i=0; i < radioElements.length; i++) - if(radioElements[i].checked == true) { - var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}")); - if ("${select}" == "false") - window.location.href=pathHeader+"${path}/"+radioElements[i].value; - else { - var str = "${pathShow}"; - pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("programas/")); - window.location.href=pathHeader+str+"/"+radioElements[i].value; - } - } - } - - function updateRedirect(){ - var radioElements = document.getElementsByName("radioButton"); - - for (var i=0; i < radioElements.length; i++) - if(radioElements[i].checked == true) { - var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}")); - var form = "${path}".indexOf("ocorrenciamunicipais") != -1 ? "?formUpdate" : "?form"; - window.location.href=pathHeader+"${path}/"+radioElements[i].value+form; - } - } - - function deleteRedirect(){ - var radioElements = document.getElementsByName("radioButton"); - - for (var i=0; i < radioElements.length; i++) - if(radioElements[i].checked == true) { - var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}")); - document.deleteForm.action = pathHeader+"${path}/"+radioElements[i].value; - return confirm('${delete_confirm_msg}'); - } - } - - function post(){ - var form = document.getElementById("programa") == null ? document.getElementById("ocorrenciaMunicipal") : document.getElementById("programa"); - console.log(form); - form.action = selectRedirect(); - form.submit(); - - } - - function selectRedirect(){ - var radioElements = document.getElementsByName("radioButton"); - var selected =""; - - for (var i=0; i < radioElements.length; i++){ - if(radioElements[i].checked == true) { - selected += radioElements[i].value + "+"; - } - } - - selected = selected.substring(0,selected.lastIndexOf("+")); - - var progIndex = window.location.pathname.indexOf("/programas"); - if(progIndex == -1){ - progIndex = window.location.pathname.indexOf("/ocorrenciamunicipais"); - var pathHeader = window.location.pathname.substring(0,progIndex)+"/ocorrenciamunicipais"; - }else{ - var pathHeader = window.location.pathname.substring(0,progIndex)+"/programas"; - } - - pathHeader = pathHeader.charAt(pathHeader.length - 1) == "/" ? pathHeader.slice(0,pathHeader.length-1) : pathHeader; - if(window.location.pathname.indexOf("pesquisa") != -1){ - pathHeader += "/pesquisa"; - } - var form = ""; - if("${Itinerante}"=="true"){ - form = "/formItinerante/"; - }else{ - form = "/form/"; - } - return pathHeader+form+selected; - } - - - </script> - </c:if> </jsp:root> \ No newline at end of file