Commit 87cc4ea3608a843e0f9ce50891a5ac27d2870a17
1 parent
86fc2ae3
Exists in
master
and in
7 other branches
#551 Uniformização dos formulários de edição
Showing
12 changed files
with
871 additions
and
891 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin/html/identifica.html
... | ... | @@ -26,7 +26,7 @@ body { |
26 | 26 | <h1>Administração do i3geo - sistemas de |
27 | 27 | identificação</h1> |
28 | 28 | <div id="formulario" style="display: none"> |
29 | - <div id="ajuda"> | |
29 | + <div id="ajuda" style="display: none"> | |
30 | 30 | <div class="hd">Ajuda</div> |
31 | 31 | <div class="bd" style="height: 144px; overflow: auto"> |
32 | 32 | Este programa permite editar a lista de sistemas de |
... | ... | @@ -45,9 +45,10 @@ body { |
45 | 45 | </div> |
46 | 46 | <div class="ft"></div> |
47 | 47 | </div> |
48 | - <input onclick="adicionaLinha()" type=button id=adiciona | |
48 | + <input type=button id=adicionaNovoIdentifica | |
49 | 49 | value="Adicionar um novo sistema" /> <br> |
50 | 50 | <p></p> |
51 | + <div id="letras_I" ></div><br> | |
51 | 52 | <div id="tabela" style="left: -5px;"></div> |
52 | 53 | <div id=logajax style="display: block"></div> |
53 | 54 | <div id=dialogoContinua style="display: block"></div> |
... | ... | @@ -103,7 +104,7 @@ body { |
103 | 104 | cabecalhoGeral("cabecalhoPrincipal", ""); |
104 | 105 | temp = function() { |
105 | 106 | document.getElementById("formulario").style.display = "block"; |
106 | - initMenu(); | |
107 | + i3GEOadmin.identifica.inicia(); | |
107 | 108 | }; |
108 | 109 | i3GEO.login.verificaOperacao("admin/html/identifica", |
109 | 110 | i3GEO.configura.locaplic, temp, "sessao"); | ... | ... |
admin/html/mapas.html
... | ... | @@ -28,7 +28,7 @@ body { |
28 | 28 | src="../imagens/04.png" style="cursor: pointer" id=botaoAjuda /> |
29 | 29 | </h1> |
30 | 30 | <div id="formulario" style="display: none"> |
31 | - <div id="ajuda"> | |
31 | + <div id="ajuda" style="display: none"> | |
32 | 32 | <div class="hd">Ajuda</div> |
33 | 33 | <div class="bd" style="height: 144px; overflow: auto"> |
34 | 34 | <p>Vc pode registrar qualquer link para ser utilizado. A |
... | ... | @@ -37,14 +37,13 @@ body { |
37 | 37 | utilizados em i3geo/ms_criamapa.php. Você pode desprezar |
38 | 38 | todos os campos do formulário e incluir apenas o link |
39 | 39 | direto desejado. |
40 | - <p>A lista de links é utilizada também na | |
41 | - interface mobile do i3geo. | |
42 | 40 | </div> |
43 | 41 | <div class="ft"></div> |
44 | 42 | </div> |
45 | - <input onclick="adicionaLinha()" type=button id=adiciona | |
43 | + <input type=button id=adicionaNovoMapa | |
46 | 44 | value="Adicionar um novo link" /> <br> |
47 | 45 | <p>Links existentes:</p> |
46 | + <div id="letras_Mp" ></div><br> | |
48 | 47 | <div id="tabela" style="left: -5px;"></div> |
49 | 48 | <div id=logajax style="display: block"></div> |
50 | 49 | </div> |
... | ... | @@ -99,7 +98,7 @@ body { |
99 | 98 | cabecalhoGeral("cabecalhoPrincipal", ""); |
100 | 99 | temp = function() { |
101 | 100 | document.getElementById("formulario").style.display = "block"; |
102 | - initMenu(); | |
101 | + i3GEOadmin.mapas.inicia(); | |
103 | 102 | }; |
104 | 103 | i3GEO.login.verificaOperacao("admin/html/mapas", |
105 | 104 | i3GEO.configura.locaplic, temp, "sessao"); | ... | ... |
admin/html/webservices.html
... | ... | @@ -25,7 +25,7 @@ body { |
25 | 25 | <div id=cabecalhoPrincipal></div> |
26 | 26 | <h1>Administração do i3geo - web Services</h1> |
27 | 27 | <div id="formulario" style="display: none"> |
28 | - <div id="ajuda"> | |
28 | + <div id="ajuda" style="display: none"> | |
29 | 29 | <div class="hd">Ajuda</div> |
30 | 30 | <div class="bd" style="height: 144px; overflow: auto"> |
31 | 31 | Este programa permite editar o cadastro de Web Services.<br> |
... | ... | @@ -45,9 +45,10 @@ body { |
45 | 45 | </div> |
46 | 46 | <div class="ft"></div> |
47 | 47 | </div> |
48 | - <input onclick="adicionaLinha()" type=button id=adiciona | |
48 | + <input type=button id=adicionaNovoWebservice | |
49 | 49 | value="Adicionar um novo endereço" /> <br> |
50 | - <p>Temas existentes:</p> | |
50 | + <p>Endereços cadastrados:</p> | |
51 | + <div id="letras_W" ></div><br> | |
51 | 52 | <div id="tabela" style="left: -5px;"></div> |
52 | 53 | <div id=logajax style="display: block"></div> |
53 | 54 | </div> |
... | ... | @@ -102,7 +103,7 @@ body { |
102 | 103 | cabecalhoGeral("cabecalhoPrincipal", ""); |
103 | 104 | temp = function() { |
104 | 105 | document.getElementById("formulario").style.display = "block"; |
105 | - initMenu(); | |
106 | + i3GEOadmin.webservices.inicia(); | |
106 | 107 | }; |
107 | 108 | i3GEO.login.verificaOperacao("admin/html/webservices", |
108 | 109 | i3GEO.configura.locaplic, temp, "sessao"); | ... | ... |
admin/js/arvore.js
... | ... | @@ -70,14 +70,14 @@ function initMenu(){ |
70 | 70 | editorDeGrupos = function(){ |
71 | 71 | if($i("editor_bd")){return;} |
72 | 72 | core_montaEditor("","600px","500px","","Grupos"); |
73 | - $i("editor_bd").innerHTML = '<p class=paragrafo >Clique nas células da tabela para editar a característica de cada item. Finalize com "enter". Após editar, salve o item.</p><p class=paragrafo ><input type=button id=adicionaNovoGrupo value="Adicionar um novo grupo" style="left:-5px;" /></p><p><br><br><div id="letras_G" ></div><br><div id="tabela" style="left:-5px;"> </div>'; | |
73 | + $i("editor_bd").innerHTML = '<p class=paragrafo ><input type=button id=adicionaNovoGrupo value="Adicionar um novo grupo" style="left:-5px;" /></p><p><br><br><div id="letras_G" ></div><br><div id="tabela" style="left:-5px;"> </div>'; | |
74 | 74 | i3GEOadmin.grupos.inicia(); |
75 | 75 | }, |
76 | 76 | editorDeSubGrupos = function() { |
77 | 77 | if($i("editor_bd")){return;} |
78 | 78 | core_montaEditor("","600px","500px","","Subgrupos"); |
79 | - $i("editor_bd").innerHTML = '<p class=paragrafo >Clique nas células da tabela para editar a caracter&iacutre;stica de cada item. Finalize com "enter". Após editar, salve o item.</p><p class=paragrafo ><input type=button id=adicionaNovoSubGrupo value="Adicionar um novo sub-grupo" style="left:-5px;" /></p><br><br><div id="letras_S" ></div><br><div id="tabela" style="left:-5px;"> </div>'; | |
80 | - initEditorSubGrupos(); | |
79 | + $i("editor_bd").innerHTML = '<p class=paragrafo ><input type=button id=adicionaNovoSubGrupo value="Adicionar um novo subgrupo" style="left:-5px;" /></p><br><br><div id="letras_SG" ></div><br><div id="tabela" style="left:-5px;"> </div>'; | |
80 | + i3GEOadmin.subgrupos.inicia(); | |
81 | 81 | }; |
82 | 82 | new YAHOO.widget.Button("botaoEditorMenu",{ onclick: { fn: editorDeMenus } }); |
83 | 83 | new YAHOO.widget.Button("botaoEditorGrupo",{ onclick: { fn: editorDeGrupos } }); | ... | ... |
admin/js/grupos.js
... | ... | @@ -75,9 +75,6 @@ i3GEOadmin.grupos = { |
75 | 75 | } |
76 | 76 | elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>"; |
77 | 77 | }, |
78 | - formatSalva: function(elCell, oRecord, oColumn){ | |
79 | - elCell.innerHTML = "<div title='salva' class=salvar style='text-align:center' onclick='gravaLinha_G(\""+oRecord._sId+"\")'></div>"; | |
80 | - }, | |
81 | 78 | formatExclui: function(elCell, oRecord, oColumn){ |
82 | 79 | elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>"; |
83 | 80 | }, |
... | ... | @@ -101,6 +98,8 @@ i3GEOadmin.grupos = { |
101 | 98 | */ |
102 | 99 | inicia: function(){ |
103 | 100 | YAHOO.namespace("grupos"); |
101 | + YAHOO.namespace("admin.container"); | |
102 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
104 | 103 | core_ativaBotaoAdicionaLinha("../php/menutemas.php?funcao=alteraGrupos","adicionaNovoGrupo","i3GEOadmin.grupos.obtem"); |
105 | 104 | i3GEOadmin.grupos.obtem(); |
106 | 105 | }, |
... | ... | @@ -174,7 +173,7 @@ i3GEOadmin.grupos = { |
174 | 173 | ins = '<div class="hd">Editor</div>'; |
175 | 174 | ins += "<div class='bd' style='height:354px;overflow:auto'>"; |
176 | 175 | ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>"; |
177 | - ins += "<div id='letras_M'></div>"; | |
176 | + ins += "<div id='letras_G'></div>"; | |
178 | 177 | novoel.innerHTML = ins; |
179 | 178 | |
180 | 179 | document.body.appendChild(novoel); | ... | ... |
admin/js/identifica.js
... | ... | @@ -29,205 +29,213 @@ Arquivo: |
29 | 29 | |
30 | 30 | i3geo/admin/js/identifica.js |
31 | 31 | */ |
32 | - | |
33 | -YAHOO.namespace("admin.container"); | |
34 | -function initMenu() | |
35 | -{ | |
36 | - core_ativaBotaoAdicionaLinha("../php/identifica.php?funcao=alterarFuncoes"); | |
37 | - core_carregando("ativa"); | |
38 | - core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
39 | - pegaFuncoes(); | |
40 | -} | |
41 | -function pegaFuncoes() | |
42 | -{ | |
43 | - core_pegaDados("buscando funções...","../php/identifica.php?funcao=pegaFuncoes","montaTabela"); | |
32 | +if(typeof(i3GEOadmin) === 'undefined'){ | |
33 | + var i3GEOadmin = {}; | |
44 | 34 | } |
45 | -function montaTabela(dados) | |
46 | -{ | |
47 | - YAHOO.example.InlineCellEditing = new function() | |
48 | - { | |
49 | - // Custom formatter for "address" column to preserve line breaks | |
50 | - var formatMais = function(elCell, oRecord, oColumn) | |
51 | - { | |
52 | - elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | |
53 | - }; | |
54 | - var formatTexto = function(elCell, oRecord, oColumn, oData) | |
55 | - { | |
56 | - elCell.innerHTML = "<pre ><p>" + oData + "</pre>"; | |
57 | - }; | |
58 | - var formatExclui = function(elCell, oRecord, oColumn) | |
59 | - { | |
60 | - elCell.innerHTML = "<div class=excluir style='text-align:center' ></div>";//onclick='excluiLinha(\""+oRecord.getData("id_menu")+"\",\""+oRecord.getId()+"\")'></div>"; | |
61 | - }; | |
62 | - var myColumnDefs = [ | |
63 | - {key:"excluir",label:"excluir",formatter:formatExclui}, | |
64 | - {key:"mais",label:"editar",formatter:formatMais}, | |
65 | - {label:"id",key:"id_i", formatter:formatTexto}, | |
66 | - {label:"nome",resizeable:true,key:"nome_i", formatter:formatTexto, editor:"textbox"}, | |
67 | - {label:"publicado?",key:"publicado_i",editor:"radio" ,editorOptions:{radioOptions:["SIM","NAO"],disableBtns:false}}, | |
68 | - {label:"programa",resizeable:true,key:"abrir_i", formatter:formatTexto, editor:"textbox"}, | |
69 | - {label:"abrir como?",key:"target_i", formatter:formatTexto,editor:"dropdown" ,editorOptions:{dropdownOptions:["self","target"],disableBtns:false}} | |
35 | +i3GEOadmin.identifica = { | |
36 | + dados: "", | |
37 | + dataTable: null, | |
38 | + colunas: ["publicado_i","abrir_i","id_i","nome_i","target_i"], | |
39 | + formatTexto: function(elCell, oRecord, oColumn, oData){ | |
40 | + if(oData === ""){ | |
41 | + oData = "<span style='color:gray' ></span>"; | |
42 | + } | |
43 | + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>"; | |
44 | + }, | |
45 | + formatExclui: function(elCell, oRecord, oColumn){ | |
46 | + elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>"; | |
47 | + }, | |
48 | + formatMais: function(elCell, oRecord, oColumn){ | |
49 | + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | |
50 | + }, | |
51 | + defColunas: function(){ | |
52 | + return [ | |
53 | + {key:"excluir",label:"excluir",formatter:i3GEOadmin.identifica.formatExclui}, | |
54 | + {key:"mais",label:"editar",formatter:i3GEOadmin.identifica.formatMais}, | |
55 | + {label:"id",key:"id_i", formatter:i3GEOadmin.identifica.formatTexto}, | |
56 | + {label:"nome",resizeable:true,key:"nome_i", formatter:i3GEOadmin.identifica.formatTexto}, | |
57 | + {label:"publicado?",resizeable:true,key:"publicado_i", formatter:i3GEOadmin.identifica.formatTexto}, | |
58 | + {label:"programa",resizeable:true,key:"programa_i", formatter:i3GEOadmin.identifica.formatTexto}, | |
59 | + {label:"abrir como?",resizeable:true,key:"target_i", formatter:i3GEOadmin.identifica.formatTexto} | |
70 | 60 | ]; |
71 | - myDataSource = new YAHOO.util.DataSource(dados); | |
72 | - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
73 | - myDataSource.responseSchema = | |
74 | - { | |
75 | - fields: ["publicado_i","abrir_i","id_i","nome_i","target_i"] | |
61 | + }, | |
62 | + /* | |
63 | + * Inicializa o menu | |
64 | + */ | |
65 | + inicia: function(){ | |
66 | + YAHOO.namespace("identifica"); | |
67 | + YAHOO.namespace("admin.container"); | |
68 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
69 | + core_ativaBotaoAdicionaLinha("../php/identifica.php?funcao=alterarFuncoes","adicionaNovoIdentifica","i3GEOadmin.identifica.obtem"); | |
70 | + i3GEOadmin.identifica.obtem(); | |
71 | + }, | |
72 | + /* | |
73 | + * Obtém a lista de menus | |
74 | + */ | |
75 | + obtem: function(){ | |
76 | + i3GEOadmin.identifica.dados = ""; | |
77 | + core_carregando("ativa"); | |
78 | + core_pegaDados("buscando endereços...","../php/identifica.php?funcao=pegaFuncoes","i3GEOadmin.identifica.tabela"); | |
79 | + }, | |
80 | + tabela: function(dados){ | |
81 | + if(i3GEOadmin.identifica.dados == ""){ | |
82 | + i3GEOadmin.identifica.dados = dados; | |
83 | + } | |
84 | + core_listaDeLetras("letras_I","i3GEOadmin.identifica.filtra"); | |
85 | + YAHOO.example.InlineCellEditing = new function(){ | |
86 | + // Custom formatter for "address" column to preserve line breaks | |
87 | + var myDataSource = new YAHOO.util.DataSource(dados); | |
88 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
89 | + myDataSource.responseSchema = { | |
90 | + fields: i3GEOadmin.identifica.colunas | |
91 | + }; | |
92 | + i3GEOadmin.identifica.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.identifica.defColunas(), myDataSource); | |
93 | + i3GEOadmin.identifica.dataTable.subscribe('cellClickEvent',function(ev){ | |
94 | + var sUrl, callback,$clicouId, $recordid, | |
95 | + target = YAHOO.util.Event.getTarget(ev), | |
96 | + column = this.getColumn(target), | |
97 | + registro = this.getRecord(target); | |
98 | + if(YAHOO.identifica.panelCK) { | |
99 | + YAHOO.identifica.panelCK.destroy(); | |
100 | + YAHOO.identifica.panelCK = null; | |
101 | + } | |
102 | + if (column.key == 'excluir'){ | |
103 | + i3GEOadmin.identifica.exclui(registro.getData('id_i'),target); | |
104 | + } | |
105 | + if (column.key == 'mais'){ | |
106 | + core_carregando("ativa"); | |
107 | + core_carregando("buscando dados..."); | |
108 | + $clicouId = registro.getData('id_i'); | |
109 | + $recordid = registro.getId(); | |
110 | + sUrl = "../php/identifica.php?funcao=pegafuncoes&id_i="+$clicouId; | |
111 | + callback = { | |
112 | + success:function(o){ | |
113 | + try{ | |
114 | + i3GEOadmin.identifica.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | |
115 | + } | |
116 | + catch(e){core_handleFailure(e,o.responseText);} | |
117 | + }, | |
118 | + failure:core_handleFailure, | |
119 | + argument: { foo:"foo", bar:"bar" } | |
120 | + }; | |
121 | + core_makeRequest(sUrl,callback); | |
122 | + } | |
123 | + }); | |
76 | 124 | }; |
77 | - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | |
78 | - myDataTable.subscribe('cellClickEvent',function(ev) | |
79 | - { | |
80 | - var target = YAHOO.util.Event.getTarget(ev); | |
81 | - var column = this.getColumn(target); | |
82 | - if(YAHOO.admin.container.panelCK) | |
83 | - { | |
84 | - YAHOO.admin.container.panelCK.destroy(); | |
85 | - YAHOO.admin.container.panelCK = null; | |
125 | + core_carregando("desativa"); | |
126 | + }, | |
127 | + editor: function(dados,id,recordid){ | |
128 | + function on_editorCheckBoxChange(p_oEvent){ | |
129 | + if(p_oEvent.newValue.get("value") == "OK"){ | |
130 | + i3GEOadmin.identifica.salva(id,recordid); | |
86 | 131 | } |
87 | - if (column.key == 'excluir') | |
88 | - { | |
89 | - var record = this.getRecord(target); | |
90 | - excluiLinha(record.getData('id_i'),target); | |
91 | - } | |
92 | - if (column.key == 'mais') | |
93 | - { | |
94 | - var record = this.getRecord(target); | |
95 | - core_carregando("ativa"); | |
96 | - core_carregando("buscando dados..."); | |
97 | - $clicouId = record.getData('id_i'); | |
98 | - $recordid = record.getId(); | |
99 | - var sUrl = "../php/identifica.php?funcao=pegafuncoes&id_i="+record.getData('id_i'); | |
100 | - var callback = | |
101 | - { | |
102 | - success:function(o) | |
103 | - { | |
104 | - try | |
105 | - { | |
106 | - montaEditor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | |
107 | - } | |
108 | - catch(e){core_handleFailure(e,o.responseText);} | |
109 | - }, | |
110 | - failure:core_handleFailure, | |
111 | - argument: { foo:"foo", bar:"bar" } | |
112 | - }; | |
113 | - core_makeRequest(sUrl,callback); | |
114 | - } | |
115 | - }); | |
132 | + YAHOO.identifica.panelEditor2.destroy(); | |
133 | + YAHOO.identifica.panelEditor2 = null; | |
134 | + }; | |
135 | + if(!$i("janela_editor2")){ | |
136 | + var editorBotoes,ins, | |
137 | + novoel = document.createElement("div"); | |
138 | + novoel.id = "janela_editor2"; | |
139 | + ins = '<div class="hd">Editor</div>'; | |
140 | + ins += "<div class='bd' style='height:354px;overflow:auto'>"; | |
141 | + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>"; | |
142 | + ins += "<div id='letras_I'></div>"; | |
143 | + novoel.innerHTML = ins; | |
116 | 144 | |
117 | - }; | |
118 | - core_carregando("desativa"); | |
119 | -} | |
120 | -function montaEditor(dados,id,recordid) | |
121 | -{ | |
122 | - function on_editorCheckBoxChange(p_oEvent) | |
123 | - { | |
124 | - if(p_oEvent.newValue.get("value") == "OK") | |
125 | - { | |
126 | - gravaDados(id,recordid); | |
145 | + document.body.appendChild(novoel); | |
146 | + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" }); | |
147 | + editorBotoes.addButtons([ | |
148 | + { label: "Salva", value: "OK", checked: false}, | |
149 | + { label: "Cancela", value: "CANCEL", checked: false } | |
150 | + ]); | |
151 | + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | |
152 | + YAHOO.identifica.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"480px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
153 | + YAHOO.identifica.panelEditor2.render(); | |
127 | 154 | } |
128 | - else | |
129 | - { | |
130 | - YAHOO.admin.container.panelEditor.destroy(); | |
131 | - YAHOO.admin.container.panelEditor = null; | |
155 | + YAHOO.identifica.panelEditor2.show(); | |
156 | + $i("editor_bd2").innerHTML = i3GEOadmin.identifica.formulario(dados[0]); | |
157 | + core_carregando("desativa"); | |
158 | + }, | |
159 | + formulario: function(i){ | |
160 | + var param = { | |
161 | + "linhas":[ | |
162 | + {titulo:"Nome:",id:"Enome_i",size:"50",value:i.nome_i,tipo:"text",div:""}, | |
163 | + {titulo:"Programa: o i3Geo irá adicionar automaticamente os parâmetros &x e &y no final do endereço",id:"Eabrir_i",size:"50",value:i.abrir_i,tipo:"text",div:""}, | |
164 | + {titulo:"Abrir como: escreva 'self' para abrir na mesma janela ou 'blank' para abrir em uma nova aba",id:"Etarget_i",size:"50",value:i.target_i,tipo:"text",div:""} | |
165 | + ] | |
166 | + }; | |
167 | + var ins = ""; | |
168 | + ins += core_geraLinhas(param) ; | |
169 | + | |
170 | + ins += "<p><b>Publicado?</b><br>"; | |
171 | + ins += "<select id='Epublicado_i' />"; | |
172 | + ins += "<option value='' "; | |
173 | + if (i.publicado_i == ""){ins += "selected";} | |
174 | + ins += ">---</option>"; | |
175 | + ins += "<option value='SIM' "; | |
176 | + if (i.publicado_i == "SIM"){ins += "selected";} | |
177 | + ins += " >sim</option>"; | |
178 | + ins += "<option value='NAO' "; | |
179 | + if (i.publicado_i == "NAO"){ins += "selected";} | |
180 | + ins += " >não</option>"; | |
181 | + ins += "</select></p>"; | |
182 | + return(ins); | |
183 | + }, | |
184 | + filtra: function(letra){ | |
185 | + var i,temp, | |
186 | + n = i3GEOadmin.identifica.dados.length, | |
187 | + novo = []; | |
188 | + if(letra == "Todos"){ | |
189 | + novo = i3GEOadmin.identifica.dados; | |
132 | 190 | } |
133 | - }; | |
134 | - if(!YAHOO.admin.container.panelEditor) | |
135 | - { | |
136 | - var novoel = document.createElement("div"); | |
137 | - novoel.id = "janela_editor"; | |
138 | - var ins = '<div class="hd">Editor</div>'; | |
139 | - ins += "<div class='bd' style='height:354px;overflow:auto'>"; | |
140 | - ins += "<div id='okcancel_checkbox'></div><div id='editor_bd'></div>"; | |
141 | - novoel.innerHTML = ins; | |
142 | - document.body.appendChild(novoel); | |
143 | - var editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id", name: "okcancel_checkbox_id", container: "okcancel_checkbox" }); | |
144 | - editorBotoes.addButtons([ | |
145 | - { label: "Salva", value: "OK", checked: false}, | |
146 | - { label: "Cancela", value: "CANCEL", checked: false } | |
147 | - ]); | |
148 | - editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | |
149 | - YAHOO.admin.container.panelEditor = new YAHOO.widget.Panel("janela_editor", { fixedcenter:true,close:false,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
150 | - YAHOO.admin.container.panelEditor.render(); | |
191 | + else{ | |
192 | + for(i=0;i<n;i++){ | |
193 | + temp = i3GEOadmin.identifica.dados[i].nome_i; | |
194 | + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){ | |
195 | + novo.push(i3GEOadmin.identifica.dados[i]); | |
196 | + } | |
197 | + } | |
198 | + } | |
199 | + i3GEOadmin.identifica.tabela(novo); | |
200 | + }, | |
201 | + exclui: function(id,row){ | |
202 | + var mensagem = " excluindo o registro do id= "+id, | |
203 | + sUrl = "../php/identifica.php?funcao=excluir&id="+id; | |
204 | + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.identifica.dataTable); | |
205 | + }, | |
206 | + salva: function(id,recordid){ | |
207 | + var i,c,sUrl, callback, | |
208 | + campos = i3GEOadmin.identifica.colunas, | |
209 | + par = "", | |
210 | + n = campos.length; | |
211 | + for (i=0;i<n;i++){ | |
212 | + c = $i("E"+campos[i].key); | |
213 | + if(c){ | |
214 | + par += "&"+campos[i].key+"="+(c.value); | |
215 | + } | |
216 | + } | |
217 | + par += "&id_i="+id; | |
218 | + core_carregando("ativa"); | |
219 | + core_carregando(" gravando o registro do id= "+id); | |
220 | + sUrl = "../php/identifica.php?funcao=alterarFuncoes"+par; | |
221 | + callback = { | |
222 | + success:function(o){ | |
223 | + try { | |
224 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") { | |
225 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem registros vinculados</span>"); | |
226 | + setTimeout("core_carregando('desativa')",3000); | |
227 | + } | |
228 | + else{ | |
229 | + var rec = i3GEOadmin.identifica.dataTable.getRecordSet().getRecord(recordid); | |
230 | + i3GEOadmin.identifica.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | |
231 | + core_carregando("desativa"); | |
232 | + } | |
233 | + } | |
234 | + catch(e){core_handleFailure(e,o.responseText);} | |
235 | + }, | |
236 | + failure:core_handleFailure, | |
237 | + argument: { foo:"foo", bar:"bar" } | |
238 | + }; | |
239 | + core_makeRequest(sUrl,callback); | |
151 | 240 | } |
152 | - YAHOO.admin.container.panelEditor.show(); | |
153 | - //carrega os dados na janela | |
154 | - $i("editor_bd").innerHTML = montaDiv(dados[0]); | |
155 | - core_carregando("desativa"); | |
156 | -} | |
157 | -function montaDiv(i) | |
158 | -{ | |
159 | - var param = { | |
160 | - "linhas":[ | |
161 | - {titulo:"Nome:",id:"Enome_i",size:"50",value:i.nome_i,tipo:"text",div:""}, | |
162 | - {titulo:"Programa: o i3Geo irá adicionar automaticamente os parâmetros &x e &y no final do endereço",id:"Eabrir_i",size:"50",value:i.abrir_i,tipo:"text",div:""}, | |
163 | - {titulo:"Abrir como: escreva 'self' para abrir na mesma janela ou 'blank' para abrir em uma nova aba",id:"Etarget_i",size:"50",value:i.target_i,tipo:"text",div:""} | |
164 | - ] | |
165 | - }; | |
166 | - var ins = ""; | |
167 | - ins += core_geraLinhas(param) ; | |
168 | - | |
169 | - ins += "<p><b>Publicado?</b><br>"; | |
170 | - ins += "<select id='Epublicado_i' />"; | |
171 | - ins += "<option value='' "; | |
172 | - if (i.publicado_i == ""){ins += "selected";} | |
173 | - ins += ">---</option>"; | |
174 | - ins += "<option value='SIM' "; | |
175 | - if (i.publicado_i == "SIM"){ins += "selected";} | |
176 | - ins += " >sim</option>"; | |
177 | - ins += "<option value='NAO' "; | |
178 | - if (i.publicado_i == "NAO"){ins += "selected";} | |
179 | - ins += " >não</option>"; | |
180 | - ins += "</select></p>"; | |
181 | - return(ins); | |
182 | -} | |
183 | -/* | |
184 | -Function: gravaDados | |
185 | - | |
186 | -Salva as alterações feitas | |
187 | - | |
188 | -<ALTERARFUNCOES> | |
189 | -*/ | |
190 | -function gravaDados(id,recordid) | |
191 | -{ | |
192 | - var campos = new Array("nome","publicado","abrir","target"); | |
193 | - var par = ""; | |
194 | - for (var i=0;i<campos.length;i++) | |
195 | - {par += "&"+campos[i]+"_i="+($i("E"+campos[i]+"_i").value);} | |
196 | - par += "&id_i="+id; | |
197 | - core_carregando("ativa"); | |
198 | - core_carregando(" gravando o registro do id= "+id); | |
199 | - var sUrl = "../php/identifica.php?funcao=alterarFuncoes"+par; | |
200 | - var callback = | |
201 | - { | |
202 | - success:function(o) | |
203 | - { | |
204 | - try | |
205 | - { | |
206 | - if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | |
207 | - { | |
208 | - core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem registros vinculados</span>"); | |
209 | - setTimeout("core_carregando('desativa')",3000); | |
210 | - } | |
211 | - else | |
212 | - { | |
213 | - var rec = myDataTable.getRecordSet().getRecord(recordid); | |
214 | - myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | |
215 | - core_carregando("desativa"); | |
216 | - } | |
217 | - YAHOO.admin.container.panelEditor.destroy(); | |
218 | - YAHOO.admin.container.panelEditor = null; | |
219 | - } | |
220 | - catch(e){core_handleFailure(e,o.responseText);} | |
221 | - }, | |
222 | - failure:core_handleFailure, | |
223 | - argument: { foo:"foo", bar:"bar" } | |
224 | - }; | |
225 | - core_makeRequest(sUrl,callback); | |
226 | -} | |
227 | - | |
228 | -function excluiLinha(id,row) | |
229 | -{ | |
230 | - var mensagem = " excluindo o registro do id= "+id; | |
231 | - var sUrl = "../php/identifica.php?funcao=excluir&id="+id; | |
232 | - core_excluiLinha(sUrl,row,mensagem); | |
233 | -} | |
234 | 241 | \ No newline at end of file |
242 | +}; | |
235 | 243 | \ No newline at end of file | ... | ... |
admin/js/mapas.js
... | ... | @@ -29,277 +29,233 @@ Arquivo: |
29 | 29 | |
30 | 30 | i3geo/admin/js/mapas.js |
31 | 31 | */ |
32 | -YAHOO.namespace("admin.container"); | |
33 | -/* | |
34 | -Function: initMenu | |
35 | - | |
36 | -Inicializa o editor | |
37 | - | |
38 | -<ALTERARMAPA> | |
39 | -*/ | |
40 | -function initMenu() | |
41 | -{ | |
42 | - core_ativaBotaoAdicionaLinha("../php/mapas.php?funcao=alterarMapa"); | |
43 | - core_carregando("ativa"); | |
44 | - core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
45 | - pegaMapas(); | |
32 | +if(typeof(i3GEOadmin) === 'undefined'){ | |
33 | + var i3GEOadmin = {}; | |
46 | 34 | } |
47 | -/* | |
48 | -Function: pegaMapas | |
49 | - | |
50 | -Obtém a lista de mapas | |
51 | - | |
52 | -<PEGAMAPAS> | |
53 | -*/ | |
54 | -function pegaMapas() | |
55 | -{ | |
56 | - core_pegaDados("buscando mapas...","../php/mapas.php?funcao=pegaMapas","montaTabela"); | |
57 | -} | |
58 | -/* | |
59 | -Function: montaTabela | |
60 | - | |
61 | -Monta a tabela com as opções de edição de cada registro | |
62 | - | |
63 | -<PEGADADOSMAPA> | |
64 | -*/ | |
65 | -function montaTabela(dados) | |
66 | -{ | |
67 | - YAHOO.example.InlineCellEditing = new function() | |
68 | - { | |
69 | - // Custom formatter for "address" column to preserve line breaks | |
70 | - var formatTextoId = function(elCell, oRecord, oColumn, oData) | |
71 | - { | |
72 | - elCell.innerHTML = "<p>" + oData + "</p>"; | |
73 | - }; | |
74 | - | |
75 | - var formatMais = function(elCell, oRecord, oColumn) | |
76 | - { | |
77 | - elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | |
78 | - }; | |
79 | - var formatExclui = function(elCell, oRecord, oColumn) | |
80 | - { | |
81 | - elCell.innerHTML = "<div class=excluir style='text-align:center' ></div>"; | |
82 | - }; | |
83 | - var myColumnDefs = [ | |
84 | - {key:"excluir",label:"excluir",formatter:formatExclui}, | |
85 | - {key:"mais",label:"mais",formatter:formatMais}, | |
86 | - {label:"id",key:"id_mapa", formatter:formatTextoId}, | |
87 | - {label:"nome",key:"nome_mapa", formatter:formatTextoId}, | |
88 | - {label:"ordem",key:"ordem_mapa", formatter:formatTextoId} | |
35 | +i3GEOadmin.mapas = { | |
36 | + dados: "", | |
37 | + dataTable: null, | |
38 | + colunas: ["id_mapa","publicado_mapa","ordem_mapa","perfil_mapa","ligados_mapa","temas_mapa","desc_mapa","ext_mapa","imagem_mapa","linkdireto_mapa","nome_mapa","outros_mapa"], | |
39 | + formatTexto: function(elCell, oRecord, oColumn, oData){ | |
40 | + if(oData === ""){ | |
41 | + oData = "<span style='color:gray' ></span>"; | |
42 | + } | |
43 | + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>"; | |
44 | + }, | |
45 | + formatExclui: function(elCell, oRecord, oColumn){ | |
46 | + elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>"; | |
47 | + }, | |
48 | + formatMais: function(elCell, oRecord, oColumn){ | |
49 | + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | |
50 | + }, | |
51 | + defColunas: function(){ | |
52 | + return [ | |
53 | + {key:"excluir",label:"excluir",formatter:i3GEOadmin.mapas.formatExclui}, | |
54 | + {key:"mais",label:"editar",formatter:i3GEOadmin.mapas.formatMais}, | |
55 | + {label:"id",key:"id_mapa", formatter:i3GEOadmin.mapas.formatTexto}, | |
56 | + {label:"nome",resizeable:true,key:"nome_mapa", formatter:i3GEOadmin.mapas.formatTexto}, | |
57 | + {label:"ordem",resizeable:true,key:"ordem_mapa", formatter:i3GEOadmin.mapas.formatTexto} | |
89 | 58 | ]; |
90 | - myDataSource = new YAHOO.util.DataSource(dados); | |
91 | - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
92 | - myDataSource.responseSchema = | |
93 | - { | |
94 | - fields: ["id_mapa","nome_mapa","ordem_mapa"] | |
59 | + }, | |
60 | + /* | |
61 | + * Inicializa o menu | |
62 | + */ | |
63 | + inicia: function(){ | |
64 | + YAHOO.namespace("mapas"); | |
65 | + YAHOO.namespace("admin.container"); | |
66 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
67 | + core_ativaBotaoAdicionaLinha("../php/mapas.php?funcao=alterarMapa","adicionaNovoMapa","i3GEOadmin.mapas.obtem"); | |
68 | + i3GEOadmin.mapas.obtem(); | |
69 | + }, | |
70 | + /* | |
71 | + * Obtém a lista de menus | |
72 | + */ | |
73 | + obtem: function(){ | |
74 | + i3GEOadmin.mapas.dados = ""; | |
75 | + core_carregando("ativa"); | |
76 | + core_pegaDados("buscando dados...","../php/mapas.php?funcao=pegaMapas","i3GEOadmin.mapas.tabela"); | |
77 | + }, | |
78 | + tabela: function(dados){ | |
79 | + if(i3GEOadmin.mapas.dados == ""){ | |
80 | + i3GEOadmin.mapas.dados = dados; | |
81 | + } | |
82 | + core_listaDeLetras("letras_Mp","i3GEOadmin.mapas.filtra"); | |
83 | + YAHOO.example.InlineCellEditing = new function(){ | |
84 | + // Custom formatter for "address" column to preserve line breaks | |
85 | + var myDataSource = new YAHOO.util.DataSource(dados); | |
86 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
87 | + myDataSource.responseSchema = { | |
88 | + fields: i3GEOadmin.mapas.colunas | |
89 | + }; | |
90 | + i3GEOadmin.mapas.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.mapas.defColunas(), myDataSource); | |
91 | + i3GEOadmin.mapas.dataTable.subscribe('cellClickEvent',function(ev){ | |
92 | + var sUrl, callback,$clicouId, $recordid, | |
93 | + target = YAHOO.util.Event.getTarget(ev), | |
94 | + column = this.getColumn(target), | |
95 | + registro = this.getRecord(target); | |
96 | + if(YAHOO.mapas.panelCK) { | |
97 | + YAHOO.mapas.panelCK.destroy(); | |
98 | + YAHOO.mapas.panelCK = null; | |
99 | + } | |
100 | + if (column.key == 'excluir'){ | |
101 | + i3GEOadmin.mapas.exclui(registro.getData('id_mapa'),target); | |
102 | + } | |
103 | + if (column.key == 'mais'){ | |
104 | + core_carregando("ativa"); | |
105 | + core_carregando("buscando dados..."); | |
106 | + $clicouId = registro.getData('id_mapa'); | |
107 | + $recordid = registro.getId(); | |
108 | + sUrl = "../php/mapas.php?funcao=pegaDadosMapa&id_mapa="+$clicouId; | |
109 | + callback = { | |
110 | + success:function(o){ | |
111 | + try{ | |
112 | + i3GEOadmin.mapas.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | |
113 | + } | |
114 | + catch(e){core_handleFailure(e,o.responseText);} | |
115 | + }, | |
116 | + failure:core_handleFailure, | |
117 | + argument: { foo:"foo", bar:"bar" } | |
118 | + }; | |
119 | + core_makeRequest(sUrl,callback); | |
120 | + } | |
121 | + }); | |
95 | 122 | }; |
96 | - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | |
97 | - // Set up editing flow | |
98 | - myDataTable.subscribe('cellClickEvent',function(ev) | |
99 | - { | |
100 | - var target = YAHOO.util.Event.getTarget(ev); | |
101 | - var column = this.getColumn(target); | |
102 | - if (column.key == 'excluir') | |
103 | - { | |
104 | - var record = this.getRecord(target); | |
105 | - excluiLinha(record.getData('id_mapa'),target); | |
106 | - } | |
107 | - if (column.key == 'mais') | |
108 | - { | |
109 | - var record = this.getRecord(target); | |
110 | - core_carregando("ativa"); | |
111 | - core_carregando("buscando dados..."); | |
112 | - $clicouId = record.getData('id_mapa'); | |
113 | - $recordid = record.getId(); | |
114 | - var sUrl = "../php/mapas.php?funcao=pegaDadosMapa&id_mapa="+record.getData('id_mapa'); | |
115 | - var callback = | |
116 | - { | |
117 | - success:function(o) | |
118 | - { | |
119 | - try | |
120 | - { | |
121 | - montaEditorMapa(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | |
122 | - } | |
123 | - catch(e){core_handleFailure(e,o.responseText);} | |
124 | - }, | |
125 | - failure:core_handleFailure, | |
126 | - argument: { foo:"foo", bar:"bar" } | |
127 | - }; | |
128 | - core_makeRequest(sUrl,callback); | |
123 | + core_carregando("desativa"); | |
124 | + }, | |
125 | + editor: function(dados,id,recordid){ | |
126 | + function on_editorCheckBoxChange(p_oEvent){ | |
127 | + if(p_oEvent.newValue.get("value") == "OK"){ | |
128 | + i3GEOadmin.mapas.salva(id,recordid); | |
129 | 129 | } |
130 | + YAHOO.mapas.panelEditor2.destroy(); | |
131 | + YAHOO.mapas.panelEditor2 = null; | |
132 | + }; | |
133 | + if(!$i("janela_editor2")){ | |
134 | + var editorBotoes,ins, | |
135 | + novoel = document.createElement("div"); | |
136 | + novoel.id = "janela_editor2"; | |
137 | + ins = '<div class="hd">Editor</div>'; | |
138 | + ins += "<div class='bd' style='height:354px;overflow:auto'>"; | |
139 | + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>"; | |
140 | + ins += "<div id='letras_SG'></div>"; | |
141 | + novoel.innerHTML = ins; | |
130 | 142 | |
131 | - }); | |
132 | - // Hook into custom event to customize save-flow of "radio" editor | |
133 | - myDataTable.subscribe("editorUpdateEvent", function(oArgs) | |
134 | - { | |
135 | - if(oArgs.editor.column.key === "active") | |
136 | - { | |
137 | - this.saveCellEditor(); | |
138 | - } | |
139 | - }); | |
140 | - myDataTable.subscribe("editorBlurEvent", function(oArgs) | |
141 | - { | |
142 | - this.cancelCellEditor(); | |
143 | - }); | |
144 | - }; | |
145 | - core_carregando("desativa"); | |
146 | -} | |
147 | -function montaEditorMapa(dados,id,recordid) | |
148 | -{ | |
149 | - function on_editorCheckBoxChange(p_oEvent) | |
150 | - { | |
151 | - if(p_oEvent.newValue.get("value") == "OK") | |
152 | - { | |
153 | - gravaDadosMapa(id,recordid); | |
154 | - } | |
155 | - else | |
156 | - { | |
157 | - YAHOO.admin.container.panelEditorMapa.destroy(); | |
158 | - YAHOO.admin.container.panelEditorMapa = null; | |
143 | + document.body.appendChild(novoel); | |
144 | + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" }); | |
145 | + editorBotoes.addButtons([ | |
146 | + { label: "Salva", value: "OK", checked: false}, | |
147 | + { label: "Cancela", value: "CANCEL", checked: false } | |
148 | + ]); | |
149 | + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | |
150 | + YAHOO.mapas.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"480px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
151 | + YAHOO.mapas.panelEditor2.render(); | |
159 | 152 | } |
160 | - }; | |
161 | - if(!YAHOO.admin.container.panelEditorMapa) | |
162 | - { | |
163 | - var novoel = document.createElement("div"); | |
164 | - novoel.id = "janela_editor"; | |
165 | - var ins = '<div class="hd">Editor</div>'; | |
166 | - ins += "<div class='bd' style='height:354px;overflow:auto'>"; | |
167 | - ins += "<div id='okcancel_checkbox'></div><div id='editor_bd'></div>"; | |
168 | - novoel.innerHTML = ins; | |
169 | - document.body.appendChild(novoel); | |
170 | - var editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id", name: "okcancel_checkbox_id", container: "okcancel_checkbox" }); | |
171 | - editorBotoes.addButtons([ | |
172 | - { label: "Salva", value: "OK", checked: false}, | |
173 | - { label: "Cancela", value: "CANCEL", checked: false } | |
174 | - ]); | |
175 | - editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | |
176 | - YAHOO.admin.container.panelEditorMapa = new YAHOO.widget.Panel("janela_editor", { fixedcenter:true,close:false,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
177 | - YAHOO.admin.container.panelEditorMapa.render(); | |
178 | - } | |
179 | - YAHOO.admin.container.panelEditorMapa.show(); | |
180 | - //carrega os dados na janela | |
181 | - $i("editor_bd").innerHTML = montaDivMapas(dados[0]); | |
182 | - core_carregando("desativa"); | |
183 | - // | |
184 | - //preenche a div com a lista de mapfiles e perfis | |
185 | - // | |
186 | - core_comboMapfiles("comboMapfiles","Etemas_mapa","",'registraMapfile(this.value,\"Etemas_mapa\")'); | |
187 | - core_comboPerfis("comboPerfis","Eperfil_mapa","","registraPerfil(this.value)"); | |
188 | -} | |
189 | -function registraPerfil(valor) | |
190 | -{ | |
191 | - var inp = $i("Eperfil_mapa"); | |
192 | - var perfis = inp.value; | |
193 | - if(perfis == "") | |
194 | - inp.value = valor; | |
195 | - else | |
196 | - inp.value = perfis+" "+valor; | |
197 | -} | |
198 | - | |
199 | -function registraMapfile(valor,onde) | |
200 | -{ | |
201 | - var inp = $i(onde); | |
202 | - var temas = inp.value; | |
203 | - if(temas == "") | |
204 | - inp.value = valor; | |
205 | - else | |
206 | - inp.value = temas+" "+valor; | |
207 | -} | |
208 | -function montaDivMapas(i) | |
209 | -{ | |
210 | - var ins = ""; | |
211 | - | |
212 | - //ins += "<p>Mapfile (código do mapfile que será utilizado para criar a camada no i3geo):" | |
213 | - //ins += "<div id=comboMapfiles >Buscando...</div>"; | |
214 | - ins += "<p>Ordem de apresentação do mapa:<br>"; | |
215 | - ins += "<input size=10 type=text id=Eordem_mapa value='"+i.ordem_mapa+"' /></p>"; | |
216 | - | |
217 | - ins += "<p>Nome do mapa:<br>"; | |
218 | - ins += "<input size=50 type=text id=Enome_mapa value='"+i.nome_mapa+"' /></p>"; | |
153 | + YAHOO.mapas.panelEditor2.show(); | |
154 | + $i("editor_bd2").innerHTML = i3GEOadmin.mapas.formulario(dados[0]); | |
155 | + core_comboMapfiles("comboMapfiles","Etemas_mapa","",'registraMapfile(this.value,\"Etemas_mapa\")'); | |
156 | + core_comboPerfis("comboPerfis","Eperfil_mapa","","registraPerfil(this.value)"); | |
157 | + core_carregando("desativa"); | |
158 | + }, | |
159 | + formulario: function(i){ | |
160 | + var ins = ""; | |
219 | 161 | |
220 | - ins += "<p>Publicado?<br>"; | |
221 | - ins += "<select id='Epublicado_mapa' >"; | |
222 | - ins += core_combosimnao(i.publicado_mapa); | |
223 | - ins += "</select></p>"; | |
162 | + //ins += "<p>Mapfile (código do mapfile que será utilizado para criar a camada no i3geo):" | |
163 | + //ins += "<div id=comboMapfiles >Buscando...</div>"; | |
164 | + ins += "<p>Ordem de apresentação do mapa:<br>"; | |
165 | + ins += "<input size=10 type=text id=Eordem_mapa value='"+i.ordem_mapa+"' /></p>"; | |
224 | 166 | |
225 | - ins += "<p>Descrição:<br>"; | |
226 | - ins += "<input size=50 type=text id=Edesc_mapa value='"+i.desc_mapa+"' /></p>"; | |
167 | + ins += "<p>Nome do mapa:<br>"; | |
168 | + ins += "<input size=50 type=text id=Enome_mapa value='"+i.nome_mapa+"' /></p>"; | |
227 | 169 | |
228 | - ins += "<p>Extensão geográfica:<br>"; | |
229 | - ins += "<input size=50 type=text id=Eext_mapa value='"+i.ext_mapa+"' /></p>"; | |
170 | + ins += "<p>Publicado?<br>"; | |
171 | + ins += "<select id='Epublicado_mapa' >"; | |
172 | + ins += core_combosimnao(i.publicado_mapa); | |
173 | + ins += "</select></p>"; | |
230 | 174 | |
231 | - ins += "<p>URL da imagem miniatura:<br>"; | |
232 | - ins += "<input size=50 type=text id=Eimagem_mapa value='"+i.imagem_mapa+"' /></p>"; | |
233 | - ins += "<img src='"+i.imagem_mapa+"' />"; | |
175 | + ins += "<p>Descrição:<br>"; | |
176 | + ins += "<input size=50 type=text id=Edesc_mapa value='"+i.desc_mapa+"' /></p>"; | |
234 | 177 | |
235 | - ins += "<p>Temas que serão incluídos nesse mapa (utilize os códigos dos mapfiles mostrados na lista abaixo): </p>"; | |
236 | - ins += "<input size=50 type=text id='Etemas_mapa' value='"+i.temas_mapa+"' /></p>"; | |
237 | - ins += "<div id=comboMapfiles >Buscando...</div>"; | |
178 | + ins += "<p>Extensão geográfica:<br>"; | |
179 | + ins += "<input size=50 type=text id=Eext_mapa value='"+i.ext_mapa+"' /></p>"; | |
238 | 180 | |
239 | - ins += "<p>Temas que serão ligados. Devem constar na lista de temas incluídos: </p>"; | |
240 | - ins += "<input size=50 type=text id='Eligados_mapa' value='"+i.ligados_mapa+"' /></p>"; | |
181 | + ins += "<p>URL da imagem miniatura:<br>"; | |
182 | + ins += "<input size=50 type=text id=Eimagem_mapa value='"+i.imagem_mapa+"' /></p>"; | |
183 | + ins += "<img src='"+i.imagem_mapa+"' />"; | |
241 | 184 | |
242 | - ins += "<p>Perfis que podem ver este mapa: </p>"; | |
243 | - ins += "<input size=50 type=text id='Eperfil_mapa' value='"+i.perfil_mapa+"' /></p>"; | |
244 | - ins += "<div id=comboPerfis >Buscando...</div>"; | |
185 | + ins += "<p>Temas que serão incluídos nesse mapa (utilize os códigos dos mapfiles mostrados na lista abaixo): </p>"; | |
186 | + ins += "<input size=50 type=text id='Etemas_mapa' value='"+i.temas_mapa+"' /></p>"; | |
187 | + ins += "<div id=comboMapfiles >Buscando...</div>"; | |
245 | 188 | |
246 | - ins += "<p>Outros parâmetros (separe com '&'):<br>"; | |
247 | - ins += "<input size=50 type=text id=Eoutros_mapa value='"+i.outros_mapa+"' /></p>"; | |
189 | + ins += "<p>Temas que serão ligados. Devem constar na lista de temas incluídos: </p>"; | |
190 | + ins += "<input size=50 type=text id='Eligados_mapa' value='"+i.ligados_mapa+"' /></p>"; | |
248 | 191 | |
249 | - ins += "<p>Link direto para abertura do mapa (despreza os outros parâmetros):<br>"; | |
250 | - ins += "<input size=50 type=text id=Elinkdireto_mapa value='"+i.linkdireto_mapa+"' /></p>"; | |
251 | - ins += "<br><br><br>"; | |
252 | - return(ins); | |
253 | -} | |
254 | -function excluiLinha(id,row) | |
255 | -{ | |
256 | - var mensagem = " excluindo o registro do id= "+id; | |
257 | - var sUrl = "../php/mapas.php?funcao=excluirMapa&id="+id; | |
258 | - core_excluiLinha(sUrl,row,mensagem); | |
259 | -} | |
260 | -/* | |
261 | -Function: gravaDadosMapa | |
192 | + ins += "<p>Perfis que podem ver este mapa: </p>"; | |
193 | + ins += "<input size=50 type=text id='Eperfil_mapa' value='"+i.perfil_mapa+"' /></p>"; | |
194 | + ins += "<div id=comboPerfis >Buscando...</div>"; | |
262 | 195 | |
263 | -Aplica as alterações feitas em um mapa | |
196 | + ins += "<p>Outros parâmetros (separe com '&'):<br>"; | |
197 | + ins += "<input size=50 type=text id=Eoutros_mapa value='"+i.outros_mapa+"' /></p>"; | |
264 | 198 | |
265 | -<ALTERARMAPA> | |
266 | -*/ | |
267 | -function gravaDadosMapa(id,recordid) | |
268 | -{ | |
269 | - var campos = new Array("publicado","ordem","perfil","ligados","temas","desc","ext","imagem","linkdireto","nome","outros"); | |
270 | - var par = ""; | |
271 | - for (var i=0;i<campos.length;i++) | |
272 | - { | |
273 | - par += "&"+campos[i]+"_mapa="+($i("E"+campos[i]+"_mapa").value); | |
199 | + ins += "<p>Link direto para abertura do mapa (despreza os outros parâmetros):<br>"; | |
200 | + ins += "<input size=50 type=text id=Elinkdireto_mapa value='"+i.linkdireto_mapa+"' /></p>"; | |
201 | + ins += "<br><br><br>"; | |
202 | + return(ins); | |
203 | + }, | |
204 | + filtra: function(letra){ | |
205 | + var i,temp, | |
206 | + n = i3GEOadmin.mapas.dados.length, | |
207 | + novo = []; | |
208 | + if(letra == "Todos"){ | |
209 | + novo = i3GEOadmin.mapas.dados; | |
210 | + } | |
211 | + else{ | |
212 | + for(i=0;i<n;i++){ | |
213 | + temp = i3GEOadmin.mapas.dados[i].nome_mapa; | |
214 | + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){ | |
215 | + novo.push(i3GEOadmin.mapas.dados[i]); | |
216 | + } | |
217 | + } | |
218 | + } | |
219 | + i3GEOadmin.mapas.tabela(novo); | |
220 | + }, | |
221 | + exclui: function(id,row){ | |
222 | + var mensagem = " excluindo o registro do id= "+id, | |
223 | + sUrl = "../php/mapas.php?funcao=excluirMapa&id="+id; | |
224 | + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.mapas.dataTable); | |
225 | + }, | |
226 | + salva: function(id,recordid){ | |
227 | + var i,c,sUrl, callback, | |
228 | + campos = i3GEOadmin.mapas.colunas, | |
229 | + par = "", | |
230 | + n = campos.length; | |
231 | + for (i=0;i<n;i++){ | |
232 | + c = $i("E"+campos[i].key); | |
233 | + if(c){ | |
234 | + par += "&"+campos[i].key+"="+(c.value); | |
235 | + } | |
236 | + } | |
237 | + par += "&id_mapa="+id; | |
238 | + core_carregando("ativa"); | |
239 | + core_carregando(" gravando o registro do id= "+id); | |
240 | + sUrl = "../php/mapas.php?funcao=alterarMapa"+par; | |
241 | + callback = { | |
242 | + success:function(o){ | |
243 | + try { | |
244 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") { | |
245 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem registros vinculados</span>"); | |
246 | + setTimeout("core_carregando('desativa')",3000); | |
247 | + } | |
248 | + else{ | |
249 | + var rec = i3GEOadmin.mapas.dataTable.getRecordSet().getRecord(recordid); | |
250 | + i3GEOadmin.mapas.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | |
251 | + core_carregando("desativa"); | |
252 | + } | |
253 | + } | |
254 | + catch(e){core_handleFailure(e,o.responseText);} | |
255 | + }, | |
256 | + failure:core_handleFailure, | |
257 | + argument: { foo:"foo", bar:"bar" } | |
258 | + }; | |
259 | + core_makeRequest(sUrl,callback); | |
274 | 260 | } |
275 | - par += "&id_mapa="+id; | |
276 | - core_carregando("ativa"); | |
277 | - core_carregando(" gravando o registro do id= "+id); | |
278 | - var sUrl = "../php/mapas.php?funcao=alterarMapa"+par; | |
279 | - var callback = | |
280 | - { | |
281 | - success:function(o) | |
282 | - { | |
283 | - try | |
284 | - { | |
285 | - if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | |
286 | - { | |
287 | - core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem víncilos com outros elementos</span>"); | |
288 | - setTimeout("core_carregando('desativa')",3000); | |
289 | - } | |
290 | - else | |
291 | - { | |
292 | - var rec = myDataTable.getRecordSet().getRecord(recordid); | |
293 | - myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | |
294 | - core_carregando("desativa"); | |
295 | - } | |
296 | - YAHOO.admin.container.panelEditorMapa.destroy(); | |
297 | - YAHOO.admin.container.panelEditorMapa = null; | |
298 | - } | |
299 | - catch(e){core_handleFailure(e,o.responseText);} | |
300 | - }, | |
301 | - failure:core_handleFailure, | |
302 | - argument: { foo:"foo", bar:"bar" } | |
303 | - }; | |
304 | - core_makeRequest(sUrl,callback); | |
305 | -} | |
306 | 261 | \ No newline at end of file |
262 | +}; | ... | ... |
admin/js/menu.js
... | ... | @@ -74,6 +74,8 @@ i3GEOadmin.menus = { |
74 | 74 | * Inicializa o menu |
75 | 75 | */ |
76 | 76 | inicia: function(){ |
77 | + YAHOO.namespace("admin.container"); | |
78 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
77 | 79 | YAHOO.namespace("menus"); |
78 | 80 | core_ativaBotaoAdicionaLinha("../php/menutemas.php?funcao=alteraMenus&publicado_menu=&perfil=&nome=&desc=&id=&aberto=","adicionaNovoMenu","i3GEOadmin.menus.obtem"); |
79 | 81 | i3GEOadmin.menus.obtem(); | ... | ... |
admin/js/subgrupos.js
... | ... | @@ -37,175 +37,203 @@ Inicializa o editor |
37 | 37 | |
38 | 38 | <ALTERASUBGRUPOS> |
39 | 39 | */ |
40 | -function initEditorSubGrupos() | |
41 | -{ | |
42 | - core_ativaBotaoAdicionaLinha("../php/menutemas.php?funcao=alteraSubGrupos","adicionaNovoSubGrupo","pegaSubGrupos_S"); | |
43 | - pegaSubGrupos_S(); | |
40 | +if(typeof(i3GEOadmin) === 'undefined'){ | |
41 | + var i3GEOadmin = {}; | |
44 | 42 | } |
45 | -/* | |
46 | -Function: pegaSubGrupos_S | |
47 | - | |
48 | -Obtém a lista de subgrupos | |
49 | - | |
50 | -<PEGASUBGRUPOS> | |
51 | -*/ | |
52 | -function pegaSubGrupos_S() | |
53 | -{ | |
54 | - dados_S = ""; | |
55 | - core_carregando("ativa"); | |
56 | - core_pegaDados("buscando sub-grupos...","../php/menutemas.php?funcao=pegaSubGrupos","montaTabela_S"); | |
57 | -} | |
58 | -function filtraDadosLetras_S(letra){ | |
59 | - var i,temp, | |
60 | - n = dados_S.length, | |
61 | - novo = []; | |
62 | - if(letra == "Todos"){ | |
63 | - novo = dados_S; | |
64 | - } | |
65 | - else{ | |
66 | - for(i=0;i<n;i++){ | |
67 | - temp = dados_S[i].nome_subgrupo; | |
68 | - if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){ | |
69 | - novo.push(dados_S[i]); | |
70 | - } | |
43 | +i3GEOadmin.subgrupos = { | |
44 | + dados: "", | |
45 | + dataTable: null, | |
46 | + colunas: ["it","es","en","desc_subgrupo","id_subgrupo","nome_subgrupo"], | |
47 | + formatTexto: function(elCell, oRecord, oColumn, oData){ | |
48 | + if(oData === ""){ | |
49 | + oData = "<span style='color:gray' ></span>"; | |
71 | 50 | } |
72 | - } | |
73 | - montaTabela_S(novo); | |
74 | -} | |
75 | -function montaTabela_S(dados) | |
76 | -{ | |
77 | - if(dados_S == ""){ | |
78 | - dados_S = dados; | |
79 | - } | |
80 | - core_listaDeLetras("letras_S","filtraDadosLetras_S"); | |
81 | - YAHOO.example.InlineCellEditing = new function() | |
82 | - { | |
83 | - // Custom formatter for "address" column to preserve line breaks | |
84 | - var formatTexto = function(elCell, oRecord, oColumn, oData) | |
85 | - { | |
86 | - if(oData === ""){ | |
87 | - oData = "<span style='color:gray' >Clique para editar, tecle enter e depois salve</span>"; | |
88 | - } | |
89 | - elCell.innerHTML = "<p style=width:250px;cursor:pointer title='clique para editar'>" + oData + "</p>"; | |
90 | - }; | |
91 | - var formatTextoId = function(elCell, oRecord, oColumn, oData) | |
92 | - { | |
93 | - elCell.innerHTML = "<p style=width:20px >" + oData + "</p>"; | |
94 | - }; | |
95 | - | |
96 | - var formatSalva = function(elCell, oRecord, oColumn) | |
97 | - { | |
98 | - elCell.innerHTML = "<div title='salva' class=salvar style='text-align:center' onclick='gravaLinha_S(\""+oRecord._sId+"\")'></div>"; | |
99 | - }; | |
100 | - var formatExclui = function(elCell, oRecord, oColumn) | |
101 | - { | |
102 | - elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>"; | |
103 | - }; | |
104 | - var myColumnDefs = [ | |
105 | - {key:"excluir",label:"excluir",formatter:formatExclui}, | |
106 | - {label:"salvar",formatter:formatSalva}, | |
107 | - {label:"id",key:"id_subgrupo", formatter:formatTextoId}, | |
108 | - {label:"nome",resizeable:true,key:"nome_subgrupo", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | |
109 | - {label:"descrição",resizeable:true,key:"desc_subgrupo", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | |
110 | - {label:"en",resizeable:true,key:"en", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | |
111 | - {label:"es",resizeable:true,key:"es", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | |
112 | - {label:"it",resizeable:true,key:"it", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})} | |
51 | + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>"; | |
52 | + }, | |
53 | + formatExclui: function(elCell, oRecord, oColumn){ | |
54 | + elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>"; | |
55 | + }, | |
56 | + formatMais: function(elCell, oRecord, oColumn){ | |
57 | + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | |
58 | + }, | |
59 | + defColunas: function(){ | |
60 | + return [ | |
61 | + {key:"excluir",label:"excluir",formatter:i3GEOadmin.subgrupos.formatExclui}, | |
62 | + {key:"mais",label:"editar",formatter:i3GEOadmin.subgrupos.formatMais}, | |
63 | + {label:"id",key:"id_subgrupo", formatter:i3GEOadmin.subgrupos.formatTexto}, | |
64 | + {label:"nome",resizeable:true,key:"nome_subgrupo", formatter:i3GEOadmin.subgrupos.formatTexto}, | |
65 | + {label:"descrição",resizeable:true,key:"desc_subgrupo", formatter:i3GEOadmin.subgrupos.formatTexto}, | |
66 | + {label:"en",resizeable:true,key:"en", formatter:i3GEOadmin.subgrupos.formatTexto}, | |
67 | + {label:"es",resizeable:true,key:"es", formatter:i3GEOadmin.subgrupos.formatTexto}, | |
68 | + {label:"it",resizeable:true,key:"it", formatter:i3GEOadmin.subgrupos.formatTexto} | |
113 | 69 | ]; |
114 | - myDataSource = new YAHOO.util.DataSource(dados); | |
115 | - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
116 | - myDataSource.responseSchema = | |
117 | - { | |
118 | - fields: ["it","es","en","desc_subgrupo","id_subgrupo","nome_subgrupo"] | |
119 | - }; | |
120 | - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | |
121 | - // Set up editing flow | |
122 | - myDataTable.highlightEditableCell = function(oArgs) | |
123 | - { | |
124 | - var elCell = oArgs.target; | |
125 | - var column = myDataTable.getColumn(oArgs.target); | |
126 | - //if(column.editor != "null") | |
127 | - if(!YAHOO.lang.isNull(column.editor)) | |
128 | - { | |
129 | - YAHOO.util.Dom.addClass(elCell,'yui-dt-highlighted'); | |
130 | - } | |
70 | + }, | |
71 | + /* | |
72 | + * Inicializa o menu | |
73 | + */ | |
74 | + inicia: function(){ | |
75 | + YAHOO.namespace("subgrupos"); | |
76 | + YAHOO.namespace("admin.container"); | |
77 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
78 | + core_ativaBotaoAdicionaLinha("../php/menutemas.php?funcao=alteraSubGrupos","adicionaNovoSubGrupo","i3GEOadmin.subgrupos.obtem"); | |
79 | + i3GEOadmin.subgrupos.obtem(); | |
80 | + }, | |
81 | + /* | |
82 | + * Obtém a lista de menus | |
83 | + */ | |
84 | + obtem: function(){ | |
85 | + i3GEOadmin.subgrupos.dados = ""; | |
86 | + core_carregando("ativa"); | |
87 | + core_pegaDados("buscando subgrupos...","../php/menutemas.php?funcao=pegaSubGrupos","i3GEOadmin.subgrupos.tabela"); | |
88 | + }, | |
89 | + tabela: function(dados){ | |
90 | + if(i3GEOadmin.subgrupos.dados == ""){ | |
91 | + i3GEOadmin.subgrupos.dados = dados; | |
92 | + } | |
93 | + core_listaDeLetras("letras_SG","i3GEOadmin.subgrupos.filtra"); | |
94 | + YAHOO.example.InlineCellEditing = new function(){ | |
95 | + // Custom formatter for "address" column to preserve line breaks | |
96 | + var myDataSource = new YAHOO.util.DataSource(dados); | |
97 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
98 | + myDataSource.responseSchema = { | |
99 | + fields: i3GEOadmin.subgrupos.colunas | |
100 | + }; | |
101 | + i3GEOadmin.subgrupos.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.subgrupos.defColunas(), myDataSource); | |
102 | + i3GEOadmin.subgrupos.dataTable.subscribe('cellClickEvent',function(ev){ | |
103 | + var sUrl, callback,$clicouId, $recordid, | |
104 | + target = YAHOO.util.Event.getTarget(ev), | |
105 | + column = this.getColumn(target), | |
106 | + registro = this.getRecord(target); | |
107 | + if(YAHOO.subgrupos.panelCK) { | |
108 | + YAHOO.subgrupos.panelCK.destroy(); | |
109 | + YAHOO.subgrupos.panelCK = null; | |
110 | + } | |
111 | + if (column.key == 'excluir'){ | |
112 | + i3GEOadmin.subgrupos.exclui(registro.getData('id_subgrupo'),target); | |
113 | + } | |
114 | + if (column.key == 'mais'){ | |
115 | + core_carregando("ativa"); | |
116 | + core_carregando("buscando dados..."); | |
117 | + $clicouId = registro.getData('id_subgrupo'); | |
118 | + $recordid = registro.getId(); | |
119 | + sUrl = "../php/menutemas.php?funcao=pegaSubGrupos&id_subgrupo="+$clicouId; | |
120 | + callback = { | |
121 | + success:function(o){ | |
122 | + try{ | |
123 | + i3GEOadmin.subgrupos.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | |
124 | + } | |
125 | + catch(e){core_handleFailure(e,o.responseText);} | |
126 | + }, | |
127 | + failure:core_handleFailure, | |
128 | + argument: { foo:"foo", bar:"bar" } | |
129 | + }; | |
130 | + core_makeRequest(sUrl,callback); | |
131 | + } | |
132 | + }); | |
131 | 133 | }; |
132 | - myDataTable.unhighlightEditableCell = function(oArgs) | |
133 | - { | |
134 | - var elCell = oArgs.target; | |
135 | - if(elCell.style.cursor="pointer") | |
136 | - { | |
137 | - YAHOO.util.Dom.removeClass(elCell,'yui-dt-highlighted'); | |
134 | + core_carregando("desativa"); | |
135 | + }, | |
136 | + editor: function(dados,id,recordid){ | |
137 | + function on_editorCheckBoxChange(p_oEvent){ | |
138 | + if(p_oEvent.newValue.get("value") == "OK"){ | |
139 | + i3GEOadmin.subgrupos.salva(id,recordid); | |
138 | 140 | } |
141 | + YAHOO.subgrupos.panelEditor2.destroy(); | |
142 | + YAHOO.subgrupos.panelEditor2 = null; | |
139 | 143 | }; |
140 | - myDataTable.subscribe("cellMouseoverEvent", myDataTable.highlightEditableCell); | |
141 | - myDataTable.subscribe("cellMouseoutEvent", myDataTable.unhighlightEditableCell); | |
142 | - myDataTable.subscribe('cellClickEvent',function(ev) | |
143 | - { | |
144 | - var target = YAHOO.util.Event.getTarget(ev); | |
145 | - var column = this.getColumn(target); | |
146 | - if(YAHOO.admin.container.panelCK) | |
147 | - { | |
148 | - YAHOO.admin.container.panelCK.destroy(); | |
149 | - YAHOO.admin.container.panelCK = null; | |
150 | - } | |
151 | - if (column.key == 'excluir') | |
152 | - { | |
153 | - var record = this.getRecord(target); | |
154 | - excluiLinha_S(record.getData('id_subgrupo'),target); | |
155 | - } | |
156 | - else | |
157 | - {this.onEventShowCellEditor(ev);} | |
158 | - }); | |
159 | - // Hook into custom event to customize save-flow of "radio" editor | |
160 | - myDataTable.subscribe("editorUpdateEvent", function(oArgs) | |
161 | - { | |
162 | - if(oArgs.editor.column.key === "active") | |
163 | - { | |
164 | - this.saveCellEditor(); | |
165 | - | |
144 | + if(!$i("janela_editor2")){ | |
145 | + var editorBotoes,ins, | |
146 | + novoel = document.createElement("div"); | |
147 | + novoel.id = "janela_editor2"; | |
148 | + ins = '<div class="hd">Editor</div>'; | |
149 | + ins += "<div class='bd' style='height:354px;overflow:auto'>"; | |
150 | + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>"; | |
151 | + ins += "<div id='letras_SG'></div>"; | |
152 | + novoel.innerHTML = ins; | |
153 | + | |
154 | + document.body.appendChild(novoel); | |
155 | + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" }); | |
156 | + editorBotoes.addButtons([ | |
157 | + { label: "Salva", value: "OK", checked: false}, | |
158 | + { label: "Cancela", value: "CANCEL", checked: false } | |
159 | + ]); | |
160 | + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | |
161 | + YAHOO.subgrupos.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"480px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
162 | + YAHOO.subgrupos.panelEditor2.render(); | |
163 | + } | |
164 | + YAHOO.subgrupos.panelEditor2.show(); | |
165 | + $i("editor_bd2").innerHTML = i3GEOadmin.subgrupos.formulario(dados[0]); | |
166 | + core_carregando("desativa"); | |
167 | + }, | |
168 | + formulario: function(i){ | |
169 | + var param = { | |
170 | + "linhas":[ | |
171 | + {titulo:"Nome padrão:",id:"Enome_subgrupo",size:"50",value:i.nome_subgrupo,tipo:"text",div:""}, | |
172 | + {titulo:"Descricao (opcional):",id:"Edesc_subgrupo",size:"50",value:i.desc_subgrupo,tipo:"text",div:""}, | |
173 | + {titulo:"Nome em inglês (opcional):",id:"Een",size:"50",value:i.en,tipo:"text",div:""}, | |
174 | + {titulo:"Espanhol (opcional):",id:"Ees",size:"50",value:i.es,tipo:"text",div:""}, | |
175 | + {titulo:"Italiano (opcional):",id:"Eit",size:"50",value:i.it,tipo:"text",div:""} | |
176 | + ] | |
177 | + }, | |
178 | + ins = ""; | |
179 | + ins += core_geraLinhas(param); | |
180 | + return(ins); | |
181 | + }, | |
182 | + filtra: function(letra){ | |
183 | + var i,temp, | |
184 | + n = i3GEOadmin.subgrupos.dados.length, | |
185 | + novo = []; | |
186 | + if(letra == "Todos"){ | |
187 | + novo = i3GEOadmin.subgrupos.dados; | |
188 | + } | |
189 | + else{ | |
190 | + for(i=0;i<n;i++){ | |
191 | + temp = i3GEOadmin.subgrupos.dados[i].nome_subgrupo; | |
192 | + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){ | |
193 | + novo.push(i3GEOadmin.subgrupos.dados[i]); | |
194 | + } | |
166 | 195 | } |
167 | - }); | |
168 | - myDataTable.subscribe("editorBlurEvent", function(oArgs) | |
169 | - { | |
170 | - this.cancelCellEditor(); | |
171 | - }); | |
172 | - myDataTable.subscribe("editorSaveEvent", function(oArgs) | |
173 | - { | |
174 | - if(oArgs.newData != oArgs.oldData){ | |
175 | - var linha = myDataTable.getTrEl(oArgs.editor.getRecord()); | |
176 | - linha.style.color = "blue"; | |
177 | - linha.style.textDecoration = "blink"; | |
196 | + } | |
197 | + i3GEOadmin.subgrupos.tabela(novo); | |
198 | + }, | |
199 | + exclui: function(id,row){ | |
200 | + var mensagem = " excluindo o registro do id= "+id, | |
201 | + sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=subgrupos"; | |
202 | + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.subgrupos.dataTable); | |
203 | + }, | |
204 | + salva: function(id,recordid){ | |
205 | + var i,c,sUrl, callback, | |
206 | + campos = i3GEOadmin.subgrupos.colunas, | |
207 | + par = "", | |
208 | + n = campos.length; | |
209 | + for (i=0;i<n;i++){ | |
210 | + c = $i("E"+campos[i].key); | |
211 | + if(c){ | |
212 | + par += "&"+campos[i].key+"="+(c.value); | |
178 | 213 | } |
179 | - }); | |
180 | - | |
181 | - }; | |
182 | - core_carregando("desativa"); | |
183 | -} | |
184 | -/* | |
185 | -Function: gravaLinha_S | |
186 | - | |
187 | -Aplica as alterações em um registro | |
188 | - | |
189 | -<ALTERASUBGRUPOS> | |
190 | -*/ | |
191 | -function gravaLinha_S(row) | |
192 | -{ | |
193 | - var r = myDataTable.getRecordSet().getRecord(row); | |
194 | - var id_subgrupo = r.getData("id_subgrupo"); | |
195 | - var nome_subgrupo = r.getData("nome_subgrupo"); | |
196 | - var desc_subgrupo = r.getData("desc_subgrupo"); | |
197 | - var en = r.getData("en"); | |
198 | - var es = r.getData("es"); | |
199 | - var it = r.getData("it"); | |
200 | - core_carregando("ativa"); | |
201 | - var mensagem = " gravando registro do id= "+id_subgrupo; | |
202 | - var sUrl = "../php/menutemas.php?funcao=alteraSubGrupos&nome="+nome_subgrupo+"&desc="+desc_subgrupo+"&id="+id_subgrupo+"&en="+en+"&es="+es+"&it="+it; | |
203 | - core_gravaLinha(mensagem,row,sUrl,"pegaSubGrupos_S"); | |
204 | -} | |
205 | -function excluiLinha_S(id,row) | |
206 | -{ | |
207 | - var mensagem = " excluindo o registro do id= "+id; | |
208 | - var sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=subgrupos"; | |
209 | - core_excluiLinha(sUrl,row,mensagem); | |
210 | -} | |
211 | -//YAHOO.util.Event.addListener(window, "load", initMenu); | |
212 | 214 | \ No newline at end of file |
215 | + } | |
216 | + par += "&id_subgrupo="+id; | |
217 | + core_carregando("ativa"); | |
218 | + core_carregando(" gravando o registro do id= "+id); | |
219 | + sUrl = "../php/menutemas.php?funcao=alteraSubGrupos"+par; | |
220 | + callback = { | |
221 | + success:function(o){ | |
222 | + try { | |
223 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") { | |
224 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem registros vinculados</span>"); | |
225 | + setTimeout("core_carregando('desativa')",3000); | |
226 | + } | |
227 | + else{ | |
228 | + var rec = i3GEOadmin.subgrupos.dataTable.getRecordSet().getRecord(recordid); | |
229 | + i3GEOadmin.subgrupos.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | |
230 | + core_carregando("desativa"); | |
231 | + } | |
232 | + } | |
233 | + catch(e){core_handleFailure(e,o.responseText);} | |
234 | + }, | |
235 | + failure:core_handleFailure, | |
236 | + argument: { foo:"foo", bar:"bar" } | |
237 | + }; | |
238 | + core_makeRequest(sUrl,callback); | |
239 | + } | |
240 | +}; | |
213 | 241 | \ No newline at end of file | ... | ... |
admin/js/webservices.js
... | ... | @@ -29,256 +29,235 @@ Arquivo: |
29 | 29 | |
30 | 30 | i3geo/admin/js/webservices.js |
31 | 31 | */ |
32 | -YAHOO.namespace("admin.container"); | |
33 | -/* | |
34 | -Function: initMenu | |
35 | - | |
36 | -Inicializa o editor | |
37 | - | |
38 | -<ALTERARWS> | |
39 | -*/ | |
40 | -function initMenu() | |
41 | -{ | |
42 | - core_ativaBotaoAdicionaLinha("../php/webservices.php?funcao=alterarWS","adiciona"); | |
43 | - core_carregando("ativa"); | |
44 | - core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
45 | - pegaWS(); | |
46 | -} | |
47 | -/* | |
48 | -Function: pegaWS | |
49 | - | |
50 | -Obtém a lista de WS | |
51 | - | |
52 | -<PEGAWS> | |
53 | -*/ | |
54 | -function pegaWS() | |
55 | -{ | |
56 | - // | |
57 | - //pega o tipo de WS que será listado se tiver sido definido na url | |
58 | - // | |
59 | - var tipows = "",u; | |
60 | - try{ | |
61 | - u = window.location.href.split("?"); | |
62 | - u = u[1].split("="); | |
63 | - tipows = u[1]; | |
64 | - } | |
65 | - catch(e){tipows = "";} | |
66 | - core_pegaDados("buscando endereços...","../php/webservices.php?funcao=pegaWS&tipows="+tipows,"montaTabela"); | |
32 | +if(typeof(i3GEOadmin) === 'undefined'){ | |
33 | + var i3GEOadmin = {}; | |
67 | 34 | } |
68 | -/* | |
69 | -Function: montaTabela | |
70 | - | |
71 | -Monta a tabela de edição | |
72 | - | |
73 | -<PEGADADOS> | |
74 | -*/ | |
75 | -function montaTabela(dados) | |
76 | -{ | |
77 | - YAHOO.example.InlineCellEditing = new function() | |
78 | - { | |
79 | - // Custom formatter for "address" column to preserve line breaks | |
80 | - var formatTextoId = function(elCell, oRecord, oColumn, oData) | |
81 | - { | |
82 | - elCell.innerHTML = "<p>" + oData + "</p>"; | |
35 | +i3GEOadmin.webservices = { | |
36 | + dados: "", | |
37 | + dataTable: null, | |
38 | + colunas: ["id_ws","desc_ws","nome_ws","link_ws","tipo_ws","autor_ws"], | |
39 | + formatTexto: function(elCell, oRecord, oColumn, oData){ | |
40 | + if(oData === ""){ | |
41 | + oData = "<span style='color:gray' ></span>"; | |
42 | + } | |
43 | + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>"; | |
44 | + }, | |
45 | + formatExclui: function(elCell, oRecord, oColumn){ | |
46 | + elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>"; | |
47 | + }, | |
48 | + formatMais: function(elCell, oRecord, oColumn){ | |
49 | + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | |
50 | + }, | |
51 | + defColunas: function(){ | |
52 | + return [ | |
53 | + {key:"excluir",label:"excluir",formatter:i3GEOadmin.webservices.formatExclui}, | |
54 | + {key:"mais",label:"editar",formatter:i3GEOadmin.webservices.formatMais}, | |
55 | + {label:"id",key:"id_ws", formatter:i3GEOadmin.webservices.formatTexto}, | |
56 | + {label:"nome",resizeable:true,key:"nome_ws", formatter:i3GEOadmin.webservices.formatTexto}, | |
57 | + {label:"tipo",resizeable:true,key:"tipo_ws", formatter:i3GEOadmin.webservices.formatTexto} | |
58 | + ]; | |
59 | + }, | |
60 | + /* | |
61 | + * Inicializa o menu | |
62 | + */ | |
63 | + inicia: function(){ | |
64 | + YAHOO.namespace("webservices"); | |
65 | + YAHOO.namespace("admin.container"); | |
66 | + core_ativaPainelAjuda("ajuda","botaoAjuda"); | |
67 | + core_ativaBotaoAdicionaLinha("../php/webservices.php?funcao=alterarWS","adicionaNovoWebservice","i3GEOadmin.webservices.obtem"); | |
68 | + i3GEOadmin.webservices.obtem(); | |
69 | + }, | |
70 | + /* | |
71 | + * Obtém a lista de menus | |
72 | + */ | |
73 | + obtem: function(){ | |
74 | + i3GEOadmin.webservices.dados = ""; | |
75 | + core_carregando("ativa"); | |
76 | + var tipows = "",u; | |
77 | + try{ | |
78 | + u = window.location.href.split("?"); | |
79 | + u = u[1].split("="); | |
80 | + tipows = u[1]; | |
81 | + } | |
82 | + catch(e){tipows = "";} | |
83 | + core_pegaDados("buscando endereços...","../php/webservices.php?funcao=pegaWS&tipows="+tipows,"i3GEOadmin.webservices.tabela"); | |
84 | + }, | |
85 | + tabela: function(dados){ | |
86 | + if(i3GEOadmin.webservices.dados == ""){ | |
87 | + i3GEOadmin.webservices.dados = dados; | |
88 | + } | |
89 | + core_listaDeLetras("letras_W","i3GEOadmin.webservices.filtra"); | |
90 | + YAHOO.example.InlineCellEditing = new function(){ | |
91 | + // Custom formatter for "address" column to preserve line breaks | |
92 | + var myDataSource = new YAHOO.util.DataSource(dados); | |
93 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
94 | + myDataSource.responseSchema = { | |
95 | + fields: i3GEOadmin.webservices.colunas | |
96 | + }; | |
97 | + i3GEOadmin.webservices.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.webservices.defColunas(), myDataSource); | |
98 | + i3GEOadmin.webservices.dataTable.subscribe('cellClickEvent',function(ev){ | |
99 | + var sUrl, callback,$clicouId, $recordid, | |
100 | + target = YAHOO.util.Event.getTarget(ev), | |
101 | + column = this.getColumn(target), | |
102 | + registro = this.getRecord(target); | |
103 | + if(YAHOO.webservices.panelCK) { | |
104 | + YAHOO.webservices.panelCK.destroy(); | |
105 | + YAHOO.webservices.panelCK = null; | |
106 | + } | |
107 | + if (column.key == 'excluir'){ | |
108 | + i3GEOadmin.webservices.exclui(registro.getData('id_ws'),target); | |
109 | + } | |
110 | + if (column.key == 'mais'){ | |
111 | + core_carregando("ativa"); | |
112 | + core_carregando("buscando dados..."); | |
113 | + $clicouId = registro.getData('id_ws'); | |
114 | + $recordid = registro.getId(); | |
115 | + sUrl = "../php/webservices.php?funcao=pegaDados&id_ws="+$clicouId; | |
116 | + callback = { | |
117 | + success:function(o){ | |
118 | + try{ | |
119 | + i3GEOadmin.webservices.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | |
120 | + } | |
121 | + catch(e){core_handleFailure(e,o.responseText);} | |
122 | + }, | |
123 | + failure:core_handleFailure, | |
124 | + argument: { foo:"foo", bar:"bar" } | |
125 | + }; | |
126 | + core_makeRequest(sUrl,callback); | |
127 | + } | |
128 | + }); | |
83 | 129 | }; |
84 | - var formatMais = function(elCell, oRecord, oColumn) | |
85 | - { | |
86 | - elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | |
130 | + core_carregando("desativa"); | |
131 | + }, | |
132 | + editor: function(dados,id,recordid){ | |
133 | + function on_editorCheckBoxChange(p_oEvent){ | |
134 | + if(p_oEvent.newValue.get("value") == "OK"){ | |
135 | + i3GEOadmin.webservices.salva(id,recordid); | |
136 | + } | |
137 | + YAHOO.webservices.panelEditor2.destroy(); | |
138 | + YAHOO.webservices.panelEditor2 = null; | |
87 | 139 | }; |
88 | - var formatExclui = function(elCell, oRecord, oColumn) | |
89 | - { | |
90 | - elCell.innerHTML = "<div class=excluir style='text-align:center' ></div>"; | |
140 | + if(!$i("janela_editor2")){ | |
141 | + var editorBotoes,ins, | |
142 | + novoel = document.createElement("div"); | |
143 | + novoel.id = "janela_editor2"; | |
144 | + ins = '<div class="hd">Editor</div>'; | |
145 | + ins += "<div class='bd' style='height:354px;overflow:auto'>"; | |
146 | + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>"; | |
147 | + ins += "<div id='letras_W'></div>"; | |
148 | + novoel.innerHTML = ins; | |
149 | + | |
150 | + document.body.appendChild(novoel); | |
151 | + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" }); | |
152 | + editorBotoes.addButtons([ | |
153 | + { label: "Salva", value: "OK", checked: false}, | |
154 | + { label: "Cancela", value: "CANCEL", checked: false } | |
155 | + ]); | |
156 | + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | |
157 | + YAHOO.webservices.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"480px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
158 | + YAHOO.webservices.panelEditor2.render(); | |
159 | + } | |
160 | + YAHOO.webservices.panelEditor2.show(); | |
161 | + $i("editor_bd2").innerHTML = i3GEOadmin.webservices.formulario(dados[0]); | |
162 | + core_carregando("desativa"); | |
163 | + }, | |
164 | + formulario: function(i){ | |
165 | + var param = { | |
166 | + "linhas":[ | |
167 | + {titulo:"Nome:",id:"Enome_ws",size:"50",value:i.nome_ws,tipo:"text",div:""}, | |
168 | + {titulo:"Descrição:",id:"Edesc_ws",size:"50",value:i.desc_ws,tipo:"text",div:""}, | |
169 | + {titulo:"Autor:",id:"Eautor_ws",size:"50",value:i.autor_ws,tipo:"text",div:""}, | |
170 | + {titulo:"Endereço:",id:"Elink_ws",size:"50",value:i.link_ws,tipo:"text",div:""} | |
171 | + ] | |
91 | 172 | }; |
92 | - var myColumnDefs = [ | |
93 | - {key:"excluir",label:"excluir",formatter:formatExclui}, | |
94 | - {key:"mais",label:"editar",formatter:formatMais}, | |
95 | - {label:"id",key:"id_ws", formatter:formatTextoId}, | |
96 | - {label:"tipo",key:"tipo_ws", formatter:formatTextoId}, | |
97 | - {label:"nome",key:"nome_ws", formatter:formatTextoId}, | |
98 | - ]; | |
99 | - myDataSource = new YAHOO.util.DataSource(dados); | |
100 | - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
101 | - myDataSource.responseSchema = | |
102 | - {fields: ["id_ws","nome_ws","tipo_ws"]}; | |
103 | - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | |
104 | - // Set up editing flow | |
105 | - myDataTable.subscribe('cellClickEvent',function(ev) | |
106 | - { | |
107 | - var target = YAHOO.util.Event.getTarget(ev); | |
108 | - var column = this.getColumn(target); | |
109 | - if (column.key == 'excluir') | |
110 | - { | |
111 | - var record = this.getRecord(target); | |
112 | - excluiLinha(record.getData('id_ws'),target); | |
113 | - } | |
114 | - if (column.key == 'mais') | |
115 | - { | |
116 | - var record = this.getRecord(target); | |
117 | - core_carregando("ativa"); | |
118 | - core_carregando("buscando dados..."); | |
119 | - $clicouId = record.getData('id_ws'); | |
120 | - $recordid = record.getId(); | |
121 | - var sUrl = "../php/webservices.php?funcao=pegaDados&id_ws="+record.getData('id_ws'); | |
122 | - var callback = | |
123 | - { | |
124 | - success:function(o) | |
125 | - { | |
126 | - try | |
127 | - { | |
128 | - montaEditor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | |
129 | - } | |
130 | - catch(e){core_handleFailure(e,o.responseText);} | |
131 | - }, | |
132 | - failure:core_handleFailure, | |
133 | - argument: { foo:"foo", bar:"bar" } | |
134 | - }; | |
135 | - core_makeRequest(sUrl,callback); | |
136 | - } | |
173 | + var ins = ""; | |
174 | + ins += core_geraLinhas(param); | |
137 | 175 | |
138 | - }); | |
139 | - // Hook into custom event to customize save-flow of "radio" editor | |
140 | - myDataTable.subscribe("editorUpdateEvent", function(oArgs) | |
141 | - { | |
142 | - if(oArgs.editor.column.key === "active") | |
143 | - { | |
144 | - this.saveCellEditor(); | |
176 | + ins += "<p>Tipo:<br>"; | |
177 | + ins += "<select id='Etipo_ws' />"; | |
178 | + ins += "<option value='' "; | |
179 | + if (i.tipo_ws == ""){ins += "selected";} | |
180 | + ins += ">---</option>"; | |
181 | + ins += "<option value='KML' "; | |
182 | + if (i.tipo_ws == "KML"){ins += "selected";} | |
183 | + ins += " >KML</option>"; | |
184 | + ins += "<option value='WMS' "; | |
185 | + if (i.tipo_ws == "WMS"){ins += "selected";} | |
186 | + ins += " >WMS</option>"; | |
187 | + ins += "<option value='WMS-Tile' "; | |
188 | + if (i.tipo_ws == "WMS-Tile"){ins += "selected";} | |
189 | + ins += " >WMS-Tile</option>"; | |
190 | + ins += "<option value='GEORSS' "; | |
191 | + if (i.tipo_ws == "GEORSS"){ins += "selected";} | |
192 | + ins += " >GEORSS</option>"; | |
193 | + ins += "<option value='WS' "; | |
194 | + if (i.tipo_ws == "WS"){ins += "selected";} | |
195 | + ins += " >WS</option>"; | |
196 | + ins += "<option value='DOWNLOAD' "; | |
197 | + if (i.tipo_ws == "DOWNLOAD"){ins += "selected";} | |
198 | + ins += " >DOWNLOAD</option>"; | |
199 | + ins += "<option value='GEOJSON' "; | |
200 | + if (i.tipo_ws == "GEOJSON"){ins += "selected";} | |
201 | + ins += " >GEOJSON</option>"; | |
202 | + | |
203 | + ins += "</select></p>"; | |
204 | + return(ins); | |
205 | + }, | |
206 | + filtra: function(letra){ | |
207 | + var i,temp, | |
208 | + n = i3GEOadmin.webservices.dados.length, | |
209 | + novo = []; | |
210 | + if(letra == "Todos"){ | |
211 | + novo = i3GEOadmin.webservices.dados; | |
212 | + } | |
213 | + else{ | |
214 | + for(i=0;i<n;i++){ | |
215 | + temp = i3GEOadmin.webservices.dados[i].nome_ws; | |
216 | + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){ | |
217 | + novo.push(i3GEOadmin.webservices.dados[i]); | |
218 | + } | |
145 | 219 | } |
146 | - }); | |
147 | - myDataTable.subscribe("editorBlurEvent", function(oArgs) | |
148 | - { | |
149 | - this.cancelCellEditor(); | |
150 | - }); | |
151 | - }; | |
152 | - core_carregando("desativa"); | |
153 | -} | |
154 | -function montaEditor(dados,id,recordid) | |
155 | -{ | |
156 | - function on_editorCheckBoxChange(p_oEvent) | |
157 | - { | |
158 | - if(p_oEvent.newValue.get("value") == "OK") | |
159 | - { | |
160 | - gravaDados(id,recordid); | |
161 | 220 | } |
162 | - else | |
163 | - { | |
164 | - YAHOO.admin.container.panelEditor.destroy(); | |
165 | - YAHOO.admin.container.panelEditor = null; | |
221 | + i3GEOadmin.webservices.tabela(novo); | |
222 | + }, | |
223 | + exclui: function(id,row){ | |
224 | + var mensagem = " excluindo o registro do id= "+id, | |
225 | + sUrl = "../php/webservices.php?funcao=excluir&id="+id; | |
226 | + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.webservices.dataTable); | |
227 | + }, | |
228 | + salva: function(id,recordid){ | |
229 | + var i,c,sUrl, callback, | |
230 | + campos = i3GEOadmin.webservices.colunas, | |
231 | + par = "", | |
232 | + n = campos.length; | |
233 | + for (i=0;i<n;i++){ | |
234 | + c = $i("E"+campos[i].key); | |
235 | + if(c){ | |
236 | + par += "&"+campos[i].key+"="+(c.value); | |
237 | + } | |
166 | 238 | } |
167 | - }; | |
168 | - if(!YAHOO.admin.container.panelEditor) | |
169 | - { | |
170 | - var novoel = document.createElement("div"); | |
171 | - novoel.id = "janela_editor"; | |
172 | - var ins = '<div class="hd">Editor</div>'; | |
173 | - ins += "<div class='bd' style='height:354px;overflow:auto'>"; | |
174 | - ins += "<div id='okcancel_checkbox'></div><div id='editor_bd'></div>"; | |
175 | - novoel.innerHTML = ins; | |
176 | - document.body.appendChild(novoel); | |
177 | - var editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id", name: "okcancel_checkbox_id", container: "okcancel_checkbox" }); | |
178 | - editorBotoes.addButtons([ | |
179 | - { label: "Salva", value: "OK", checked: false}, | |
180 | - { label: "Cancela", value: "CANCEL", checked: false } | |
181 | - ]); | |
182 | - editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | |
183 | - YAHOO.admin.container.panelEditor = new YAHOO.widget.Panel("janela_editor", { fixedcenter:true,close:false,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } ); | |
184 | - YAHOO.admin.container.panelEditor.render(); | |
239 | + par += "&id_ws="+id; | |
240 | + core_carregando("ativa"); | |
241 | + core_carregando(" gravando o registro do id= "+id); | |
242 | + sUrl = "../php/webservices.php?funcao=alterarWS"+par; | |
243 | + callback = { | |
244 | + success:function(o){ | |
245 | + try { | |
246 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") { | |
247 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem registros vinculados</span>"); | |
248 | + setTimeout("core_carregando('desativa')",3000); | |
249 | + } | |
250 | + else{ | |
251 | + var rec = i3GEOadmin.webservices.dataTable.getRecordSet().getRecord(recordid); | |
252 | + i3GEOadmin.webservices.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | |
253 | + core_carregando("desativa"); | |
254 | + } | |
255 | + } | |
256 | + catch(e){core_handleFailure(e,o.responseText);} | |
257 | + }, | |
258 | + failure:core_handleFailure, | |
259 | + argument: { foo:"foo", bar:"bar" } | |
260 | + }; | |
261 | + core_makeRequest(sUrl,callback); | |
185 | 262 | } |
186 | - YAHOO.admin.container.panelEditor.show(); | |
187 | - //carrega os dados na janela | |
188 | - $i("editor_bd").innerHTML = montaDiv(dados[0]); | |
189 | - core_carregando("desativa"); | |
190 | -} | |
191 | -function montaDiv(i) | |
192 | -{ | |
193 | - var param = { | |
194 | - "linhas":[ | |
195 | - {titulo:"Nome:",id:"Enome_ws",size:"50",value:i.nome_ws,tipo:"text",div:""}, | |
196 | - {titulo:"Descrição:",id:"Edesc_ws",size:"50",value:i.desc_ws,tipo:"text",div:""}, | |
197 | - {titulo:"Autor:",id:"Eautor_ws",size:"50",value:i.autor_ws,tipo:"text",div:""}, | |
198 | - {titulo:"Endereço:",id:"Elink_ws",size:"50",value:i.link_ws,tipo:"text",div:""} | |
199 | - ] | |
200 | - }; | |
201 | - var ins = ""; | |
202 | - ins += core_geraLinhas(param); | |
203 | - | |
204 | - ins += "<p>Tipo:<br>"; | |
205 | - ins += "<select id='Etipo_ws' />"; | |
206 | - ins += "<option value='' "; | |
207 | - if (i.tipo_ws == ""){ins += "selected";} | |
208 | - ins += ">---</option>"; | |
209 | - ins += "<option value='KML' "; | |
210 | - if (i.tipo_ws == "KML"){ins += "selected";} | |
211 | - ins += " >KML</option>"; | |
212 | - ins += "<option value='WMS' "; | |
213 | - if (i.tipo_ws == "WMS"){ins += "selected";} | |
214 | - ins += " >WMS</option>"; | |
215 | - ins += "<option value='WMS-Tile' "; | |
216 | - if (i.tipo_ws == "WMS-Tile"){ins += "selected";} | |
217 | - ins += " >WMS-Tile</option>"; | |
218 | - ins += "<option value='GEORSS' "; | |
219 | - if (i.tipo_ws == "GEORSS"){ins += "selected";} | |
220 | - ins += " >GEORSS</option>"; | |
221 | - ins += "<option value='WS' "; | |
222 | - if (i.tipo_ws == "WS"){ins += "selected";} | |
223 | - ins += " >WS</option>"; | |
224 | - ins += "<option value='DOWNLOAD' "; | |
225 | - if (i.tipo_ws == "DOWNLOAD"){ins += "selected";} | |
226 | - ins += " >DOWNLOAD</option>"; | |
227 | - ins += "<option value='GEOJSON' "; | |
228 | - if (i.tipo_ws == "GEOJSON"){ins += "selected";} | |
229 | - ins += " >GEOJSON</option>"; | |
230 | - | |
231 | - ins += "</select></p>"; | |
232 | - return(ins); | |
233 | -} | |
234 | -function excluiLinha(id,row) | |
235 | -{ | |
236 | - var mensagem = " excluindo o registro do id= "+id; | |
237 | - var sUrl = "../php/webservices.php?funcao=excluir&id="+id; | |
238 | - core_excluiLinha(sUrl,row,mensagem); | |
239 | -} | |
240 | -/* | |
241 | -Function: gravaDados | |
242 | - | |
243 | -Aplica as alterações feitas em um WS | |
244 | - | |
245 | -<ALTERARWS> | |
246 | -*/ | |
247 | -function gravaDados(id,recordid) | |
248 | -{ | |
249 | - var campos = new Array("desc","nome","link","tipo","autor"), | |
250 | - par = "", | |
251 | - i; | |
252 | - for (i=0;i<campos.length;i++) | |
253 | - {par += "&"+campos[i]+"_ws="+($i("E"+campos[i]+"_ws").value);} | |
254 | - par += "&id_ws="+id; | |
255 | - core_carregando("ativa"); | |
256 | - core_carregando(" gravando o registro do id= "+id); | |
257 | - var sUrl = "../php/webservices.php?funcao=alterarWS"+par; | |
258 | - var callback = | |
259 | - { | |
260 | - success:function(o) | |
261 | - { | |
262 | - try | |
263 | - { | |
264 | - if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | |
265 | - { | |
266 | - core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem registros vinculados</span>"); | |
267 | - setTimeout("core_carregando('desativa')",3000); | |
268 | - } | |
269 | - else | |
270 | - { | |
271 | - var rec = myDataTable.getRecordSet().getRecord(recordid); | |
272 | - myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | |
273 | - core_carregando("desativa"); | |
274 | - } | |
275 | - YAHOO.admin.container.panelEditor.destroy(); | |
276 | - YAHOO.admin.container.panelEditor = null; | |
277 | - } | |
278 | - catch(e){core_handleFailure(e,o.responseText);} | |
279 | - }, | |
280 | - failure:core_handleFailure, | |
281 | - argument: { foo:"foo", bar:"bar" } | |
282 | - }; | |
283 | - core_makeRequest(sUrl,callback); | |
284 | -} | |
285 | 263 | \ No newline at end of file |
264 | +}; | |
286 | 265 | \ No newline at end of file | ... | ... |
admin/php/menutemas.php
... | ... | @@ -308,7 +308,12 @@ switch (strtoupper($funcao)) |
308 | 308 | {JSON} |
309 | 309 | */ |
310 | 310 | case "PEGASUBGRUPOS": |
311 | - $dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_subgrupos order by nome_subgrupo"); | |
311 | + if(isset($id_grupo) && $id_grupo != "") { | |
312 | + $dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_subgrupos WHERE id_subgrupo = $id_subgrupo order by nome_subgrupo"); | |
313 | + } | |
314 | + else{ | |
315 | + $dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_subgrupos order by nome_subgrupo"); | |
316 | + } | |
312 | 317 | retornaJSON($dados); |
313 | 318 | exit; |
314 | 319 | break; |
... | ... | @@ -355,7 +360,13 @@ switch (strtoupper($funcao)) |
355 | 360 | {JSON} |
356 | 361 | */ |
357 | 362 | case "ALTERASUBGRUPOS": |
358 | - retornaJSON(alteraSubGrupos()); | |
363 | + alteraSubGrupos(); | |
364 | + if(isset($id_subgrupo) && $id_subgrupo != "") { | |
365 | + retornaJSON(pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_subgrupos WHERE id_subgrupo = $id_subgrupo")); | |
366 | + } | |
367 | + else{ | |
368 | + retornaJSON("ok"); | |
369 | + } | |
359 | 370 | exit; |
360 | 371 | break; |
361 | 372 | /* |
... | ... | @@ -1028,25 +1039,21 @@ function alteraGrupos() |
1028 | 1039 | */ |
1029 | 1040 | function alteraSubGrupos() |
1030 | 1041 | { |
1031 | - global $nome,$desc,$id,$en,$es,$it,$esquemaadmin; | |
1032 | - try | |
1033 | - { | |
1042 | + global $nome_subgrupo,$desc_subgrupo,$id_subgrupo,$en,$es,$it,$esquemaadmin; | |
1043 | + try{ | |
1034 | 1044 | require_once("conexao.php"); |
1035 | - if($convUTF) | |
1036 | - { | |
1037 | - $nome = utf8_encode($nome); | |
1038 | - $desc = utf8_encode($desc); | |
1045 | + if($convUTF){ | |
1046 | + $nome_subgrupo = utf8_encode($nome_subgrupo); | |
1047 | + $desc_subgrupo = utf8_encode($desc_subgrupo); | |
1039 | 1048 | $en = utf8_encode($en); |
1040 | 1049 | $es = utf8_encode($es); |
1041 | 1050 | $it = utf8_encode($it); |
1042 | 1051 | } |
1043 | 1052 | $retorna = ""; |
1044 | - if($id != "") | |
1045 | - { | |
1046 | - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_subgrupos SET en = '$en', es = '$es', it = '$it', nome_subgrupo = '$nome', desc_subgrupo = '$desc' WHERE id_subgrupo = $id"); | |
1053 | + if($id_subgrupo != ""){ | |
1054 | + $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_subgrupos SET en = '$en', es = '$es', it = '$it', nome_subgrupo = '$nome_subgrupo', desc_subgrupo = '$desc_subgrupo' WHERE id_subgrupo = $id_subgrupo"); | |
1047 | 1055 | } |
1048 | - else | |
1049 | - { | |
1056 | + else{ | |
1050 | 1057 | $dbhw->query("INSERT INTO ".$esquemaadmin."i3geoadmin_subgrupos (nome_subgrupo, desc_subgrupo, en, es, it) VALUES ('', '','','','')"); |
1051 | 1058 | } |
1052 | 1059 | $dbhw = null; | ... | ... |