Commit 055e8ac801258e07f869371d9a2e398e14528a0b
1 parent
4aa53048
Exists in
master
and in
7 other branches
Inclusão de função de ordenação na edição da árvore do catálogo
Showing
10 changed files
with
200 additions
and
15 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin1/cadastros/perfis/index.php
| ... | ... | @@ -62,7 +62,7 @@ include "../../head.php"; |
| 62 | 62 | <div class="panel panel-default" id="form-{{id_perfil}}"> |
| 63 | 63 | <div class="panel-body"> |
| 64 | 64 | <div class="row"> |
| 65 | - <div class="col-md-7"> | |
| 65 | + <div class="col-md-12"> | |
| 66 | 66 | <form style="" onchange="this.style.boxShadow='2px 2px 5px 0 #009688';" class="form-horizontal" role="form" |
| 67 | 67 | method="post" > |
| 68 | 68 | <div class="form-group form-group-lg"> |
| ... | ... | @@ -72,14 +72,13 @@ include "../../head.php"; |
| 72 | 72 | </div> |
| 73 | 73 | </div> |
| 74 | 74 | </form> |
| 75 | - </div> | |
| 76 | - <div class="col-md-5"> | |
| 77 | 75 | <div class="pull-right"> |
| 78 | 76 | <a href="javascript:void(0)" onclick="{{onExcluir}}('{{id_perfil}}')" class="btn btn-danger" |
| 79 | 77 | role="button">{{excluir}}</a> |
| 80 | 78 | <a href="javascript:void(0)" |
| 81 | 79 | onclick="{{onSalvar}}('{{id_perfil}}')" class="btn btn-primary" role="button">{{salvar}}</a> |
| 82 | 80 | </div> |
| 81 | + | |
| 83 | 82 | </div> |
| 84 | 83 | </div> |
| 85 | 84 | </div> | ... | ... |
admin1/cadastros/tags/index.php
| ... | ... | @@ -62,7 +62,7 @@ include "../../head.php"; |
| 62 | 62 | <div class="panel panel-default" id="form-{{id_tag}}"> |
| 63 | 63 | <div class="panel-body"> |
| 64 | 64 | <div class="row"> |
| 65 | - <div class="col-md-7"> | |
| 65 | + <div class="col-md-12"> | |
| 66 | 66 | <form style="" onchange="this.style.boxShadow='2px 2px 5px 0 #009688';" class="form-horizontal" role="form" |
| 67 | 67 | method="post" > |
| 68 | 68 | <div class="form-group form-group-lg"> |
| ... | ... | @@ -72,8 +72,6 @@ include "../../head.php"; |
| 72 | 72 | </div> |
| 73 | 73 | </div> |
| 74 | 74 | </form> |
| 75 | - </div> | |
| 76 | - <div class="col-md-5"> | |
| 77 | 75 | <div class="pull-right"> |
| 78 | 76 | <a href="javascript:void(0)" onclick="{{onExcluir}}('{{id_tag}}')" class="btn btn-danger" |
| 79 | 77 | role="button">{{excluir}}</a> | ... | ... |
admin1/catalogo/menus/grupos/subgrupos/exec.php
| ... | ... | @@ -34,7 +34,8 @@ include_once (dirname ( __FILE__ ) . "/../../../../../admin/php/login.php"); |
| 34 | 34 | $funcoesEdicao = array ( |
| 35 | 35 | "ADICIONAR", |
| 36 | 36 | "ALTERAR", |
| 37 | - "EXCLUIR" | |
| 37 | + "EXCLUIR", | |
| 38 | + "ORDENA" | |
| 38 | 39 | ); |
| 39 | 40 | if (in_array ( strtoupper ( $funcao ), $funcoesEdicao )) { |
| 40 | 41 | if (verificaOperacaoSessao ( "admin/html/arvore" ) === false) { |
| ... | ... | @@ -46,6 +47,31 @@ include (dirname ( __FILE__ ) . "/../../../../../admin/php/conexao.php"); |
| 46 | 47 | |
| 47 | 48 | $funcao = strtoupper ( $funcao ); |
| 48 | 49 | switch ($funcao) { |
| 50 | + case "ORDENA" : | |
| 51 | + $ordem = explode(" ",$ordem); | |
| 52 | + //verifica se existe a mesma quantidade de registros no banco e na lista de ids | |
| 53 | + $dados = pegaDados ( "SELECT ordem from ".$esquemaadmin."i3geoadmin_n2 WHERE id_n1 = $id_n1", $dbh, false ); | |
| 54 | + if(count($dados) != count($ordem)){ | |
| 55 | + header ( "HTTP/1.1 500 erro numero de registros nao batem" ); | |
| 56 | + exit (); | |
| 57 | + } | |
| 58 | + //verifica se os ids existem no mesmo nivel | |
| 59 | + $dados = pegaDados ( "SELECT ordem from ".$esquemaadmin."i3geoadmin_n2 WHERE id_n1 = $id_n1 AND id_n2 IN (" . implode(",",$ordem). ")", $dbh, false ); | |
| 60 | + if(count($dados) != count($ordem)){ | |
| 61 | + header ( "HTTP/1.1 500 erro ids nao batem" ); | |
| 62 | + exit (); | |
| 63 | + } | |
| 64 | + | |
| 65 | + $retorna = i3GeoAdminOrdena($dbhw,$ordem,i3geoadmin_n2,"id_n2"); | |
| 66 | + $dbhw = null; | |
| 67 | + $dbh = null; | |
| 68 | + if ($retorna === false) { | |
| 69 | + header ( "HTTP/1.1 500 erro ao ordenar" ); | |
| 70 | + exit (); | |
| 71 | + } | |
| 72 | + retornaJSON ( $retorna ); | |
| 73 | + exit(); | |
| 74 | + break; | |
| 49 | 75 | case "ADICIONAR" : |
| 50 | 76 | $novo = adicionar( $id_subgrupo, $id_n1, $publicado, $n2_perfil, $ordem, $dbhw ); |
| 51 | 77 | if ($novo === false) { | ... | ... |
admin1/catalogo/menus/grupos/subgrupos/execraiz.php
| ... | ... | @@ -34,7 +34,8 @@ include_once (dirname ( __FILE__ ) . "/../../../../../admin/php/login.php"); |
| 34 | 34 | $funcoesEdicao = array ( |
| 35 | 35 | "ADICIONAR", |
| 36 | 36 | "ALTERAR", |
| 37 | - "EXCLUIR" | |
| 37 | + "EXCLUIR", | |
| 38 | + "ORDENA" | |
| 38 | 39 | ); |
| 39 | 40 | if (in_array ( strtoupper ( $funcao ), $funcoesEdicao )) { |
| 40 | 41 | if (verificaOperacaoSessao ( "admin/html/arvore" ) === false) { |
| ... | ... | @@ -46,6 +47,31 @@ include (dirname ( __FILE__ ) . "/../../../../../admin/php/conexao.php"); |
| 46 | 47 | |
| 47 | 48 | $funcao = strtoupper ( $funcao ); |
| 48 | 49 | switch ($funcao) { |
| 50 | + case "ORDENA" : | |
| 51 | + $ordem = explode(" ",$ordem); | |
| 52 | + //verifica se existe a mesma quantidade de registros no banco e na lista de ids | |
| 53 | + $dados = pegaDados ( "SELECT ordem from ".$esquemaadmin."i3geoadmin_raiz WHERE nivel = 1 AND id_nivel = $id_n1", $dbh, false ); | |
| 54 | + if(count($dados) != count($ordem)){ | |
| 55 | + header ( "HTTP/1.1 500 erro numero de registros nao batem" ); | |
| 56 | + exit (); | |
| 57 | + } | |
| 58 | + //verifica se os ids existem no mesmo nivel | |
| 59 | + $dados = pegaDados ( "SELECT ordem from ".$esquemaadmin."i3geoadmin_raiz WHERE nivel = 1 AND id_nivel = $id_n1 AND id_raiz IN (" . implode(",",$ordem). ")", $dbh, false ); | |
| 60 | + if(count($dados) != count($ordem)){ | |
| 61 | + header ( "HTTP/1.1 500 erro ids nao batem" ); | |
| 62 | + exit (); | |
| 63 | + } | |
| 64 | + | |
| 65 | + $retorna = i3GeoAdminOrdena($dbhw,$ordem,i3geoadmin_raiz,"id_raiz"); | |
| 66 | + $dbhw = null; | |
| 67 | + $dbh = null; | |
| 68 | + if ($retorna === false) { | |
| 69 | + header ( "HTTP/1.1 500 erro ao ordenar" ); | |
| 70 | + exit (); | |
| 71 | + } | |
| 72 | + retornaJSON ( $retorna ); | |
| 73 | + exit(); | |
| 74 | + break; | |
| 49 | 75 | case "ADICIONAR" : |
| 50 | 76 | if (empty ( $id_tema ) || empty ( $id_menu ) || empty ( $id_n1 )) { |
| 51 | 77 | header ( "HTTP/1.1 500 erro nos parametros" ); | ... | ... |
admin1/catalogo/menus/grupos/subgrupos/index.js
| ... | ... | @@ -55,6 +55,31 @@ i3GEOadmin.subgrupos = { |
| 55 | 55 | ); |
| 56 | 56 | i3GEOadmin.subgrupos.listaRaiz(json["raiz"],opcoesPerfil,json["temas"]); |
| 57 | 57 | i3GEOadmin.subgrupos.listaNos(json["subgrupos"],opcoesPerfil,json["tiposSubGrupos"]); |
| 58 | + | |
| 59 | + //torna os paineis ordenavies | |
| 60 | + i3GEOadmin.subgrupos.ondeNos.sortable({ | |
| 61 | + update: function( event, ui ) { | |
| 62 | + var data = i3GEOadmin.subgrupos.ondeNos.sortable('toArray', {attribute: "data-id"}); | |
| 63 | + i3GEOadmin.subgrupos.ordenaNos(data); | |
| 64 | + } | |
| 65 | + }); | |
| 66 | + i3GEOadmin.subgrupos.ondeRaiz.sortable({ | |
| 67 | + update: function( event, ui ) { | |
| 68 | + var data = i3GEOadmin.subgrupos.ondeRaiz.sortable('toArray', {attribute: "data-id"}); | |
| 69 | + i3GEOadmin.subgrupos.ordenaRaiz(data); | |
| 70 | + } | |
| 71 | + }); | |
| 72 | + | |
| 73 | + //faz com que seja mostrado um icone de ordenamento no mouseover | |
| 74 | + $('.panel').hover( | |
| 75 | + function(){ | |
| 76 | + $(this).find('.move').fadeIn(400); | |
| 77 | + }, | |
| 78 | + function(){ | |
| 79 | + $(this).find('.move').fadeOut(250); | |
| 80 | + } | |
| 81 | + ); | |
| 82 | + | |
| 58 | 83 | $.material.init(); |
| 59 | 84 | } |
| 60 | 85 | ) |
| ... | ... | @@ -408,6 +433,46 @@ i3GEOadmin.subgrupos = { |
| 408 | 433 | } |
| 409 | 434 | ); |
| 410 | 435 | }, |
| 436 | + ordenaNos: function(data){ | |
| 437 | + i3GEOadmin.core.modalAguarde(true); | |
| 438 | + $.post( | |
| 439 | + "exec.php?funcao=ordena", | |
| 440 | + "id_n1=" + i3GEOadmin.subgrupos.id_n1 + "&ordem=" + data.join(" ") | |
| 441 | + ) | |
| 442 | + .done( | |
| 443 | + function(data, status){ | |
| 444 | + i3GEOadmin.core.modalAguarde(false); | |
| 445 | + i3GEOadmin.core.iconeAguarde(i3GEOadmin.subgrupos.ondeNos); | |
| 446 | + i3GEOadmin.subgrupos.lista(); | |
| 447 | + } | |
| 448 | + ) | |
| 449 | + .fail( | |
| 450 | + function(data){ | |
| 451 | + i3GEOadmin.core.modalAguarde(false); | |
| 452 | + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); | |
| 453 | + } | |
| 454 | + ); | |
| 455 | + }, | |
| 456 | + ordenaRaiz: function(data){ | |
| 457 | + i3GEOadmin.core.modalAguarde(true); | |
| 458 | + $.post( | |
| 459 | + "execraiz.php?funcao=ordena", | |
| 460 | + "id_n1=" + i3GEOadmin.subgrupos.id_n1 + "&ordem=" + data.join(" ") | |
| 461 | + ) | |
| 462 | + .done( | |
| 463 | + function(data, status){ | |
| 464 | + i3GEOadmin.core.modalAguarde(false); | |
| 465 | + i3GEOadmin.core.iconeAguarde(i3GEOadmin.subgrupos.ondeNos); | |
| 466 | + i3GEOadmin.subgrupos.lista(); | |
| 467 | + } | |
| 468 | + ) | |
| 469 | + .fail( | |
| 470 | + function(data){ | |
| 471 | + i3GEOadmin.core.modalAguarde(false); | |
| 472 | + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); | |
| 473 | + } | |
| 474 | + ); | |
| 475 | + }, | |
| 411 | 476 | editarTemas: function(id,titulo){ |
| 412 | 477 | //muda a url para que o usuario possa voltar pelo botao do navegador |
| 413 | 478 | var u = window.location.origin | ... | ... |
admin1/catalogo/menus/grupos/subgrupos/index.php
| ... | ... | @@ -85,7 +85,7 @@ $nome_menu = filter_var ( $_GET ["nome_menu"], FILTER_SANITIZE_STRING ); |
| 85 | 85 | <option value="formNo-{{id_n2}}">{{{nome_subgrupo}}}</option> |
| 86 | 86 | </script> |
| 87 | 87 | <script id="templateRaiz" type="x-tmpl-mustache"> |
| 88 | -<div class="panel panel-default" id="formRaiz-{{id_raiz}}"> | |
| 88 | +<div class="panel panel-default" data-id="{{id_raiz}}" id="formRaiz-{{id_raiz}}"> | |
| 89 | 89 | <div class="panel-heading" role="tab"> |
| 90 | 90 | <h3 class="panel-title" {{escondido}}> |
| 91 | 91 | <a href="javascript:void(0)" onclick="{{onExcluir}}('{{id_raiz}}')" class="btn btn-danger btn-fab btn-fab-mini" role="button"> |
| ... | ... | @@ -93,7 +93,9 @@ $nome_menu = filter_var ( $_GET ["nome_menu"], FILTER_SANITIZE_STRING ); |
| 93 | 93 | </a> |
| 94 | 94 | |
| 95 | 95 | <a class="collapsed in" role="button" data-toggle="collapse" href="#body-formRaiz-{{id_raiz}}" |
| 96 | - aria-expanded="false" aria-controls="#body-formRaiz-{{id_raiz}}"> {{{nome_tema}}} </a> | |
| 96 | + aria-expanded="false" aria-controls="#body-formRaiz-{{id_raiz}}"> {{{nome_tema}}} | |
| 97 | + <i class="material-icons move" style="color: gray; display:none;">swap_vert</i> | |
| 98 | + </a> | |
| 97 | 99 | </h3> |
| 98 | 100 | </div> |
| 99 | 101 | <div class="panel-body panel-collapse collapse" id="body-formRaiz-{{id_raiz}}"> |
| ... | ... | @@ -136,7 +138,7 @@ $nome_menu = filter_var ( $_GET ["nome_menu"], FILTER_SANITIZE_STRING ); |
| 136 | 138 | </div> |
| 137 | 139 | </script> |
| 138 | 140 | <script id="templateNos" type="x-tmpl-mustache"> |
| 139 | -<div class="panel panel-default" id="formNo-{{id_n2}}"> | |
| 141 | +<div class="panel panel-default" data-id="{{id_n2}}" id="formNo-{{id_n2}}"> | |
| 140 | 142 | <div class="panel-heading" role="tab"> |
| 141 | 143 | <h3 class="panel-title" {{escondido}}> |
| 142 | 144 | <a href="javascript:void(0)" onclick="{{onExcluir}}('{{id_n2}}')" class="btn btn-danger btn-fab btn-fab-mini" role="button"> |
| ... | ... | @@ -144,7 +146,9 @@ $nome_menu = filter_var ( $_GET ["nome_menu"], FILTER_SANITIZE_STRING ); |
| 144 | 146 | </a> |
| 145 | 147 | |
| 146 | 148 | <a class="collapsed in" role="button" data-toggle="collapse" href="#body-formNo-{{id_n2}}" |
| 147 | - aria-expanded="false" aria-controls="#body-formNo-{{id_n2}}"> {{{nome_subgrupo}}} </a> | |
| 149 | + aria-expanded="false" aria-controls="#body-formNo-{{id_n2}}"> {{{nome_subgrupo}}} | |
| 150 | + <i class="material-icons move" style="color: gray; display:none;">swap_vert</i> | |
| 151 | + </a> | |
| 148 | 152 | </h3> |
| 149 | 153 | </div> |
| 150 | 154 | <div class="panel-body panel-collapse collapse" id="body-formNo-{{id_n2}}"> | ... | ... |
admin1/catalogo/menus/grupos/subgrupos/temas/exec.php
| ... | ... | @@ -34,7 +34,8 @@ include_once (dirname ( __FILE__ ) . "/../../../../../../admin/php/login.php"); |
| 34 | 34 | $funcoesEdicao = array ( |
| 35 | 35 | "ADICIONAR", |
| 36 | 36 | "ALTERAR", |
| 37 | - "EXCLUIR" | |
| 37 | + "EXCLUIR", | |
| 38 | + "ORDENA" | |
| 38 | 39 | ); |
| 39 | 40 | if (in_array ( strtoupper ( $funcao ), $funcoesEdicao )) { |
| 40 | 41 | if (verificaOperacaoSessao ( "admin/html/arvore" ) === false) { |
| ... | ... | @@ -46,6 +47,31 @@ include (dirname ( __FILE__ ) . "/../../../../../../admin/php/conexao.php"); |
| 46 | 47 | |
| 47 | 48 | $funcao = strtoupper ( $funcao ); |
| 48 | 49 | switch ($funcao) { |
| 50 | + case "ORDENA" : | |
| 51 | + $ordem = explode(" ",$ordem); | |
| 52 | + //verifica se existe a mesma quantidade de registros no banco e na lista de ids | |
| 53 | + $dados = pegaDados ( "SELECT ordem from ".$esquemaadmin."i3geoadmin_n3 WHERE id_n2 = $id_n2", $dbh, false ); | |
| 54 | + if(count($dados) != count($ordem)){ | |
| 55 | + header ( "HTTP/1.1 500 erro numero de registros nao batem" ); | |
| 56 | + exit (); | |
| 57 | + } | |
| 58 | + //verifica se os ids existem no mesmo nivel | |
| 59 | + $dados = pegaDados ( "SELECT ordem from ".$esquemaadmin."i3geoadmin_n3 WHERE id_n2 = $id_n2 AND id_n3 IN (" . implode(",",$ordem). ")", $dbh, false ); | |
| 60 | + if(count($dados) != count($ordem)){ | |
| 61 | + header ( "HTTP/1.1 500 erro ids nao batem" ); | |
| 62 | + exit (); | |
| 63 | + } | |
| 64 | + | |
| 65 | + $retorna = i3GeoAdminOrdena($dbhw,$ordem,i3geoadmin_n3,"id_n3"); | |
| 66 | + $dbhw = null; | |
| 67 | + $dbh = null; | |
| 68 | + if ($retorna === false) { | |
| 69 | + header ( "HTTP/1.1 500 erro ao ordenar" ); | |
| 70 | + exit (); | |
| 71 | + } | |
| 72 | + retornaJSON ( $retorna ); | |
| 73 | + exit(); | |
| 74 | + break; | |
| 49 | 75 | case "ADICIONAR" : |
| 50 | 76 | $novo = adicionar( $id_tema, $id_n2, $publicado, $n3_perfil, $ordem, $dbhw ); |
| 51 | 77 | if ($novo === false) { | ... | ... |
admin1/catalogo/menus/grupos/subgrupos/temas/index.js
| ... | ... | @@ -67,6 +67,25 @@ i3GEOadmin.temas = { |
| 67 | 67 | i3GEOadmin.core.filtra(i3GEOadmin.core.pegaFiltro()); |
| 68 | 68 | } |
| 69 | 69 | i3GEOadmin.temas.listaTemas(json["dados"],opcoesPerfil,json["temas"]); |
| 70 | + | |
| 71 | + //torna os paineis ordenavies | |
| 72 | + i3GEOadmin.temas.onde.sortable({ | |
| 73 | + update: function( event, ui ) { | |
| 74 | + var data = i3GEOadmin.temas.onde.sortable('toArray', {attribute: "data-id"}); | |
| 75 | + i3GEOadmin.temas.ordena(data); | |
| 76 | + } | |
| 77 | + }); | |
| 78 | + | |
| 79 | + //faz com que seja mostrado um icone de ordenamento no mouseover | |
| 80 | + $('.panel').hover( | |
| 81 | + function(){ | |
| 82 | + $(this).find('.move').fadeIn(400); | |
| 83 | + }, | |
| 84 | + function(){ | |
| 85 | + $(this).find('.move').fadeOut(250); | |
| 86 | + } | |
| 87 | + ); | |
| 88 | + | |
| 70 | 89 | $.material.init(); |
| 71 | 90 | } |
| 72 | 91 | ) |
| ... | ... | @@ -231,6 +250,26 @@ i3GEOadmin.temas = { |
| 231 | 250 | } |
| 232 | 251 | ); |
| 233 | 252 | }, |
| 253 | + ordena: function(data){ | |
| 254 | + i3GEOadmin.core.modalAguarde(true); | |
| 255 | + $.post( | |
| 256 | + "exec.php?funcao=ordena", | |
| 257 | + "id_n2=" + i3GEOadmin.temas.id_n2 + "&ordem=" + data.join(" ") | |
| 258 | + ) | |
| 259 | + .done( | |
| 260 | + function(data, status){ | |
| 261 | + i3GEOadmin.core.modalAguarde(false); | |
| 262 | + i3GEOadmin.core.iconeAguarde(i3GEOadmin.temas.ondeNos); | |
| 263 | + i3GEOadmin.temas.lista(); | |
| 264 | + } | |
| 265 | + ) | |
| 266 | + .fail( | |
| 267 | + function(data){ | |
| 268 | + i3GEOadmin.core.modalAguarde(false); | |
| 269 | + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); | |
| 270 | + } | |
| 271 | + ); | |
| 272 | + }, | |
| 234 | 273 | addInput: function(id,valor){ |
| 235 | 274 | var i = $("#"+id); |
| 236 | 275 | $(i.val(i.val() + ' ' + valor)); | ... | ... |
admin1/catalogo/menus/grupos/subgrupos/temas/index.php
| ... | ... | @@ -59,7 +59,7 @@ $nome_subgrupo = filter_var ( $_GET ["nome_subgrupo"], FILTER_SANITIZE_STRING ); |
| 59 | 59 | <option value="form-{{id_n3}}">{{{nome_tema}}}</option> |
| 60 | 60 | </script> |
| 61 | 61 | <script id="templateTemas" type="x-tmpl-mustache"> |
| 62 | -<div class="panel panel-default" id="form-{{id_n3}}"> | |
| 62 | +<div class="panel panel-default" data-id="{{id_n3}}" id="form-{{id_n3}}"> | |
| 63 | 63 | <div class="panel-heading" role="tab"> |
| 64 | 64 | <h3 class="panel-title" {{escondido}}> |
| 65 | 65 | <a href="javascript:void(0)" onclick="{{onExcluir}}('{{id_n3}}')" class="btn btn-danger btn-fab btn-fab-mini" role="button"> |
| ... | ... | @@ -67,7 +67,9 @@ $nome_subgrupo = filter_var ( $_GET ["nome_subgrupo"], FILTER_SANITIZE_STRING ); |
| 67 | 67 | </a> |
| 68 | 68 | |
| 69 | 69 | <a class="collapsed in" role="button" data-toggle="collapse" href="#body-form-{{id_n3}}" |
| 70 | - aria-expanded="false" aria-controls="#body-form-{{id_n3}}"> {{{nome_tema}}} </a> | |
| 70 | + aria-expanded="false" aria-controls="#body-form-{{id_n3}}"> {{{nome_tema}}} | |
| 71 | + <i class="material-icons move" style="color: gray; display:none;">swap_vert</i> | |
| 72 | + </a> | |
| 71 | 73 | </h3> |
| 72 | 74 | </div> |
| 73 | 75 | <div class="panel-body panel-collapse collapse" id="body-form-{{id_n3}}"> | ... | ... |