1
{% extends "../../base-foto.html" %}
4
<script type="text/javascript">
5
var REGISTRY_ID = '{{REGISTRY_ID}}';
6
var LISTA_ACOES = {{LISTA_ACOES}};
8
// Retorna valor de URL e folder da acao
10
function findAction(acao) {
11
for (item in LISTA_ACOES) {
12
if (acao == LISTA_ACOES[item]["acao"]) {
13
return LISTA_ACOES[item];
19
// Analisa se tem ações com mesmo número
21
function EqualOrdem() {
22
ordens = document.getElementsByName("ordem");
23
for (i=0; i<ordens.length-1; i++) {
24
for (j=i+1; j<ordens.length; j++){
25
if (ordens[i].value == ordens[j].value){
26
alert ("Existe mais de uma linha com o mesmo número de ordem.");
34
// Define novos limites máximos para os números de ordem de cada linha
35
// Chamado ao excluir ou incluir uma ação
37
function resetMaxOrdensInput(){
38
var ordens = document.getElementsByName("ordem");
39
for (i=0; i<ordens.length; i++) {
40
ordens[i].max = ordens.length;
44
// crítica do formulário de inclusão de um nova ação
47
if ( $("#newacao").val() == "" ) {
48
alert ("Selecione uma Ação.");
51
if ( !$("#url").prop('disabled') && !($("#url").val()) ) {
52
alert ("Selecione uma Localização.");
62
// Exibe lista de folders
64
function enableFolderAndUrl(){
66
$("#newcomplemento").val("");
69
$("#url").prop('disabled', true);
73
$("#folder").prop('disabled', true);
77
var action = findAction($("#newacao").val());
78
if (action["url"] != 'S') {
81
$("#criar_novo").hide();
83
if (action["folder"] != 'S') {
86
$("#url").prop('disabled', true);
88
$("#folder").prop('disabled', true);
92
// criar wiki e enviar arquivo
94
$("#url").prop('disabled', true);
97
$("#folder").prop('disabled', false);
101
$.ajax({url: "/rest/"+action["service"]+"/folder/"+REGISTRY_ID,
103
success: function(response) {
104
// select to be modified
105
sel = document.getElementById("folder")
107
// remove all old options
108
$('#folder').empty();
110
// and then create the new ones
111
var opt = document.createElement("option");
112
opt.value = "default"; opt.innerHTML = "usar a pasta padrão";
113
sel.appendChild(opt);
115
for (item in response.itens) {
116
opt = document.createElement("option");
117
opt.value = response.itens[item][0];
118
opt.innerHTML = response.itens[item][1];
119
sel.appendChild(opt);
130
$("#criar_novo").show();
131
$("#criar_novo > a").attr("href", "/"+action["service"]+"/"+REGISTRY_ID);
133
$("#url").prop('disabled', false);
136
if (action["folder"] == 'S') {
137
// tem folder (consultar arquivo e ler wiki)
139
$("#folder").prop('disabled', false);
142
$.ajax({url: "/rest/"+action["service"]+"/folder/"+REGISTRY_ID,
144
success: function(response) {
145
// select to be modified
146
sel = document.getElementById("folder")
148
// remove all old options
149
$('#folder').empty();
151
// and then create the new ones
152
var opt = document.createElement("option");
153
opt.value = ""; opt.innerHTML = "selecione uma pasta";
154
sel.appendChild(opt);
156
for (item in response.itens) {
157
opt = document.createElement("option");
158
opt.value = response.itens[item][0];
159
opt.innerHTML = response.itens[item][1];
160
sel.appendChild(opt);
166
// não tem folder (publicar no forum, consultar favoritos e assistir videoaula)
168
$.ajax({url: "/rest/"+action["service"]+"/list/"+REGISTRY_ID,
170
success: function(response) {
171
// select to be modified
172
sel = document.getElementById("url")
174
// remove all old options
177
// and then create the new ones
178
var opt = document.createElement("option");
179
opt.value = ''; opt.innerHTML = '';
180
sel.appendChild(opt);
181
for (item in response.itens) {
182
opt = document.createElement("option");
183
opt.value = '/'+action["service"]+'/' + REGISTRY_ID + '/' + response.itens[item];
184
opt.innerHTML = response.itens[item];
185
sel.appendChild(opt);
195
// Exibe lista de arquivos de um folder
197
function changeUrlList(folder) {
198
var action = findAction($("#newacao").val());
199
$.ajax({url: "/rest/"+action["service"]+"/list/"+REGISTRY_ID+"?folder="+folder,
201
success: function(response) {
202
// obj = JSON && JSON.parse(response.itens) || $.parseJSON(response.itens);
203
// select to be modified
204
sel = document.getElementById("url")
206
// remove all old options
209
// and then create the new ones
210
for(item in response.itens) {
211
var opt = document.createElement("option");
212
opt.value = '/'+action["service"]+'/' + REGISTRY_ID + '/' + response.itens[item];
213
console.log(response.itens[item]);
214
opt.innerHTML = response.itens[item];
215
sel.appendChild(opt);
222
// callback associada ao link para excluir ação (ícone da lixeira).
224
function onDeleteAction() {
226
if ( !confirm('Deseja realmente remover esta ação da tarefa?') )
235
// pega valor de pos no tr correspondente
236
var tr = $(this).closest('tr');
237
var pos = tr.attr("pos");
239
$.ajax({url: "/task/action/delete/{{REGISTRY_ID}}/{{TASKDATA['name_id']}}?pos=" + pos,
241
success: function(response) {
242
if (response.status==0) {
243
// tr.css("background-color","#FF3700");
244
tr.fadeOut(400, function(){
246
resetMaxOrdensInput();
257
// campos para folder e URL entra escondido. só aparecerá se necessário.
260
$("#criar_novo").hide();
262
// Callback chamada ao escolher um folder
263
$("#folder").change(function() {
264
changeUrlList(this.options[this.selectedIndex].value);
267
// callback no botão para incluir nova ação
268
$("#b_newAction").click(function() {
270
var action = findAction($("#newacao").val());
271
var url_corrigida = $("#url").val();
273
// se criar página ou enviar arquivo descarta o que vem na URL pois ela será montada no controlador chamado por ajax
274
if (action["url"] == "N" && action["folder"] == "S"){
275
url_corrigida = null;
278
$.ajax({url: "/task/action/new/{{REGISTRY_ID}}/{{TASKDATA['name_id']}}",
281
data: {"_xsrf":getCookie("_xsrf"),
282
"acao": $("#newacao").val(),
283
"complemento": $("#newcomplemento").val(),
284
"folder": $("#folder").val(),
285
"url": $("#url").val(),
286
"nome_folder": $("#folder option:selected").text()
289
success: function(response) {
290
if (response.status == 0){
291
var last_pos = parseInt($( "#actiontable tr:last" ).attr("pos"));
293
if (last_pos || last_pos==0) next_pos = last_pos + 1;
295
var id_link = "del_" + next_pos; // + $("#time").val().replace(':','');
296
// var url_link = (url_corrigida != null ? $("#url").val() : "");
297
// if (url_link=="" && response.url_folder!="")
298
// url_link = response.url_folder
300
var newline = '<tr pos="' + next_pos + '"><td width="65>" "</td>'+
301
'<td width="250">' + $("#newacao").val() + '</td>' +
302
'<td width="40%">' + $("#newcomplemento").val() + '</td>' +
303
'<td>' + response.url_folder + '</td>' + // '<td><a href="' + url_link + '">' + url_link + '</a></td>' +
304
'<td width="88" align="center">' +
305
'<a id="' + id_link + '" class="deleteAction" title="apagar">' +
306
'<img src="/static/imagens/icones/delete16.png" alt="apagar" border="0" /></a>' +
309
if ($( "#actiontable tr" ).length == 0) {
310
// insere se a tabela está vazia
311
$( "#actiontable" ).append(newline);
312
$( "#" + id_link ).click(onDeleteAction);
315
// senão insere no final
316
$( "#actiontable tr:last" ).after( newline );
317
$( "#" + id_link ).click(onDeleteAction);
320
// limpa os campos do form de inclusão
321
$('#newacao')[0].selectedIndex = 0;
322
$("#newcomplemento").val("");
325
$("#url").prop('disabled', true);
327
$('#folder').empty();
328
$("#folder").prop('disabled', true);
331
$("#criar_novo").hide();
333
resetMaxOrdensInput();
340
// callback no ícone lixeira para excluir ação
341
$( "#actiontable .deleteAction" ).click(onDeleteAction);
348
{% block body-right %}
349
<script type="text/javascript" src="/static/ckeditor/ckeditor.js"></script>
351
<form name="editaacoes" action="{{ request.path }}" method="post" onsubmit="return EqualOrdem()">
352
{% raw xsrf_form_html() %}
354
{{modules.ShowMolduraInicio(u"Gerenciar ações da tarefa "+TASKDATA["titulo"], links=LINKS)}}
355
{% if MSG %} <div class="alert alert-danger" role="alert">{{ MSG }}</div> {% end %}
358
{{ escape(TASKDATA["titulo"]) }}<br/>
360
<h2>Descrição da Tarefa:</h2>
361
{{ escape(TASKDATA["descricao"]) }}<br/>
365
<!-- Lista de ações -->
366
<table width="100%" class="activTableBorder">
368
<td width="71.6" align="left"><b>Ordem</b></td>
369
<td width="250" align="left"><b>Ação</b></td>
370
<td width="40%" align="left"><b>Descrição</b></td>
371
<td align="left"><b>Localização</b></td>
372
<td width="88" align="center"></td>
376
<table id="actiontable" width="100%" class="activTableBorder">
377
{% for key in TASKDATA["acoes"] %}
379
<td width="65"><input type="number" min="1" max="{{ len(TASKDATA["acoes"]) }}" name="ordem" style="width:50px; "value="{{ key}}"></td>
380
<td width="250">{{ TASKDATA["acoes"][key]["tipo"] }}<input type="hidden" name="tipo" value="{{ TASKDATA["acoes"][key]["tipo"] }}"></td>
381
<td width="40%"><input type="text" name="descricao" style="width:450px;"value="{{ TASKDATA["acoes"][key]["descricao"] }}"></td>
382
{% if TASKDATA["acoes"][key]["localizacao"] %}
383
<td>{{ TASKDATA["acoes"][key]["localizacao"] }}<input type="hidden" name="localizacao" value="{{ TASKDATA["acoes"][key]["localizacao"] }}"></td>
385
<td><input type="hidden" name="localizacao" value=" "></td>
387
<td width="88" align = "center">
388
<a class="deleteAction" title="apagar">
389
<img src="/static/imagens/icones/delete16.png" alt="apagar" border="0" /></a>
395
<!-- form name="addAction" a inclusão do form aqui faria com que um enter no campo time submetesse o form erradamente -->
396
{% raw xsrf_form_html() %}
397
<input type="hidden" name="id" value="{{ escape(TASKDATA['_id']) }}" />
399
<!-- Inclusão de uma ação -->
400
<table width="100%" class="activTableBorder">
402
<td width="71.6"></td>
404
<select name='newacao' id='newacao' onchange='enableFolderAndUrl();'>
405
<option value='' selected='selected'></option>
406
{% for item in LISTA_ACOES %}
407
{% if item["service"] in USERDATA["services"] or item["service"]=="" %}
408
<option value='{{ item["acao"] }}'>{{ item["acao"] }}</option>
413
<td width="40%"><input type="text" style="width:450px" name="newcomplemento" id="newcomplemento"></td>
415
<select name="folder" id="folder"></select>
416
<select name="url" id="url"></select>
417
<span id="criar_novo"><a href="" target="_new">criar agora!</a></span>
420
<input id="b_newAction" type="button" value="incluir" />
429
<input type="submit" value="enviar">
430
{{ modules.ShowMolduraFim() }}