Commit 2e9e942676bc67a7fbe5015a50b6e9fa6b5a6e91
1 parent
39a98c38
Exists in
master
and in
7 other branches
Reorganização do layout do editor de perfis
Showing
4 changed files
with
110 additions
and
36 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin1/catalogo/mapas/exec.php
| ... | ... | @@ -32,7 +32,9 @@ $funcoesEdicao = array ( |
| 32 | 32 | "ADICIONAR", |
| 33 | 33 | "ALTERAR", |
| 34 | 34 | "EXCLUIR", |
| 35 | - "LIMPACACHE" | |
| 35 | + "LIMPACACHE", | |
| 36 | + "LISTA", | |
| 37 | + "LISTAUNICO" | |
| 36 | 38 | ); |
| 37 | 39 | if (in_array ( strtoupper ( $funcao ), $funcoesEdicao )) { |
| 38 | 40 | if (verificaOperacaoSessao ( "admin/html/mapas" ) === false) { |
| ... | ... | @@ -74,10 +76,12 @@ switch ($funcao) { |
| 74 | 76 | retornaJSON ( $dados ); |
| 75 | 77 | exit (); |
| 76 | 78 | break; |
| 77 | - case "LISTA" : | |
| 78 | - $semmapfile = pegaDados ( "SELECT id_mapa, publicado_mapa, ordem_mapa, perfil_mapa, ligados_mapa, temas_mapa, desc_mapa, ext_mapa, imagem_mapa, linkdireto_mapa, nome_mapa, outros_mapa, 'nao' as contemmapfile from " . $esquemaadmin . "i3geoadmin_mapas where mapfile = '' or mapfile is null order by ordem_mapa, lower(nome_mapa)", $dbh, false ); | |
| 79 | - $commapfile = pegaDados ( "SELECT id_mapa, publicado_mapa, ordem_mapa, perfil_mapa, ligados_mapa, temas_mapa, desc_mapa, ext_mapa, imagem_mapa, linkdireto_mapa, nome_mapa, outros_mapa, 'sim' as contemmapfile from " . $esquemaadmin . "i3geoadmin_mapas where mapfile != '' and mapfile is not null order by ordem_mapa, lower(nome_mapa)", $dbh, false ); | |
| 80 | - if ($semmapfile === false || $commapfile === false) { | |
| 79 | + case "LISTAUNICO" : | |
| 80 | + $mapfile = pegaDados ( "SELECT id_mapa, publicado_mapa, ordem_mapa, perfil_mapa, ligados_mapa, temas_mapa, desc_mapa, ext_mapa, imagem_mapa, linkdireto_mapa, nome_mapa, outros_mapa, 'nao' as contemmapfile from " . $esquemaadmin . "i3geoadmin_mapas where id_mapa = $id_mapa AND mapfile = '' or mapfile is null ", $dbh, false ); | |
| 81 | + if(count($mapfile) == 0){ | |
| 82 | + $mapfile = pegaDados ( "SELECT id_mapa, publicado_mapa, ordem_mapa, perfil_mapa, ligados_mapa, temas_mapa, desc_mapa, ext_mapa, imagem_mapa, linkdireto_mapa, nome_mapa, outros_mapa, 'sim' as contemmapfile from " . $esquemaadmin . "i3geoadmin_mapas where id_mapa = $id_mapa AND mapfile != '' and mapfile is not null ", $dbh, false ); | |
| 83 | + } | |
| 84 | + if ($mapfile === false) { | |
| 81 | 85 | $dbhw = null; |
| 82 | 86 | $dbh = null; |
| 83 | 87 | header ( "HTTP/1.1 500 erro ao consultar banco de dados tabela de mapas" ); |
| ... | ... | @@ -91,11 +95,32 @@ switch ($funcao) { |
| 91 | 95 | $arvore = new Arvore ( $locaplic ); |
| 92 | 96 | $temas = $arvore->pegaTodosTemas ( true ); |
| 93 | 97 | retornaJSON ( array ( |
| 94 | - "dados" => array_merge ( $semmapfile, $commapfile ), | |
| 98 | + "dados" => $mapfile[0], | |
| 95 | 99 | "perfis" => $perfis, |
| 96 | 100 | "temas" => $temas |
| 97 | 101 | ) ); |
| 98 | 102 | break; |
| 103 | + case "LISTA" : | |
| 104 | + $mapfiles = pegaDados ( "SELECT id_mapa, nome_mapa from " . $esquemaadmin . "i3geoadmin_mapas order by ordem_mapa, lower(nome_mapa)", $dbh, false ); | |
| 105 | + if ($mapfiles === false) { | |
| 106 | + $dbhw = null; | |
| 107 | + $dbh = null; | |
| 108 | + header ( "HTTP/1.1 500 erro ao consultar banco de dados tabela de mapas" ); | |
| 109 | + exit (); | |
| 110 | + } | |
| 111 | + $perfis = pegaDados ( "SELECT id_perfil, perfil from " . $esquemaadmin . "i3geoadmin_perfis order by perfil", $dbh, false ); | |
| 112 | + $dbhw = null; | |
| 113 | + $dbh = null; | |
| 114 | + // pega a lista de temas | |
| 115 | + include ("../../../admin/php/classe_arvore.php"); | |
| 116 | + $arvore = new Arvore ( $locaplic ); | |
| 117 | + $temas = $arvore->pegaTodosTemas ( true ); | |
| 118 | + retornaJSON ( array ( | |
| 119 | + "dados" => $mapfiles, | |
| 120 | + "perfis" => $perfis, | |
| 121 | + "temas" => $temas | |
| 122 | + ) ); | |
| 123 | + break; | |
| 99 | 124 | case "EXCLUIR" : |
| 100 | 125 | $retorna = excluir ( $id_mapa, $dbhw ); |
| 101 | 126 | $dbhw = null; | ... | ... |
admin1/catalogo/mapas/index.js
| ... | ... | @@ -27,6 +27,8 @@ i3GEOadmin.mapas = { |
| 27 | 27 | ondeLista: "", |
| 28 | 28 | //conteudo html do formulario de adicao de operacao |
| 29 | 29 | formAdiciona: "", |
| 30 | + //parametros obtidos do formulario de edicao antes de abrir o modal de confirmacao | |
| 31 | + parametrosSalvar: "", | |
| 30 | 32 | init: function(onde){ |
| 31 | 33 | i3GEOadmin.mapas.ondeLista = onde; |
| 32 | 34 | i3GEOadmin.mapas.lista(); |
| ... | ... | @@ -69,22 +71,7 @@ Obtém a lista |
| 69 | 71 | { |
| 70 | 72 | "data": json["dados"], |
| 71 | 73 | "onExcluir": "i3GEOadmin.mapas.excluirDialogo",//funcao |
| 72 | - "onSalvar": "i3GEOadmin.mapas.salvarDialogo",//funcao | |
| 73 | - "opcoesPublicado": function(){ | |
| 74 | - var hash = {}; | |
| 75 | - hash["sim"] = i3GEOadmin.mapas.dicionario.sim; | |
| 76 | - hash["nao"] = i3GEOadmin.mapas.dicionario.nao; | |
| 77 | - if(this.publicado_mapa == ""){ | |
| 78 | - this.publicado_mapa = "SIM"; | |
| 79 | - } | |
| 80 | - hash[this.publicado_mapa + "-sel"] = "selected"; | |
| 81 | - return Mustache.to_html( | |
| 82 | - $("#templateOpcoesPublicado").html(), | |
| 83 | - hash | |
| 84 | - ); | |
| 85 | - }, | |
| 86 | - "opcoesPerfil": opcoesPerfil, | |
| 87 | - "opcoesTema": opcoesTema | |
| 74 | + "onEditar": "i3GEOadmin.mapas.editarDialogo" | |
| 88 | 75 | } |
| 89 | 76 | ) |
| 90 | 77 | ); |
| ... | ... | @@ -139,6 +126,65 @@ Obtém a lista |
| 139 | 126 | i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); |
| 140 | 127 | }); |
| 141 | 128 | }, |
| 129 | + editarDialogo: function(id){ | |
| 130 | + i3GEOadmin.core.fechaModalGeral(); | |
| 131 | + i3GEOadmin.core.modalAguarde(true); | |
| 132 | + $.post( | |
| 133 | + "exec.php?funcao=listaunico", | |
| 134 | + "id_mapa=" + id | |
| 135 | + ) | |
| 136 | + .done( | |
| 137 | + function(data, status){ | |
| 138 | + var json = jQuery.parseJSON(data); | |
| 139 | + var templateLista = $("#templateFormLista").html(); | |
| 140 | + //combo com temas | |
| 141 | + var opcoesTema = '<option value="">---</option>' + Mustache.to_html( | |
| 142 | + "{{#data}}" + $("#templateTemas").html() + "{{/data}}", | |
| 143 | + {"data":json["temas"]} | |
| 144 | + ); | |
| 145 | + //combo com perfis | |
| 146 | + var opcoesPerfil = '<option value="">---</option>' + Mustache.to_html( | |
| 147 | + "{{#data}}" + $("#templateOpcoesPerfil").html() + "{{/data}}", | |
| 148 | + {"data":json["perfis"]} | |
| 149 | + ); | |
| 150 | + //lista todas as menus | |
| 151 | + var html = Mustache.to_html( | |
| 152 | + "{{#data}}" + templateLista + "{{/data}}", | |
| 153 | + $.extend( | |
| 154 | + {}, | |
| 155 | + i3GEOadmin.mapas.dicionario, | |
| 156 | + { | |
| 157 | + "data": json["dados"], | |
| 158 | + "onExcluir": "i3GEOadmin.mapas.excluirDialogo",//funcao | |
| 159 | + "onSalvar": "i3GEOadmin.mapas.salvarDialogo",//funcao | |
| 160 | + "opcoesPublicado": function(){ | |
| 161 | + var hash = {}; | |
| 162 | + hash["sim"] = i3GEOadmin.mapas.dicionario.sim; | |
| 163 | + hash["nao"] = i3GEOadmin.mapas.dicionario.nao; | |
| 164 | + if(this.publicado_mapa == ""){ | |
| 165 | + this.publicado_mapa = "SIM"; | |
| 166 | + } | |
| 167 | + hash[this.publicado_mapa + "-sel"] = "selected"; | |
| 168 | + return Mustache.to_html( | |
| 169 | + $("#templateOpcoesPublicado").html(), | |
| 170 | + hash | |
| 171 | + ); | |
| 172 | + }, | |
| 173 | + "opcoesPerfil": opcoesPerfil, | |
| 174 | + "opcoesTema": opcoesTema | |
| 175 | + } | |
| 176 | + ) | |
| 177 | + ); | |
| 178 | + i3GEOadmin.core.abreModalGeral(html); | |
| 179 | + } | |
| 180 | + ) | |
| 181 | + .fail( | |
| 182 | + function(data){ | |
| 183 | + i3GEOadmin.core.modalAguarde(false); | |
| 184 | + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); | |
| 185 | + } | |
| 186 | + ); | |
| 187 | + }, | |
| 142 | 188 | adicionaDialogo: function(){ |
| 143 | 189 | i3GEOadmin.core.abreModalGeral(i3GEOadmin.mapas.formAdiciona); |
| 144 | 190 | }, |
| ... | ... | @@ -196,17 +242,18 @@ Obt&eacute;m a lista |
| 196 | 242 | ); |
| 197 | 243 | }, |
| 198 | 244 | salvarDialogo: function(id){ |
| 245 | + i3GEOadmin.mapas.parametrosSalvar = $("#form-edicao-" + id).serialize(); | |
| 199 | 246 | var hash = { |
| 200 | 247 | "mensagem": i3GEOadmin.mapas.dicionario.confirma, |
| 201 | 248 | "onBotao1": "i3GEOadmin.mapas.salvar('"+id+"')", |
| 202 | 249 | "botao1": i3GEOadmin.mapas.dicionario.sim, |
| 203 | - "onBotao2": "i3GEOadmin.core.fechaModalConfirma();", | |
| 250 | + "onBotao2": "i3GEOadmin.mapas.parametrosSalvar = '';i3GEOadmin.core.fechaModalConfirma();", | |
| 204 | 251 | "botao2": i3GEOadmin.mapas.dicionario.nao |
| 205 | 252 | }; |
| 206 | 253 | i3GEOadmin.core.abreModalConfirma(hash); |
| 207 | 254 | }, |
| 208 | 255 | salvar: function(id){ |
| 209 | - var parametros = $("#form-" + id + " form").serialize(); | |
| 256 | + var parametros = i3GEOadmin.mapas.parametrosSalvar; | |
| 210 | 257 | i3GEOadmin.core.fechaModalGeral(); |
| 211 | 258 | i3GEOadmin.core.modalAguarde(true); |
| 212 | 259 | $.post( |
| ... | ... | @@ -215,6 +262,7 @@ Obt&eacute;m a lista |
| 215 | 262 | ) |
| 216 | 263 | .done( |
| 217 | 264 | function(data, status){ |
| 265 | + i3GEOadmin.mapas.parametrosSalvar = ''; | |
| 218 | 266 | i3GEOadmin.core.modalAguarde(false); |
| 219 | 267 | i3GEOadmin.core.iconeAguarde(i3GEOadmin.mapas.ondeLista); |
| 220 | 268 | i3GEOadmin.mapas.lista(); |
| ... | ... | @@ -222,6 +270,7 @@ Obt&eacute;m a lista |
| 222 | 270 | ) |
| 223 | 271 | .fail( |
| 224 | 272 | function(data){ |
| 273 | + i3GEOadmin.mapas.parametrosSalvar = ''; | |
| 225 | 274 | i3GEOadmin.core.modalAguarde(false); |
| 226 | 275 | i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); |
| 227 | 276 | } | ... | ... |
admin1/catalogo/mapas/index.php
| ... | ... | @@ -56,7 +56,7 @@ include "../../head.php"; |
| 56 | 56 | <option value="form-{{id_mapa}}">{{{nome_mapa}}}</option> |
| 57 | 57 | </script> |
| 58 | 58 | <script id="templateFormLista" type="x-tmpl-mustache"> |
| 59 | -<form style="" action="#" onsubmit="{{onSalvar}}('{{id_mapa}}');return false;" onchange="this.style.boxShadow='2px 2px 5px 0 #009688';" class="form-horizontal" role="form" method="post" > | |
| 59 | +<form id="form-edicao-{{id_mapa}}" style="" action="#" onsubmit="{{onSalvar}}('{{id_mapa}}');return false;" onchange="this.style.boxShadow='2px 2px 5px 0 #009688';" class="form-horizontal" role="form" method="post" > | |
| 60 | 60 | <div class="row"> |
| 61 | 61 | <div class="col-md-12"> |
| 62 | 62 | <div class="form-group form-group-lg"> |
| ... | ... | @@ -162,20 +162,20 @@ include "../../head.php"; |
| 162 | 162 | </form> |
| 163 | 163 | </script> |
| 164 | 164 | <script id="templateLista" type="x-tmpl-mustache"> |
| 165 | -<div class="panel panel-default" id="form-{{id_mapa}}"> | |
| 166 | - <div class="panel-heading icon" role="tab"> | |
| 167 | - <h3 class="panel-title {{escondido}}"> | |
| 168 | - <a href="javascript:void(0)" onclick="{{onExcluir}}('{{id_mapa}}')" class="btn btn-danger btn-fab btn-fab-mini" role="button"> | |
| 169 | - <i class="material-icons">delete_forever</i> | |
| 165 | +<div class="list-group-item" id="form-{{id_mapa}}"> | |
| 166 | + <div class="row-content"> | |
| 167 | + <h3 class="list-group-item-heading {{escondido}}"> | |
| 168 | + {{{nome_mapa}}} | |
| 169 | + <a href="javascript:void(0)" onclick="{{onEditar}}('{{id_mapa}}')" class="btn btn-danger btn-fab btn-fab-mini pull-right" role="button"> | |
| 170 | + <i class="material-icons md-18">edit</i> | |
| 171 | + </a> | |
| 172 | + <span class="pull-right"> </span> | |
| 173 | + <a href="javascript:void(0)" onclick="{{onExcluir}}('{{id_mapa}}')" class="btn btn-danger btn-fab btn-fab-mini pull-right" role="button"> | |
| 174 | + <i class="material-icons md-18">delete_forever</i> | |
| 170 | 175 | </a> |
| 171 | - | |
| 172 | - <a class="collapsed in" role="button" data-toggle="collapse" href="#body-form-{{id_mapa}}" | |
| 173 | - aria-expanded="false" aria-controls="#body-form-{{id_mapa}}"> {{{nome_mapa}}} </a> | |
| 174 | 176 | </h3> |
| 175 | 177 | </div> |
| 176 | - <div class="panel-body panel-collapse collapse" id="body-form-{{id_mapa}}"> | |
| 177 | - {{{templateFormLista}}} | |
| 178 | - </div> | |
| 178 | + <div class="list-group-separator"></div> | |
| 179 | 179 | </div> |
| 180 | 180 | </script> |
| 181 | 181 | <script id="templateTemas" type="x-tmpl-mustache"> | ... | ... |