1 /* Functions used for the requirement specs */
3 namespace("kivi.requirement_spec", function(ns) {
5 // -----------------------------------------------------------------------------
6 // ------------------------------ basic settings -------------------------------
7 // -----------------------------------------------------------------------------
9 ns.basic_settings_customer_changed = function(customer_ctrl, value_ctrl) {
11 'controller.pl?action=Customer/get_hourly_rate',
12 { id: $(customer_ctrl).val() },
13 function(data) { if (data.hourly_rate_formatted) $(value_ctrl).val(data.hourly_rate_formatted); }
17 // -----------------------------------------------------------------------------
18 // ------------------------------ the tree itself ------------------------------
19 // -----------------------------------------------------------------------------
21 ns.tree_check_move = function(data) {
22 var dragged_type = data.o.data('type');
23 var dropped_type = data.r.data('type');
25 // console.debug("dragged " + dragged_type + " dropped " + dropped_type + " dir " + data.p);
27 if ((dragged_type == "sections") || (dragged_type == "text-blocks-front") || (dragged_type == "text-blocks-back"))
30 if (dragged_type == "text-block") {
31 if ((dropped_type == "text-blocks-front") || (dropped_type == "text-blocks-back"))
32 return (data.p == "inside") || (data.p == "last");
33 if (dropped_type == "text-block")
34 return (data.p == "before") || (data.p == "after");
39 if (dragged_type == "section") {
40 if (dropped_type == "sections")
41 return (data.p == "inside") || (data.p == "last");
42 if (dropped_type == "section")
43 return (data.p == "before") || (data.p == "after");
48 // dragged_type == (sub) function blocks
49 if ((dropped_type == "text-block") || (dropped_type == "text-blocks-front") || (dropped_type == "text-blocks-back"))
52 var dropped_depth = dropped_type == "sections" ? 0 : dropped_type == "section" ? 1 : data.r.parent().parent().data('type') != "function-block" ? 2 : 3;
53 if ((data.p == "inside") || (data.p == "last"))
56 var dragged_depth = 1 + data.o.children('ul').size();
58 // console.debug("dropped_depth " + dropped_depth + " dragged_depth " + dragged_depth);
60 return (2 <= dropped_depth) && ((dragged_depth + dropped_depth) <= 4);
63 ns.tree_node_moved = function(event) {
64 // console.debug("node moved");
65 var move_obj = $.jstree._reference('#tree')._get_move();
66 var dragged = move_obj.o;
67 var dropped = move_obj.r;
68 var controller = dragged.data("type") == "text-block" ? "RequirementSpecTextBlock" : "RequirementSpecItem";
70 action: controller + "/dragged_and_dropped",
71 requirement_spec_id: $('#requirement_spec_id').val(),
72 id: dragged.data("id"),
73 dropped_id: dropped.data("id"),
74 dropped_type: dropped.data("type"),
76 current_content_type: $('#current_content_type').val(),
77 current_content_id: $('#current_content_id').val()
79 // console.debug("controller: " + controller);
80 // console.debug(data);
82 $.post("controller.pl", data, kivi.eval_json_result);
87 ns.tree_node_clicked = function(event) {
88 var node = $.jstree._reference('#tree')._get_node(event.target);
89 var type = node ? node.data('type') : undefined;
94 var url = 'controller.pl?action='
95 $.get('controller.pl', {
96 action: (/^text-block/.test(type) ? 'RequirementSpecTextBlock' : 'RequirementSpecItem') + '/ajax_list.js',
97 requirement_spec_id: $('#requirement_spec_id').val(),
98 current_content_type: $('#current_content_type').val(),
99 current_content_id: $('#current_content_id').val(),
101 clicked_id: node.data('id')
102 }, kivi.eval_json_result);
105 ns.setup_tooltip_for_tree_node = function(li) {
106 $(li).find('a').prop('title', $(li).prop('title')).tooltip();
107 $(li).prop('title', '');
110 ns.tree_loaded = function(event) {
111 var id = $('#tree').data('initially_selected_node');
113 $.jstree._reference("#tree").select_node(id, true);
115 $('#tree li[title!=""]').each(function(idx, elt) {
116 ns.setup_tooltip_for_tree_node(elt);
120 ns.tree_node_created = function(event, data) {
121 console.info("created ", data);
122 if (data && data.rslt && data.rslt.obj)
123 ns.setup_tooltip_for_tree_node(data.rslt.obj);
126 ns.initialize_requirement_spec = function(data) {
127 $('#tree').data('initially_selected_node', data.initially_selected_node);
130 .bind('create_node.jstree', ns.tree_node_created)
131 .bind('move_node.jstree', ns.tree_node_moved)
132 .bind('click.jstree', ns.tree_node_clicked)
133 .bind('loaded.jstree', ns.tree_loaded)
137 initially_open: data.initially_open,
144 check_move: ns.tree_check_move,
149 theme: "requirement-spec"
151 plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ]
154 ns.create_context_menus(data.is_template);
155 $('#requirement_spec_tabs').on("tabsbeforeactivate", ns.tabs_before_activate);
158 // -------------------------------------------------------------------------
159 // ------------------------------ text blocks ------------------------------
160 // -------------------------------------------------------------------------
162 ns.find_text_block_id = function(clicked_elt) {
163 var id = $(clicked_elt).attr('id');
165 if (/^text-block-picture-\d+$/.test(id))
166 id = $(clicked_elt).closest('.text-block-context-menu').attr('id');
168 // console.log("id: " + id);
169 if (/^text-block-\d+$/.test(id)) {
170 // console.log("find_text_block_id: case 1: " + id.substr(11));
171 return id.substr(11) * 1;
174 id = $(clicked_elt).closest("[id*=text-block-]").attr('id')
175 if (/^text-block-\d+$/.test(id)) {
176 // console.log("find_text_block_id: case 2: " + id.substr(11));
177 return id.substr(11) * 1;
180 id = $(clicked_elt).closest("[id*=tb-]").attr('id')
181 if (/^tb-\d+$/.test(id)) {
182 // console.log("find_text_block_id: case 3: " + id.substr(3));
183 return id.substr(3) * 1;
186 // console.log("find_text_block_id: case undef, id: " + id);
190 ns.find_text_block_output_position = function(clicked_elt) {
191 var output_position = $(clicked_elt).closest('#text-block-list-container').find('#text_block_output_position').val();
193 return output_position;
195 var type = $(clicked_elt).closest('#tb-back,#tb-front').data('type') || $('#current_content_type').val();
196 if (/^text-blocks-(front|back)/.test(type))
197 return type == "text-blocks-front" ? 0 : 1;
202 ns.disable_edit_text_block_commands = function(key, opt) {
203 return ns.find_text_block_id(opt.$trigger) == undefined;
206 ns.standard_text_block_ajax_call = function(key, opt, other_data) {
208 action: "RequirementSpecTextBlock/ajax_" + key,
209 requirement_spec_id: $('#requirement_spec_id').val(),
210 id: ns.find_text_block_id(opt.$trigger),
211 output_position: ns.find_text_block_output_position(opt.$trigger),
212 current_content_type: $('#current_content_type').val(),
213 current_content_id: $('#current_content_id').val()
216 $.post("controller.pl", $.extend(data, other_data || {}), kivi.eval_json_result);
221 ns.cancel_edit_text_block_form = function(id_base) {
222 var id = $('#' + id_base + '_id').val();
223 $('#' + id_base + '_form').remove();
225 $('#text-block-' + id).show();
228 ns.ask_delete_text_block = function(key, opt) {
229 if (confirm(kivi.t8("Are you sure?")))
230 ns.standard_text_block_ajax_call(key, opt);
234 ns.find_text_block_picture_id = function(clicked_elt) {
235 var id = $(clicked_elt).attr('id');
236 var match = id.match(/^text-block-picture-(\d+)$/);
243 ns.add_edit_text_block_picture_ajax_call = function(key, opt) {
244 var title = key == 'add_picture' ? kivi.t8('Add picture to text block') : kivi.t8('Edit picture');
246 kivi.popup_dialog({ url: 'controller.pl',
247 data: { action: 'RequirementSpecTextBlock/ajax_' + key,
248 id: ns.find_text_block_id(opt.$trigger),
249 picture_id: ns.find_text_block_picture_id(opt.$trigger) },
250 dialog: { title: title }});
255 ns.standard_text_block_picture_ajax_call = function(key, opt) {
257 action: "RequirementSpecTextBlock/ajax_" + key
258 , id: ns.find_text_block_picture_id(opt.$trigger)
261 if (key == 'download_picture')
262 $.download("controller.pl", data);
264 $.post("controller.pl", data, kivi.eval_json_result);
269 ns.ask_delete_text_block_picture = function(key, opt) {
270 if (confirm(kivi.t8("Are you sure?")))
271 ns.standard_text_block_picture_ajax_call(key, opt);
275 ns.handle_text_block_picture_popup_menu_markings = function(opt, add) {
276 var id = ns.find_text_block_picture_id(opt.$trigger);
278 $('#text-block-picture-' + id ).toggleClass('selected', add);
282 ns.text_block_picture_popup_menu_shown = function(opt) {
283 return ns.handle_text_block_picture_popup_menu_markings(opt, true);
286 ns.text_block_picture_popup_menu_hidden = function(opt) {
287 return ns.handle_text_block_picture_popup_menu_markings(opt, false);
290 ns.make_text_block_picture_lists_sortable = function() {
291 kivi.run_once_for(".requirement-spec-text-block-picture-list", 'make-text-block-picture-list-sortable', function($elt) {
293 stop: function(event, ui) {
294 $.post('controller.pl?action=RequirementSpecTextBlock/reorder_pictures', {
295 'picture_id[]': $($elt.sortable('toArray')).map(function(idx, str) { return str.replace('text-block-picture-', ''); }).toArray()
304 // --------------------------------------------------------------------------------
305 // ------------------------------ sections and items ------------------------------
306 // --------------------------------------------------------------------------------
308 ns.find_item_id = function(clicked_elt) {
309 // console.log("clicked id: " + $(clicked_elt).attr('id'));
310 var id = $(clicked_elt).attr('id');
311 var result = /^(function-block|function-block-content|sub-function-block|sub-function-block-content|section|section-header)-(\d+)$/.exec(id);
313 // console.log("find_item_id: case 1: " + result[2]);
317 id = $(clicked_elt).closest("[id*=fb-]").attr('id')
318 if (/^fb-\d+$/.test(id)) {
319 // console.log("find_item_id: case 2: " + id.substr(3));
320 return id.substr(3) * 1;
323 // console.log("find_item_id: case undef");
327 ns.standard_item_ajax_call = function(key, opt, other_data) {
329 action: "RequirementSpecItem/ajax_" + key,
330 requirement_spec_id: $('#requirement_spec_id').val(),
331 id: ns.find_item_id(opt.$trigger),
332 current_content_type: $('#current_content_type').val(),
333 current_content_id: $('#current_content_id').val()
336 // console.log("I would normally POST the following now:");
337 // console.log(data);
338 $.post("controller.pl", $.extend(data, other_data || {}), kivi.eval_json_result);
343 ns.disable_edit_item_commands = function(key, opt) {
344 return ns.find_item_id(opt.$trigger) == undefined;
347 ns.disable_add_function_block_command = function(key, opt) {
348 return opt.$trigger.attr('id') == "sections";
351 ns.cancel_edit_item_form = function(form_id_base, options) {
352 $('#' + form_id_base + '_form').remove();
356 $(options.to_show).show();
357 if (options.to_hide_if_empty && (1 == $(options.to_hide_if_empty).children().size()))
358 $(options.to_hide_if_empty).hide();
361 ns.ask_delete_item = function(key, opt) {
362 if (confirm(kivi.t8("Are you sure?")))
363 ns.standard_item_ajax_call(key, opt);
367 ns.handle_text_block_popup_menu_markings = function(opt, add) {
368 var id = ns.find_text_block_id(opt.$trigger);
370 $('#text-block-' + id).toggleClass('selected', add);
374 ns.text_block_popup_menu_shown = function(opt) {
375 return ns.handle_text_block_popup_menu_markings(opt, true);
378 ns.text_block_popup_menu_hidden = function(opt) {
379 return ns.handle_text_block_popup_menu_markings(opt, false);
382 ns.handle_item_popup_menu_markings = function(opt, add) {
383 var id = ns.find_item_id(opt.$trigger);
385 $('#section-' + id + ',#function-block-' + id + ',#sub-function-block-' + id).toggleClass('selected', add);
389 ns.item_popup_menu_shown = function(opt) {
390 return ns.handle_item_popup_menu_markings(opt, true);
393 ns.item_popup_menu_hidden = function(opt) {
394 return ns.handle_item_popup_menu_markings(opt, false);
397 ns.submit_function_block = function(event, shift_in_out) {
398 event.preventDefault();
400 var prefix = $(this).attr('id').match("^(?:edit|new)_function_block_[\\d_]+\\d")[0];
401 var action = $('#' + prefix + '_id').val() ? 'update' : 'create';
402 kivi.submit_ajax_form('controller.pl?action=RequirementSpecItem/ajax_' + action, '#' + prefix + '_form', { shift_in_out: !!shift_in_out });
407 ns.init_function_block_keypress_events = function(form_id) {
408 $("#" + form_id + " INPUT[type=text]").bind("keypress", "return", ns.submit_function_block);
410 $('#' + form_id + ' INPUT[type=text],#' + form_id + ' TEXTAREA,#' + form_id + ' INPUT[type=button]')
411 .bind('keypress', 'shift+return', function(event) { return ns.submit_function_block.apply(this, [ event, true ]); });
414 // -------------------------------------------------------------------------
415 // ------------------------------- templates -------------------------------
416 // -------------------------------------------------------------------------
418 ns.paste_template = function(key, opt, other_data) {
419 kivi.popup_dialog({ url: 'controller.pl?action=RequirementSpec/select_template_to_paste', dialog: { title: kivi.t8("Select template to paste") } });
422 ns.paste_selected_template = function(template_id) {
423 $('#jqueryui_popup_dialog').dialog("close");
426 action: "RequirementSpec/paste_template",
427 id: $('#requirement_spec_id').val(),
428 template_id: template_id,
429 current_content_type: $('#current_content_type').val(),
430 current_content_id: $('#current_content_id').val()
433 // console.log("I would normally POST the following now:");
434 // console.log(data);
435 $.post("controller.pl", data, kivi.eval_json_result);
440 // -------------------------------------------------------------------------
441 // ---------------------------- basic settings -----------------------------
442 // -------------------------------------------------------------------------
443 ns.standard_basic_settings_ajax_call = function(key, opt) {
444 if (key == 'cancel') {
445 if (confirm(kivi.t8('Do you really want to cancel?'))) {
446 $('#basic_settings').show();
447 $('#basic_settings_form').remove();
452 var data = 'action=RequirementSpec/ajax_' + key + '&id=' + encodeURIComponent($('#requirement_spec_id').val());
454 $.post("controller.pl", data, kivi.eval_json_result);
459 // -------------------------------------------------------------------------
460 // -------------------------- time/cost estimate ---------------------------
461 // -------------------------------------------------------------------------
463 ns.standard_time_cost_estimate_ajax_call = function(key, opt) {
464 if (key == 'cancel') {
465 if (confirm(kivi.t8('Do you really want to cancel?'))) {
466 $('#time_cost_estimate').show();
467 $('#time_cost_estimate_form_container').remove();
473 if (key == 'save_keep_open') {
475 add_data = 'keep_open=1&';
478 var data = "action=RequirementSpec/ajax_" + key + "_time_and_cost_estimate&" + add_data;
481 data += $('#edit_time_cost_estimate_form').serialize()
482 + '&' + $('#current_content_type').serialize()
483 + '&' + $('#current_content_id').serialize();
485 data += 'id=' + encodeURIComponent($('#requirement_spec_id').val());
487 $.post("controller.pl", data, kivi.eval_json_result);
492 ns.time_cost_estimate_input_key_down = function(event) {
493 if(event.keyCode == 13) {
494 event.preventDefault();
495 ns.standard_time_cost_estimate_ajax_call('save');
500 // -------------------------------------------------------------------------
501 // --------------------------- quotations/orders ---------------------------
502 // -------------------------------------------------------------------------
504 ns.find_quotation_order_id = function(clicked_elt) {
505 return $(clicked_elt).find('>[name=order_id]').val();
508 ns.standard_quotation_order_ajax_call = function(key, opt) {
509 if (key == 'cancel') {
510 if (confirm(kivi.t8('Do you really want to cancel?'))) {
511 $('#quotations_and_orders').show();
512 $('#quotations_and_orders_article_assignment,#quotations_and_orders_new,#quotations_and_orders_update').remove();
517 else if ((key == 'create') && $('#quotations_and_orders_form INPUT[name="sections[].order_part_id"]').filter(function(idx, elt) { return ($(elt).val() || '') == '' }).size()) {
518 alert(kivi.t8('There is one or more sections for which no part has been assigned yet; therefore creating the new record is not possible yet.'));
522 var data = 'action=RequirementSpecOrder/' + key
523 + '&' + $('#requirement_spec_id').serialize();
525 if ((key == 'save_assignment') || (key == 'create') || (key == 'do_update'))
526 data += '&' + $('#quotations_and_orders_form').serialize();
527 else if ((key == 'update') || (key == 'delete'))
528 data += '&rs_order_id=' + encodeURIComponent(ns.find_quotation_order_id(opt.$trigger));
530 // console.log("I would normally POST the following now:");
531 // console.log(data);
532 $.post("controller.pl", data, kivi.eval_json_result);
537 ns.ask_delete_quotation_order = function(key, opt) {
538 if (confirm(kivi.t8("Are you sure?")))
539 ns.standard_quotation_order_ajax_call(key, opt);
543 ns.disable_edit_quotation_order_commands = function(key, opt) {
544 return ns.find_quotation_order_id(opt.$trigger) == undefined;
547 ns.disable_create_quotation_order_commands = function(key, opt) {
548 return !$('#quotations_and_orders_sections');
551 ns.assign_order_part_id_to_all = function() {
552 var order_part_id = $('#quotations_and_orders_order_id').val();
553 var order_part_name = $('#quotations_and_orders_order_id_name').val();
555 $('#quotations_and_orders_form INPUT[name="sections[].order_part_id"]').each(function(idx, elt) {
556 $(elt).val(order_part_id);
559 $('#quotations_and_orders_form [id^=quotations_and_orders_sections_order_pard_id_]').filter(function() {
560 return $(this).attr('id') && $(this).attr('id').match("^quotations_and_orders_sections_order_pard_id_[0-9]+_name$");
561 }).each(function(idx, elt) {
562 $(elt).val(order_part_name);
566 // -------------------------------------------------------------------------
567 // ---------------------------- general actions ----------------------------
568 // -------------------------------------------------------------------------
570 ns.create_reqspec_pdf = function(key, opt) {
572 action: "RequirementSpec/create_pdf",
573 id: $('#requirement_spec_id').val()
575 $.download("controller.pl", data);
578 ns.copy_reqspec = function(key, opt) {
579 window.location.href = "controller.pl?action=RequirementSpec/new©_source_id=" + encodeURIComponent($('#requirement_spec_id').val());
583 ns.delete_reqspec = function(key, opt) {
584 if (confirm(kivi.t8("Are you sure?")))
585 window.location.href = "controller.pl?action=RequirementSpec/destroy&id=" + encodeURIComponent($('#requirement_spec_id').val());
589 ns.disable_commands = function(key, opt) {
590 if (key === "create_version")
591 return ($('#current_version_id').val() || '') == '' ? false : true;
595 // -------------------------------------------------------------------------
596 // -------------------------------- versions -------------------------------
597 // -------------------------------------------------------------------------
599 ns.find_versioned_copy_id = function(clicked_elt) {
600 var id = $(clicked_elt).find("[name=versioned_copy_id]");
601 return id ? id.val() : undefined;
604 ns.disable_versioned_copy_item_commands = function(key, opt) {
605 if (key === "revert_to_version")
606 return !ns.find_versioned_copy_id(opt.$trigger);
610 ns.create_version = function() {
611 kivi.popup_dialog({ url: 'controller.pl',
612 data: { action: 'RequirementSpecVersion/new',
613 requirement_spec_id: $('#requirement_spec_id').val() },
614 dialog: { title: kivi.t8('Create a new version') }});
618 ns.create_pdf_for_versioned_copy_ajax_call = function(key, opt) {
620 action: "RequirementSpec/create_pdf",
621 id: ns.find_versioned_copy_id(opt.$trigger)
623 $.download("controller.pl", data);
628 ns.revert_to_versioned_copy_ajax_call = function(key, opt) {
629 if (!confirm(kivi.t8('Do you really want to revert to this version?')))
633 action: 'RequirementSpec/revert_to',
634 versioned_copy_id: ns.find_versioned_copy_id(opt.$trigger),
635 id: $('#requirement_spec_id').val()
638 $.post("controller.pl", data, kivi.eval_json_result);
643 // -------------------------------------------------------------------------
644 // ------------------------------- tab widget ------------------------------
645 // -------------------------------------------------------------------------
646 var content_div_ids_for_tab_headers = {
647 'tab-header-function-block': 'function-blocks-tab'
648 , 'tab-header-basic-settings': 'ui-tabs-1'
649 , 'tab-header-time-cost-estimate': 'ui-tabs-2'
650 , 'tab-header-versions': 'ui-tabs-3'
651 , 'tab-header-quotations-orders': 'ui-tabs-4'
654 ns.tabs_before_activate = function(event, ui) {
658 var content_div_id = content_div_ids_for_tab_headers[ $(ui.oldTab).attr('id') ];
659 if (!content_div_id || (content_div_id == 'function-blocks-tab'))
662 var inputs = $('#' + content_div_id).find('input,select,textarea').filter('[type!=hidden]');
663 if (!inputs.size() || confirm(kivi.t8("If you switch to a different tab without saving you will lose the data you've entered in the current tab.")))
666 var new_focus = $(inputs).filter(':focusable')[0];
668 $(new_focus).focus();
673 // -------------------------------------------------------------------------
674 // ----------------------------- context menus -----------------------------
675 // -------------------------------------------------------------------------
677 ns.create_context_menus = function(is_template) {
679 var general_actions = {
681 , general_actions: { name: kivi.t8('Requirement spec template actions'), className: 'context-menu-heading' }
682 // , sep99: "---------"
683 , copy_reqspec: { name: kivi.t8('Copy template'), icon: "copy", callback: kivi.requirement_spec.copy_reqspec }
684 , delete_reqspec: { name: kivi.t8('Delete template'), icon: "delete", callback: kivi.requirement_spec.delete_reqspec }
687 } else { // if (is_template)
688 var general_actions = {
690 , general_actions: { name: kivi.t8('Requirement spec actions'), className: 'context-menu-heading' }
691 , create_pdf: { name: kivi.t8('Create PDF'), icon: "pdf", callback: kivi.requirement_spec.create_reqspec_pdf }
692 , create_version: { name: kivi.t8('Create new version'), icon: "new", callback: kivi.requirement_spec.create_version, disabled: kivi.requirement_spec.disable_commands }
693 , copy_reqspec: { name: kivi.t8('Copy requirement spec'), icon: "copy", callback: kivi.requirement_spec.copy_reqspec }
694 , delete_reqspec: { name: kivi.t8('Delete requirement spec'), icon: "delete", callback: kivi.requirement_spec.delete_reqspec }
695 , sep_paste_template: "---------"
696 , paste_template: { name: kivi.t8('Paste template'), icon: "paste", callback: kivi.requirement_spec.paste_template }
700 selector: '.versioned-copy-context-menu',
702 heading: { name: kivi.t8('Version actions'), className: 'context-menu-heading' }
703 , create_version_pdf: { name: kivi.t8('Create PDF'), icon: "pdf", callback: kivi.requirement_spec.create_pdf_for_versioned_copy_ajax_call }
704 , revert_to_version: { name: kivi.t8('Revert to version'), icon: "revert", callback: kivi.requirement_spec.revert_to_versioned_copy_ajax_call, disabled: kivi.requirement_spec.disable_versioned_copy_item_commands }
708 var paste_template_actions = {
710 } // if (is_template) ... else ...
713 selector: '.text-block-context-menu',
715 show: kivi.requirement_spec.text_block_popup_menu_shown
716 , hide: kivi.requirement_spec.text_block_popup_menu_hidden
719 heading: { name: kivi.t8('Text block actions'), className: 'context-menu-heading' }
720 , add: { name: kivi.t8('Add text block'), icon: "add", callback: kivi.requirement_spec.standard_text_block_ajax_call }
721 , edit: { name: kivi.t8('Edit text block'), icon: "edit", callback: kivi.requirement_spec.standard_text_block_ajax_call, disabled: kivi.requirement_spec.disable_edit_text_block_commands }
722 , delete: { name: kivi.t8('Delete text block'), icon: "delete", callback: kivi.requirement_spec.ask_delete_text_block, disabled: kivi.requirement_spec.disable_edit_text_block_commands }
723 , add_picture: { name: kivi.t8('Add picture to text block'), icon: "add-picture", callback: kivi.requirement_spec.add_edit_text_block_picture_ajax_call, disabled: kivi.requirement_spec.disable_edit_text_block_commands }
725 , flag: { name: kivi.t8('Toggle marker'), icon: "flag", callback: kivi.requirement_spec.standard_text_block_ajax_call, disabled: kivi.requirement_spec.disable_edit_text_block_commands }
727 , copy: { name: kivi.t8('Copy'), icon: "copy", callback: kivi.requirement_spec.standard_text_block_ajax_call, disabled: kivi.requirement_spec.disable_edit_text_block_commands }
728 , paste: { name: kivi.t8('Paste'), icon: "paste", callback: kivi.requirement_spec.standard_text_block_ajax_call }
733 selector: '.text-block-picture-context-menu',
735 show: kivi.requirement_spec.text_block_picture_popup_menu_shown
736 , hide: kivi.requirement_spec.text_block_picture_popup_menu_hidden
739 heading: { name: kivi.t8('Text block picture actions'), className: 'context-menu-heading' }
740 , add_picture: { name: kivi.t8('Add picture'), icon: "add-picture", callback: kivi.requirement_spec.add_edit_text_block_picture_ajax_call }
741 , edit_picture: { name: kivi.t8('Edit picture'), icon: "edit", callback: kivi.requirement_spec.add_edit_text_block_picture_ajax_call }
742 , delete_picture: { name: kivi.t8('Delete picture'), icon: "delete", callback: kivi.requirement_spec.ask_delete_text_block_picture }
743 , download_picture: { name: kivi.t8('Download picture'), icon: "download", callback: kivi.requirement_spec.standard_text_block_picture_ajax_call }
745 , copy_picture: { name: kivi.t8('Copy'), icon: "copy", callback: kivi.requirement_spec.standard_text_block_picture_ajax_call }
746 , paste_picture: { name: kivi.t8('Paste'), icon: "paste", callback: kivi.requirement_spec.standard_text_block_picture_ajax_call }
751 selector: '.basic-settings-context-menu',
753 heading: { name: kivi.t8('Basic settings actions'), className: 'context-menu-heading' }
754 , edit: { name: kivi.t8('Edit'), icon: "edit", callback: kivi.requirement_spec.standard_basic_settings_ajax_call }
759 selector: '.edit-basic-settings-context-menu',
761 heading: { name: kivi.t8('Basic settings actions'), className: 'context-menu-heading' }
762 , save: { name: kivi.t8('Save'), icon: "save", callback: kivi.requirement_spec.standard_basic_settings_ajax_call }
763 , cancel: { name: kivi.t8('Cancel'), icon: "close", callback: kivi.requirement_spec.standard_basic_settings_ajax_call }
768 selector: '.time-cost-estimate-context-menu',
770 heading: { name: kivi.t8('Time/cost estimate actions'), className: 'context-menu-heading' }
771 , edit: { name: kivi.t8('Edit'), icon: "edit", callback: kivi.requirement_spec.standard_time_cost_estimate_ajax_call }
776 selector: '.edit-time-cost-estimate-context-menu',
778 heading: { name: kivi.t8('Time/cost estimate actions'), className: 'context-menu-heading' }
779 , save: { name: kivi.t8('Save'), icon: "save", callback: kivi.requirement_spec.standard_time_cost_estimate_ajax_call }
780 , save_keep_open: { name: kivi.t8('Save and keep open'), icon: "save", callback: kivi.requirement_spec.standard_time_cost_estimate_ajax_call }
781 , cancel: { name: kivi.t8('Cancel'), icon: "close", callback: kivi.requirement_spec.standard_time_cost_estimate_ajax_call }
786 selector: '.quotations-and-orders-context-menu,.quotations-and-orders-order-context-menu',
788 heading: { name: kivi.t8('Quotations/Orders actions'), className: 'context-menu-heading' }
789 , edit_assignment: { name: kivi.t8('Edit article/section assignments'), icon: "edit", callback: ns.standard_quotation_order_ajax_call }
791 , new: { name: kivi.t8('Create new qutoation/order'), icon: "add", callback: ns.standard_quotation_order_ajax_call, disabled: ns.disable_create_quotation_order_commands }
792 , update: { name: kivi.t8('Update quotation/order'), icon: "update", callback: ns.standard_quotation_order_ajax_call, disabled: ns.disable_edit_quotation_order_commands }
794 , delete: { name: kivi.t8('Delete quotation/order'), icon: "delete", callback: ns.ask_delete_quotation_order, disabled: ns.disable_edit_quotation_order_commands }
799 selector: '.quotations-and-orders-edit-assignment-context-menu',
801 heading: { name: kivi.t8('Edit article/section assignments'), className: 'context-menu-heading' }
802 , save_assignment: { name: kivi.t8('Save'), icon: "edit", callback: ns.standard_quotation_order_ajax_call }
803 , cancel: { name: kivi.t8('Cancel'), icon: "close", callback: ns.standard_quotation_order_ajax_call }
808 selector: '.quotations-and-orders-new-context-menu',
810 heading: { name: kivi.t8('Create new quotation/order'), className: 'context-menu-heading' }
811 , create: { name: kivi.t8('Create'), icon: "edit", callback: ns.standard_quotation_order_ajax_call }
812 , cancel: { name: kivi.t8('Cancel'), icon: "close", callback: ns.standard_quotation_order_ajax_call }
817 selector: '.quotations-and-orders-update-context-menu',
819 heading: { name: kivi.t8('Update quotation/order'), className: 'context-menu-heading' }
820 , do_update: { name: kivi.t8('Update'), icon: "update", callback: ns.standard_quotation_order_ajax_call }
821 , cancel: { name: kivi.t8('Cancel'), icon: "close", callback: ns.standard_quotation_order_ajax_call }
826 selector: '#content',
827 items: general_actions
831 show: kivi.requirement_spec.item_popup_menu_shown
832 , hide: kivi.requirement_spec.item_popup_menu_hidden
836 selector: '.section-context-menu',
839 heading: { name: kivi.t8('Section/Function block actions'), className: 'context-menu-heading' }
840 , add_section: { name: kivi.t8('Add section'), icon: "add", callback: kivi.requirement_spec.standard_item_ajax_call }
841 , add_function_block: { name: kivi.t8('Add function block'), icon: "add", callback: kivi.requirement_spec.standard_item_ajax_call, disabled: kivi.requirement_spec.disable_add_function_block_command }
843 , edit: { name: kivi.t8('Edit'), icon: "edit", callback: kivi.requirement_spec.standard_item_ajax_call, disabled: kivi.requirement_spec.disable_edit_item_commands }
844 , delete: { name: kivi.t8('Delete'), icon: "delete", callback: kivi.requirement_spec.ask_delete_item, disabled: kivi.requirement_spec.disable_edit_item_commands }
846 , flag: { name: kivi.t8('Toggle marker'), icon: "flag", callback: kivi.requirement_spec.standard_item_ajax_call, disabled: kivi.requirement_spec.disable_edit_item_commands }
848 , copy: { name: kivi.t8('Copy'), icon: "copy", callback: kivi.requirement_spec.standard_item_ajax_call, disabled: kivi.requirement_spec.disable_edit_item_commands }
849 , paste: { name: kivi.t8('Paste'), icon: "paste", callback: kivi.requirement_spec.standard_item_ajax_call }
854 selector: '.function-block-context-menu,.sub-function-block-context-menu',
857 heading: { name: kivi.t8('Function block actions'), className: 'context-menu-heading' }
858 , add_function_block: { name: kivi.t8('Add function block'), icon: "add", callback: kivi.requirement_spec.standard_item_ajax_call }
859 , add_sub_function_block: { name: kivi.t8('Add sub function block'), icon: "add", callback: kivi.requirement_spec.standard_item_ajax_call }
861 , edit: { name: kivi.t8('Edit'), icon: "edit", callback: kivi.requirement_spec.standard_item_ajax_call, disabled: kivi.requirement_spec.disable_edit_item_commands }
862 , delete: { name: kivi.t8('Delete'), icon: "delete", callback: kivi.requirement_spec.ask_delete_item, disabled: kivi.requirement_spec.disable_edit_item_commands }
864 , flag: { name: kivi.t8('Toggle marker'), icon: "flag", callback: kivi.requirement_spec.standard_item_ajax_call, disabled: kivi.requirement_spec.disable_edit_item_commands }
866 , copy: { name: kivi.t8('Copy'), icon: "copy", callback: kivi.requirement_spec.standard_item_ajax_call, disabled: kivi.requirement_spec.disable_edit_item_commands }
867 , paste: { name: kivi.t8('Paste'), icon: "paste", callback: kivi.requirement_spec.standard_item_ajax_call }
872 }); // end of namespace(...., function() {...