X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/402ad79b07e541bf996b3f5f463d3a9ac4705a01..9ec921e6a48f7302e3819dfe020200f6a5bcc3cc:/js/requirement_spec.js diff --git a/js/requirement_spec.js b/js/requirement_spec.js index 4a6665050..535c34eab 100644 --- a/js/requirement_spec.js +++ b/js/requirement_spec.js @@ -102,6 +102,59 @@ ns.tree_node_clicked = function(event) { }, kivi.eval_json_result); }; +ns.setup_tooltip_for_tree_node = function(li) { + $(li).find('a').prop('title', $(li).prop('title')).tooltip(); + $(li).prop('title', ''); +}; + +ns.tree_loaded = function(event) { + var id = $('#tree').data('initially_selected_node'); + if (id) + $.jstree._reference("#tree").select_node(id, true); + + $('#tree li[title!=""]').each(function(idx, elt) { + ns.setup_tooltip_for_tree_node(elt); + }); +}; + +ns.tree_node_created = function(event, data) { + console.info("created ", data); + if (data && data.rslt && data.rslt.obj) + ns.setup_tooltip_for_tree_node(data.rslt.obj); +}; + +ns.initialize_requirement_spec = function(data) { + $('#tree').data('initially_selected_node', data.initially_selected_node); + + $('#tree') + .bind('create_node.jstree', ns.tree_node_created) + .bind('move_node.jstree', ns.tree_node_moved) + .bind('click.jstree', ns.tree_node_clicked) + .bind('loaded.jstree', ns.tree_loaded) + .jstree({ + core: { + animation: 0, + initially_open: data.initially_open, + }, + json_data: { + data: data.tree_data + }, + crrm: { + move: { + check_move: ns.tree_check_move, + open_move: true + } + }, + themes: { + theme: "requirement-spec" + }, + plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ] + }); + + ns.create_context_menus(data.is_template); + $('#requirement_spec_tabs').on("tabsbeforeactivate", ns.tabs_before_activate); +}; + // ------------------------------------------------------------------------- // ------------------------------ text blocks ------------------------------ // ------------------------------------------------------------------------- @@ -178,15 +231,6 @@ ns.ask_delete_text_block = function(key, opt) { return true; }; -ns.text_block_input_key_down = function(event) { - if(event.keyCode == 13) { - event.preventDefault(); - var prefix = $(this).attr('id').match("^edit_function_block_\\d+")[0]; - $("#" + prefix + "_submit").click(); - return false; - } -}; - ns.find_text_block_picture_id = function(clicked_elt) { var id = $(clicked_elt).attr('id'); var match = id.match(/^text-block-picture-(\d+)$/); @@ -243,6 +287,20 @@ ns.text_block_picture_popup_menu_hidden = function(opt) { return ns.handle_text_block_picture_popup_menu_markings(opt, false); }; +ns.make_text_block_picture_lists_sortable = function() { + kivi.run_once_for(".requirement-spec-text-block-picture-list", 'make-text-block-picture-list-sortable', function($elt) { + $elt.sortable({ + stop: function(event, ui) { + $.post('controller.pl?action=RequirementSpecTextBlock/reorder_pictures', { + 'picture_id[]': $($elt.sortable('toArray')).map(function(idx, str) { return str.replace('text-block-picture-', ''); }).toArray() + }); + return ui; + } + , distance: 5 + }); + }); +}; + // -------------------------------------------------------------------------------- // ------------------------------ sections and items ------------------------------ // -------------------------------------------------------------------------------- @@ -336,6 +394,23 @@ ns.item_popup_menu_hidden = function(opt) { return ns.handle_item_popup_menu_markings(opt, false); }; +ns.submit_function_block = function(event, shift_in_out) { + event.preventDefault(); + + var prefix = $(this).attr('id').match("^(?:edit|new)_function_block_[\\d_]+\\d")[0]; + var action = $('#' + prefix + '_id').val() ? 'update' : 'create'; + kivi.submit_ajax_form('controller.pl?action=RequirementSpecItem/ajax_' + action, '#' + prefix + '_form', { shift_in_out: !!shift_in_out }); + + return false; +}; + +ns.init_function_block_keypress_events = function(form_id) { + $("#" + form_id + " INPUT[type=text]").bind("keypress", "return", ns.submit_function_block); + + $('#' + form_id + ' INPUT[type=text],#' + form_id + ' TEXTAREA,#' + form_id + ' INPUT[type=button]') + .bind('keypress', 'shift+return', function(event) { return ns.submit_function_block.apply(this, [ event, true ]); }); +}; + // ------------------------------------------------------------------------- // ------------------------------- templates ------------------------------- // ------------------------------------------------------------------------- @@ -394,7 +469,13 @@ ns.standard_time_cost_estimate_ajax_call = function(key, opt) { return true; } - var data = "action=RequirementSpec/ajax_" + key + "_time_and_cost_estimate&"; + var add_data = ''; + if (key == 'save_keep_open') { + key = 'save'; + add_data = 'keep_open=1&'; + } + + var data = "action=RequirementSpec/ajax_" + key + "_time_and_cost_estimate&" + add_data; if (key == 'save') data += $('#edit_time_cost_estimate_form').serialize() @@ -696,6 +777,7 @@ ns.create_context_menus = function(is_template) { items: $.extend({ heading: { name: kivi.t8('Time/cost estimate actions'), className: 'context-menu-heading' } , save: { name: kivi.t8('Save'), icon: "save", callback: kivi.requirement_spec.standard_time_cost_estimate_ajax_call } + , save_keep_open: { name: kivi.t8('Save and keep open'), icon: "save", callback: kivi.requirement_spec.standard_time_cost_estimate_ajax_call } , cancel: { name: kivi.t8('Cancel'), icon: "close", callback: kivi.requirement_spec.standard_time_cost_estimate_ajax_call } }, general_actions) });