2014-06-17 Vanessa Gil <vanessa.gil@artica.es>
* include/javascript/pandora_module.js: Fixed bug adding and deleting macros. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10220 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
dddebcbbcc
commit
60bbb3ab6c
|
@ -1,3 +1,8 @@
|
|||
2014-06-17 Vanessa Gil <vanessa.gil@artica.es>
|
||||
|
||||
* include/javascript/pandora_module.js: Fixed bug
|
||||
adding and deleting macros.
|
||||
|
||||
2014-06-17 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_menu.php: Fix ACLs limitations. Now its possible
|
||||
|
|
|
@ -744,3 +744,101 @@ function network_component_group_change_event() {
|
|||
);
|
||||
});
|
||||
}
|
||||
|
||||
function new_macro_local_component(prefix) {
|
||||
$('#delete_macro_button').show();
|
||||
|
||||
var next_row = parseInt($('#next_row').html());
|
||||
|
||||
$('#next_row').html(next_row + 2);
|
||||
var nrow1 = next_row - 2;
|
||||
var nrow2 = next_row - 1;
|
||||
var nrow3 = next_row;
|
||||
var nrow4 = next_row + 1;
|
||||
|
||||
var next_number = parseInt($('#next_macro').html());
|
||||
$('#next_macro').html(next_number + 1);
|
||||
var current_number = next_number - 1;
|
||||
|
||||
// Clone two last rows
|
||||
var $row1 = $('#' + prefix + nrow1).clone(true);
|
||||
var $row2 = $('#' + prefix + nrow2).clone(true);
|
||||
|
||||
// Change the tr ID
|
||||
$row1.attr('id',prefix + (nrow3));
|
||||
$row2.attr('id',prefix + (nrow4));
|
||||
// Change the td ID
|
||||
$row1.find('td').attr('id', changeTdId);
|
||||
$row2.find('td').attr('id', changeTdId);
|
||||
|
||||
// Insert after last field
|
||||
$row2.insertAfter('#' + prefix + nrow2);
|
||||
$row1.insertAfter('#' + prefix + nrow2);
|
||||
|
||||
// Change labels
|
||||
for(i = 0; i <= 3; i++) {
|
||||
var label1 = $("#" + prefix + nrow3 + "-" + i).html();
|
||||
var exp_reg = new RegExp('field' + current_number, 'g');
|
||||
label1 = label1.replace(exp_reg,'field' + next_number);
|
||||
$("#" + prefix + nrow3 + "-" + i).html(label1);
|
||||
}
|
||||
|
||||
for(i = 0; i <= 1; i++) {
|
||||
var label2 = $("#" + prefix + nrow4 + "-" + i).html();
|
||||
var exp_reg = new RegExp('field' + current_number, 'g');
|
||||
label2 = label2.replace(exp_reg,'field' + next_number);
|
||||
$("#" + prefix + nrow4 + "-" + i).html(label2);
|
||||
}
|
||||
|
||||
// Empty the text inputs
|
||||
$('#text-field' + next_number + '_desc').val('');
|
||||
$('#text-field' + next_number + '_help').val('');
|
||||
$('#text-field' + next_number + '_value').val('');
|
||||
|
||||
function changeTdId() {
|
||||
switch(this.id) {
|
||||
case prefix + (nrow1) + '-0':
|
||||
return prefix + (nrow3) + '-0';
|
||||
break;
|
||||
case prefix + (nrow1) + '-1':
|
||||
return prefix + (nrow3) + '-1';
|
||||
break;
|
||||
case prefix + (nrow1) + '-2':
|
||||
return prefix + (nrow3) + '-2';
|
||||
break;
|
||||
case prefix + (nrow1) + '-3':
|
||||
return prefix + (nrow3) + '-3';
|
||||
break;
|
||||
case prefix + (nrow2) + '-0':
|
||||
return prefix + (nrow4) + '-0';
|
||||
break;
|
||||
case prefix + (nrow2) + '-1':
|
||||
return prefix + (nrow4) + '-1';
|
||||
break;
|
||||
case prefix + (nrow2) + '-2':
|
||||
return prefix + (nrow4) + '-2';
|
||||
break;
|
||||
case prefix + (nrow2) + '-3':
|
||||
return prefix + (nrow4) + '-3';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function delete_macro_local_component(prefix) {
|
||||
var next_number = parseInt($('#next_macro').html());
|
||||
// Is not possible delete first macro
|
||||
if (next_number == 3) {
|
||||
$('#delete_macro_button').hide();
|
||||
}
|
||||
var next_row = parseInt($('#next_row').html());
|
||||
$('#next_macro').html(next_number-1);
|
||||
$('#next_row').html(next_row-2);
|
||||
|
||||
var nrow1 = next_row - 2;
|
||||
var nrow2 = next_row - 1;
|
||||
|
||||
var $row1 = $('#'+prefix+nrow1).remove();
|
||||
var $row2 = $('#'+prefix+nrow2).remove();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue