// console.debug("dragged " + dragged_type + " dropped " + dropped_type + " dir " + data.p);
- if ((dragged_type == "sections") || (dragged_type == "textblocks-front") || (dragged_type == "textblocks-back"))
+ if ((dragged_type == "sections") || (dragged_type == "text-blocks-front") || (dragged_type == "text-blocks-back"))
return false;
- if (dragged_type == "textblock") {
- if ((dropped_type == "textblocks-front") || (dropped_type == "textblocks-back"))
+ if (dragged_type == "text-block") {
+ if ((dropped_type == "text-blocks-front") || (dropped_type == "text-blocks-back"))
return (data.p == "inside") || (data.p == "last");
- if (dropped_type == "textblock")
+ if (dropped_type == "text-block")
return (data.p == "before") || (data.p == "after");
return false;
}
// dragged_type == (sub) function blocks
- if ((dropped_type == "textblock") || (dropped_type == "textblocks-front") || (dropped_type == "textblocks-back"))
+ if ((dropped_type == "text-block") || (dropped_type == "text-blocks-front") || (dropped_type == "text-blocks-back"))
return false;
var dropped_depth = dropped_type == "sections" ? 0 : dropped_type == "section" ? 1 : data.r.parent().parent().data('type') != "functionblock" ? 2 : 3;
var move_obj = $.jstree._reference('#tree')._get_move();
var dragged = move_obj.o;
var dropped = move_obj.r;
- var controller = dragged.data("type") == "textblock" ? "RequirementSpecTextBlock" : "RequirementSpecItem";
+ var controller = dragged.data("type") == "text-block" ? "RequirementSpecTextBlock" : "RequirementSpecItem";
var data = {
action: controller + "/dragged_and_dropped",
requirement_spec_id: $('#requirement_spec_id').val(),
var url = 'controller.pl?action='
$.get('controller.pl', {
- action: (/^textblock/ ? 'RequirementSpecTextBlock' : 'RequirementSpecItem') + '/ajax_list.js',
+ action: (/^text-block/ ? 'RequirementSpecTextBlock' : 'RequirementSpecItem') + '/ajax_list.js',
requirement_spec_id: $('#requirement_spec_id').val(),
current_content_type: $('#current_content_type').val(),
current_content_id: $('#current_content_id').val(),
}
function find_text_block_id(clicked_elt) {
- console.log("id: " + $(clicked_elt).attr('id'));
+ // console.log("id: " + $(clicked_elt).attr('id'));
var id = $(clicked_elt).attr('id');
if (/^text-block-\d+$/.test(id)) {
- console.log("find_text_block_id: case 1: " + id.substr(11));
+ // console.log("find_text_block_id: case 1: " + id.substr(11));
return id.substr(11) * 1;
}
id = $(clicked_elt).closest("[id*=text-block-]").attr('id')
if (/^text-block-\d+$/.test(id)) {
- console.log("find_text_block_id: case 2: " + id.substr(11));
+ // console.log("find_text_block_id: case 2: " + id.substr(11));
return id.substr(11) * 1;
}
id = $(clicked_elt).closest("[id*=tb-]").attr('id')
if (/^tb-\d+$/.test(id)) {
- console.log("find_text_block_id: case 3: " + id.substr(3));
+ // console.log("find_text_block_id: case 3: " + id.substr(3));
return id.substr(3) * 1;
}
- console.log("find_text_block_id: case undef");
+ // console.log("find_text_block_id: case undef");
return undefined;
}
return output_position;
var type = $(clicked_elt).closest('#tb-back,#tb-front').data('type');
- if (/^textblocks-(front|back)/.test(type))
- return type == "textblocks-front" ? 0 : 1;
+ if (/^text-blocks-(front|back)/.test(type))
+ return type == "text-blocks-front" ? 0 : 1;
return undefined;
}
return find_text_block_id(opt.$trigger) == undefined;
}
-function edit_text_block(key, opt) {
+function standard_text_block_ajax_call(key, opt, other_data) {
var data = {
- action: "RequirementSpecTextBlock/ajax_edit",
+ action: "RequirementSpecTextBlock/ajax_" + key,
+ requirement_spec_id: $('#requirement_spec_id').val(),
id: find_text_block_id(opt.$trigger),
+ output_position: find_text_block_output_position(opt.$trigger),
current_content_type: $('#current_content_type').val(),
current_content_id: $('#current_content_id').val()
};
- $.post("controller.pl", data, eval_json_result);
- return true;
-}
-function add_text_block(key, opt) {
- return true;
-}
+ $.post("controller.pl", $.extend(data, other_data || {}), eval_json_result);
-function delete_text_block(key, opt) {
- var data = {
- action: "RequirementSpecTextBlock/ajax_delete",
- id: find_text_block_id(opt.$trigger),
- current_content_type: $('#current_content_type').val(),
- current_content_id: $('#current_content_id').val()
- };
- $.post("controller.pl", data, eval_json_result);
return true;
}
function submit_edit_text_block_form(id_base) {
+ var id = $('#' + id_base + '_id').val();
var url = "controller.pl?" + $('#' + id_base + '_form').serialize();
var data = {
- action: 'RequirementSpecTextBlock/ajax_update',
- id: $('#' + id_base + '_id').val(),
+ action: 'RequirementSpecTextBlock/ajax_' + (id ? 'update' : 'create'),
+ id: id,
form_prefix: id_base
};
- console.log("posting edit text block: " + url);
- console.log(data);
$.post(url, data, eval_json_result);
+ return true;
}
function cancel_edit_text_block_form(id_base) {