Commit 85cc3d2d12c27b83779b5e5a697dc3fa4b04a1dc
1 parent
3e5878d4
Exists in
master
and in
7 other branches
Reorganização do layout do editor de menus
Showing
5 changed files
with
106 additions
and
49 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin1/catalogo/menus/exec.php
... | ... | @@ -31,7 +31,9 @@ include_once (dirname ( __FILE__ ) . "/../../../admin/php/login.php"); |
31 | 31 | $funcoesEdicao = array ( |
32 | 32 | "ADICIONAR", |
33 | 33 | "ALTERAR", |
34 | - "EXCLUIR" | |
34 | + "EXCLUIR", | |
35 | + "LISTA", | |
36 | + "LISTAUNICO" | |
35 | 37 | ); |
36 | 38 | if (in_array ( strtoupper ( $funcao ), $funcoesEdicao )) { |
37 | 39 | if (verificaOperacaoSessao ( "admin/html/arvore" ) === false) { |
... | ... | @@ -74,8 +76,21 @@ switch ($funcao) { |
74 | 76 | retornaJSON ( $dados ); |
75 | 77 | exit (); |
76 | 78 | break; |
79 | + case "LISTAUNICO" : | |
80 | + $dados = pegaDados ( "SELECT id_menu, publicado_menu, perfil_menu, aberto, desc_menu, nome_menu, es, en from ".$esquemaadmin."i3geoadmin_menus WHERE id_menu = $id_menu ", $dbh, false ); | |
81 | + if ($dados === false) { | |
82 | + $dbhw = null; | |
83 | + $dbh = null; | |
84 | + header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); | |
85 | + exit (); | |
86 | + } | |
87 | + $perfis = pegaDados ( "SELECT id_perfil, perfil from ".$esquemaadmin."i3geoadmin_perfis order by perfil", $dbh, false ); | |
88 | + $dbhw = null; | |
89 | + $dbh = null; | |
90 | + retornaJSON ( array("dados"=>$dados[0], "perfis"=>$perfis) ); | |
91 | + break; | |
77 | 92 | case "LISTA" : |
78 | - $dados = pegaDados ( "SELECT id_menu, publicado_menu, perfil_menu, aberto, desc_menu, nome_menu, es, en from ".$esquemaadmin."i3geoadmin_menus order by lower(nome_menu)", $dbh, false ); | |
93 | + $dados = pegaDados ( "SELECT id_menu, nome_menu from ".$esquemaadmin."i3geoadmin_menus order by lower(nome_menu)", $dbh, false ); | |
79 | 94 | if ($dados === false) { |
80 | 95 | $dbhw = null; |
81 | 96 | $dbh = null; | ... | ... |
admin1/catalogo/menus/index.js
... | ... | @@ -27,6 +27,8 @@ i3GEOadmin.menus = { |
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.menus.ondeLista = onde; |
32 | 34 | i3GEOadmin.menus.lista(); |
... | ... | @@ -49,7 +51,6 @@ Obtém a lista de menus |
49 | 51 | var json = jQuery.parseJSON(data); |
50 | 52 | //template do form de cada operacao |
51 | 53 | var templateLista = $("#templateLista").html(); |
52 | - templateLista = templateLista.replace("{{{templateFormLista}}}",$("#templateFormLista").html()); | |
53 | 54 | //combo com perfis |
54 | 55 | var opcoesPerfil = '<option value="">---</option>' + Mustache.to_html( |
55 | 56 | "{{#data}}" + $("#templateOpcoesPerfil").html() + "{{/data}}", |
... | ... | @@ -64,28 +65,7 @@ Obt&eacute;m a lista de menus |
64 | 65 | { |
65 | 66 | "data": json["dados"], |
66 | 67 | "onExcluir": "i3GEOadmin.menus.excluirDialogo",//funcao |
67 | - "onSalvar": "i3GEOadmin.menus.salvarDialogo",//funcao | |
68 | - "opcoesAberto": function(){ | |
69 | - var hash = {}; | |
70 | - hash[this.aberto + "-sel"] = "selected"; | |
71 | - hash["sim"] = i3GEOadmin.menus.dicionario.sim; | |
72 | - hash["nao"] = i3GEOadmin.menus.dicionario.nao; | |
73 | - return Mustache.to_html( | |
74 | - $("#templateOpcoesAberto").html(), | |
75 | - hash | |
76 | - ); | |
77 | - }, | |
78 | - "opcoesPublicado": function(){ | |
79 | - var hash = {}; | |
80 | - hash[this.publicado_menu + "-sel"] = "selected"; | |
81 | - hash["sim"] = i3GEOadmin.menus.dicionario.sim; | |
82 | - hash["nao"] = i3GEOadmin.menus.dicionario.nao; | |
83 | - return Mustache.to_html( | |
84 | - $("#templateOpcoesPublicado").html(), | |
85 | - hash | |
86 | - ); | |
87 | - }, | |
88 | - "opcoesPerfil": opcoesPerfil | |
68 | + "onEditar": "i3GEOadmin.menus.editarDialogo" | |
89 | 69 | } |
90 | 70 | ) |
91 | 71 | ); |
... | ... | @@ -148,6 +128,66 @@ Obt&eacute;m a lista de menus |
148 | 128 | i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); |
149 | 129 | }); |
150 | 130 | }, |
131 | + editarDialogo: function(id){ | |
132 | + i3GEOadmin.core.fechaModalGeral(); | |
133 | + i3GEOadmin.core.modalAguarde(true); | |
134 | + $.post( | |
135 | + "exec.php?funcao=listaunico", | |
136 | + "id_menu=" + id | |
137 | + ) | |
138 | + .done( | |
139 | + function(data, status){ | |
140 | + var json = jQuery.parseJSON(data); | |
141 | + var templateLista = $("#templateFormLista").html(); | |
142 | + //combo com perfis | |
143 | + var opcoesPerfil = '<option value="">---</option>' + Mustache.to_html( | |
144 | + "{{#data}}" + $("#templateOpcoesPerfil").html() + "{{/data}}", | |
145 | + {"data":json["perfis"]} | |
146 | + ); | |
147 | + //lista todas as menus | |
148 | + var html = Mustache.to_html( | |
149 | + "{{#data}}" + templateLista + "{{/data}}", | |
150 | + $.extend( | |
151 | + {}, | |
152 | + i3GEOadmin.menus.dicionario, | |
153 | + { | |
154 | + "data": json["dados"], | |
155 | + "onExcluir": "i3GEOadmin.menus.excluirDialogo",//funcao | |
156 | + "onSalvar": "i3GEOadmin.menus.salvarDialogo",//funcao | |
157 | + "opcoesAberto": function(){ | |
158 | + var hash = {}; | |
159 | + hash[this.aberto + "-sel"] = "selected"; | |
160 | + hash["sim"] = i3GEOadmin.menus.dicionario.sim; | |
161 | + hash["nao"] = i3GEOadmin.menus.dicionario.nao; | |
162 | + return Mustache.to_html( | |
163 | + $("#templateOpcoesAberto").html(), | |
164 | + hash | |
165 | + ); | |
166 | + }, | |
167 | + "opcoesPublicado": function(){ | |
168 | + var hash = {}; | |
169 | + hash[this.publicado_menu + "-sel"] = "selected"; | |
170 | + hash["sim"] = i3GEOadmin.menus.dicionario.sim; | |
171 | + hash["nao"] = i3GEOadmin.menus.dicionario.nao; | |
172 | + return Mustache.to_html( | |
173 | + $("#templateOpcoesPublicado").html(), | |
174 | + hash | |
175 | + ); | |
176 | + }, | |
177 | + "opcoesPerfil": opcoesPerfil | |
178 | + } | |
179 | + ) | |
180 | + ); | |
181 | + i3GEOadmin.core.abreModalGeral(html); | |
182 | + } | |
183 | + ) | |
184 | + .fail( | |
185 | + function(data){ | |
186 | + i3GEOadmin.core.modalAguarde(false); | |
187 | + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); | |
188 | + } | |
189 | + ); | |
190 | + }, | |
151 | 191 | adicionaDialogo: function(){ |
152 | 192 | i3GEOadmin.core.abreModalGeral(i3GEOadmin.menus.formAdiciona); |
153 | 193 | }, |
... | ... | @@ -205,17 +245,18 @@ Obt&eacute;m a lista de menus |
205 | 245 | ); |
206 | 246 | }, |
207 | 247 | salvarDialogo: function(id){ |
248 | + i3GEOadmin.menus.parametrosSalvar = $("#form-edicao-" + id).serialize(); | |
208 | 249 | var hash = { |
209 | 250 | "mensagem": i3GEOadmin.menus.dicionario.confirma, |
210 | 251 | "onBotao1": "i3GEOadmin.menus.salvar('"+id+"')", |
211 | 252 | "botao1": i3GEOadmin.menus.dicionario.sim, |
212 | - "onBotao2": "i3GEOadmin.core.fechaModalConfirma();", | |
253 | + "onBotao2": "i3GEOadmin.menus.parametrosSalvar = '';i3GEOadmin.core.fechaModalConfirma();", | |
213 | 254 | "botao2": i3GEOadmin.menus.dicionario.nao |
214 | 255 | }; |
215 | 256 | i3GEOadmin.core.abreModalConfirma(hash); |
216 | 257 | }, |
217 | 258 | salvar: function(id){ |
218 | - var parametros = $("#form-" + id + " form").serialize(); | |
259 | + var parametros = i3GEOadmin.menus.parametrosSalvar; | |
219 | 260 | i3GEOadmin.core.fechaModalGeral(); |
220 | 261 | i3GEOadmin.core.modalAguarde(true); |
221 | 262 | $.post( |
... | ... | @@ -224,6 +265,7 @@ Obt&eacute;m a lista de menus |
224 | 265 | ) |
225 | 266 | .done( |
226 | 267 | function(data, status){ |
268 | + i3GEOadmin.menus.parametrosSalvar = ''; | |
227 | 269 | i3GEOadmin.core.modalAguarde(false); |
228 | 270 | i3GEOadmin.core.iconeAguarde(i3GEOadmin.menus.ondeLista); |
229 | 271 | i3GEOadmin.menus.lista(); |
... | ... | @@ -231,6 +273,7 @@ Obt&eacute;m a lista de menus |
231 | 273 | ) |
232 | 274 | .fail( |
233 | 275 | function(data){ |
276 | + i3GEOadmin.menus.parametrosSalvar = ''; | |
234 | 277 | i3GEOadmin.core.modalAguarde(false); |
235 | 278 | i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); |
236 | 279 | } | ... | ... |
admin1/catalogo/menus/index.php
... | ... | @@ -62,7 +62,7 @@ include "../../head.php"; |
62 | 62 | <option value="form-{{id_menu}}">{{{nome_menu}}}</option> |
63 | 63 | </script> |
64 | 64 | <script id="templateFormLista" type="x-tmpl-mustache"> |
65 | -<form style="" action="#" onsubmit="{{onSalvar}}('{{id_menu}}');return false;" onchange="this.style.boxShadow='2px 2px 5px 0 #009688';" class="form-horizontal" | |
65 | +<form id="form-edicao-{{id_menu}}" style="" action="#" onsubmit="{{onSalvar}}('{{id_menu}}');return false;" onchange="this.style.boxShadow='2px 2px 5px 0 #009688';" class="form-horizontal" | |
66 | 66 | role="form" method="post" > |
67 | 67 | <div class="row"> |
68 | 68 | <div class="col-md-12"> |
... | ... | @@ -126,28 +126,27 @@ include "../../head.php"; |
126 | 126 | </form> |
127 | 127 | </script> |
128 | 128 | <script id="templateLista" type="x-tmpl-mustache"> |
129 | -<div class="panel panel-default" id="form-{{id_menu}}"> | |
130 | - <div class="panel-heading icon" role="tab"> | |
131 | - <h3 class="panel-title {{escondido}}"> | |
132 | - <a href="javascript:void(0)" onclick="{{onExcluir}}('{{id_menu}}')" class="btn btn-danger btn-fab btn-fab-mini" role="button"> | |
133 | - <i class="material-icons">delete_forever</i> | |
129 | +<div class="list-group-item" id="form-{{id_menu}}"> | |
130 | + <div class="row-content"> | |
131 | + <h3 class="list-group-item-heading {{escondido}}"> | |
132 | + {{{nome_menu}}} | |
133 | + <div class="pull-right"> | |
134 | + <a role="button" class="btn btn-danger btn-fab btn-fab-mini pull-left" onclick="i3GEOadmin.menus.editarGrupos('{{id_menu}}','{{{nome_menu}}}')" href="javascript:void(0)"> | |
135 | + <i class="material-icons md-18">folder_open</i> | |
136 | + </a> | |
137 | + <label class=pull-right><h6 style="margin-top: 5px; margin-bottom: 5px;"> {{{txtGrupo}}}</h6></label> | |
138 | + </div> | |
139 | + <span class="pull-right"> </span> | |
140 | + <a href="javascript:void(0)" onclick="{{onEditar}}('{{id_menu}}')" class="btn btn-danger btn-fab btn-fab-mini pull-right" role="button"> | |
141 | + <i class="material-icons md-18">edit</i> | |
142 | + </a> | |
143 | + <span class="pull-right"> </span> | |
144 | + <a href="javascript:void(0)" onclick="{{onExcluir}}('{{id_menu}}')" class="btn btn-danger btn-fab btn-fab-mini pull-right" role="button"> | |
145 | + <i class="material-icons md-18">delete_forever</i> | |
134 | 146 | </a> |
135 | - | |
136 | - <a class="collapsed in" role="button" data-toggle="collapse" href="#body-form-{{id_menu}}" | |
137 | - aria-expanded="false" aria-controls="#body-form-{{id_menu}}"> {{{nome_menu}}} </a> | |
138 | 147 | </h3> |
139 | 148 | </div> |
140 | - <div class="panel-body panel-collapse collapse" id="body-form-{{id_menu}}"> | |
141 | - {{{templateFormLista}}} | |
142 | - </div> | |
143 | - <div class="panel-footer {{{escondido}}}" style="padding-top: 0px; padding-bottom: 0px;"> | |
144 | - <div class="pull-right"> | |
145 | - <button style="color:#007a6f;" onclick="i3GEOadmin.menus.editarGrupos('{{id_menu}}','{{{nome_menu}}}')" class="btn btn-primary btn-xs" style="margin-top: 2px; margin-bottom: 2px;"> | |
146 | - <i class="material-icons">folder_open</i> {{{grupos}}} | |
147 | - </button> | |
148 | - </div> | |
149 | - <div class="clearfix"></div> | |
150 | - </div> | |
149 | + <div class="list-group-separator"></div> | |
151 | 150 | </div> |
152 | 151 | </script> |
153 | 152 | <script id="templateOpcoesPerfil" type="x-tmpl-mustache"> | ... | ... |