- ]
- }
- ];
-
- $(function() {
- $('#tree').jstree({
- core: {
- animation: 0,
- initially_open: [ "tb-front", "tb-back", "sections"
-[%- FOREACH section = SELF.requirement_spec.sections -%]
- , "fb-[% section.id %]"
- [%- FOREACH function_block = section.children -%]
- , "fb-[% function_block.id -%]"
- [%- END -%]
-[%- END -%]
- ]
- },
- json_data: {
- data: tree_data
- },
- crrm: {
- move: {
- check_move: requirement_spec_tree_check_move,
- open_move: true
- }
- },
- themes: {
- theme: "requirement-spec"
- },
- plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ]
- })
- .bind("move_node.jstree", requirement_spec_tree_node_moved)
- .bind("click.jstree", requirement_spec_tree_node_clicked);
-[%- IF SELF.requirement_spec_item -%]
- $.jstree._reference("#tree").select_node('fb-[% SELF.requirement_spec_item.id %]', true);
-[%- END -%]
- });
-
-function ask_delete_text_block(key, opt) {
- if (confirm("[% LxERP.t8("Are you sure?") %]"))
- standard_text_block_ajax_call(key, opt);
- return true;
-}
-
-$(function(){
- $.contextMenu({
- selector: '.text-block-context-menu',
- items: {
- add: { name: "[% LxERP.t8('Add text block') %]", icon: "add", callback: standard_text_block_ajax_call },
- edit: { name: "[% LxERP.t8('Edit text block') %]", icon: "edit", callback: standard_text_block_ajax_call, disabled: disable_edit_text_block_commands },
- delete: { name: "[% LxERP.t8('Delete text block') %]", icon: "delete", callback: ask_delete_text_block, disabled: disable_edit_text_block_commands },
- sep1: "---------",
- copy: { name: "[% LxERP.t8('Copy') %]", icon: "copy", disabled: disable_edit_text_block_commands },
- paste: { name: "[% LxERP.t8('Paste') %]", icon: "paste", disabled: disable_edit_text_block_commands }
- }
- });
+ ]});
+
+ tree_data.push({
+ data: [% JSON.json(LxERP.t8("Text blocks back")) %],
+ metadata: { type: "text-blocks-back" },
+ attr: { id: "tb-back", class: "text-block-context-menu" },
+ children: [
+[% FOREACH tb = SELF.requirement_spec.text_blocks_sorted(output_position=1) %]
+ [% P.requirement_spec_text_block_jstree_data(tb).json %][% IF !loop.last %],[% END %]
+[% END %]
+ ]});
+
+ initially_open = initially_open.concat(['tb-front', 'tb-back']);
+[% END %]
+
+ $('#tree').jstree({
+ core: {
+ animation: 0,
+ initially_open: initially_open,
+ },
+ json_data: {
+ data: tree_data
+ },
+ crrm: {
+ move: {
+ check_move: kivi.requirement_spec.tree_check_move,
+ open_move: true
+ }
+ },
+ themes: {
+ theme: "requirement-spec"
+ },
+ plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ]
+ })
+ .bind("move_node.jstree", kivi.requirement_spec.tree_node_moved)
+ .bind("click.jstree", kivi.requirement_spec.tree_node_clicked);
+[% IF SELF.requirement_spec_item %]
+ $.jstree._reference("#tree").select_node('#fb-[% SELF.requirement_spec_item.id %]', true);
+[% END %]
+
+ kivi.requirement_spec.create_context_menus([% SELF.requirement_spec.is_template ? 'true' : 'false' %]);