759add13fdcc8d524f03b8dc47002adc1e3790c1
[kivitendo-erp.git] / templates / webpages / requirement_spec / show.html
1 [%- USE JSON -%][%- USE HTML %][%- USE L %][%- USE LxERP %][%- USE P -%]
2
3 <h1>[%- HTML.escape(SELF.requirement_spec.displayable_name('format', 'with_customer')) %]
4   [% LxERP.t8("for") %]
5   [% HTML.escape(SELF.requirement_spec.customer.displayable_name) -%]
6 </h1>
7
8 [%- L.hidden_tag('requirement_spec_id', SELF.requirement_spec.id) -%]
9
10 <div id="requirement_spec_version">
11   [%- INCLUDE 'requirement_spec/_version.html' requirement_spec=SELF.requirement_spec -%]
12 </div>
13
14 <div id="column-container">
15  <div id="tree-column">
16   <div id="tree"></div>
17  </div>
18
19  <div id="content-column" class="clearfix">
20   [% L.hidden_tag('current_content_type', SELF.requirement_spec_item.id ? 'section' : '') %]
21   [% L.hidden_tag('current_content_id',   SELF.requirement_spec_item.id) %]
22
23   <div id="column-content">
24    [%- IF SELF.requirement_spec_item -%]
25     [%- INCLUDE 'requirement_spec_item/_single_section.html' requirement_spec_item=SELF.requirement_spec_item -%]
26    [%- ELSE -%]
27     no section
28     [%#- render :partial => 'requirement_spec_items/no_section' -%]
29    [%- END -%]
30   </div>
31  </div>
32 </div>
33
34 <script type="text/javascript">
35  <!--
36      var tree_data = [
37        { data:     [% JSON.json(LxERP.t8("Text blocks front")) %],
38          metadata: { type: "text-blocks-front" },
39          attr:     { id: "tb-front", class: "text-block-context-menu" },
40          children: [
41 [% FOREACH tb = SELF.requirement_spec.text_blocks_for_position(0) %]
42  [% P.requirement_spec_text_block_jstree_data(tb).json %][% IF !loop.last %],[% END %]
43 [% END %]
44          ]
45        },
46
47        { data:     [% JSON.json(LxERP.t8("Sections")) %],
48          metadata: { type: "sections" },
49          attr:     { id: "sections" },
50          children: [
51
52 [% FOREACH section = SELF.requirement_spec.sections %]
53  [% P.requirement_spec_item_jstree_data(section).json %][% IF !loop.last %],[% END %]
54 [% END %]
55          ]
56        },
57
58        { data:     [% JSON.json(LxERP.t8("Text blocks back")) %],
59          metadata: { type: "text-blocks-back" },
60          attr:     { id: "tb-back", class: "text-block-context-menu" },
61          children: [
62 [% FOREACH tb = SELF.requirement_spec.text_blocks_for_position(1) %]
63  [% P.requirement_spec_text_block_jstree_data(tb).json %][% IF !loop.last %],[% END %]
64 [% END %]
65          ]
66        }
67      ];
68
69      $(function() {
70        $('#tree').jstree({
71          core: {
72            animation: 0,
73            initially_open: [ "tb-front", "tb-back", "sections"
74 [%- FOREACH section = SELF.requirement_spec.sections -%]
75  , "fb-[% section.id %]"
76  [%- FOREACH function_block = section.children -%]
77   , "fb-[% function_block.id -%]"
78  [%- END -%]
79 [%- END -%]
80  ]
81          },
82          json_data: {
83            data: tree_data
84          },
85          crrm: {
86            move: {
87              check_move: requirement_spec_tree_check_move,
88              open_move:  true
89            }
90          },
91          themes: {
92            theme: "requirement-spec"
93          },
94          plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ]
95        })
96        .bind("move_node.jstree", requirement_spec_tree_node_moved)
97        .bind("click.jstree",     requirement_spec_tree_node_clicked);
98 [%- IF SELF.requirement_spec_item -%]
99        $.jstree._reference("#tree").select_node('fb-[% SELF.requirement_spec_item.id %]', true);
100 [%- END -%]
101      });
102
103 function ask_delete_text_block(key, opt) {
104   if (confirm("[% LxERP.t8("Are you sure?") %]"))
105     standard_text_block_ajax_call(key, opt);
106   return true;
107 }
108
109 $(function(){
110     $.contextMenu({
111         selector: '.text-block-context-menu',
112         items: {
113           add:    { name: "[% LxERP.t8('Add text block') %]", icon: "add", callback: standard_text_block_ajax_call },
114           edit:   { name: "[% LxERP.t8('Edit text block') %]", icon: "edit", callback: standard_text_block_ajax_call, disabled: disable_edit_text_block_commands },
115           delete: { name: "[% LxERP.t8('Delete text block') %]", icon: "delete", callback: ask_delete_text_block, disabled: disable_edit_text_block_commands },
116           sep1:   "---------",
117           copy:   { name: "[% LxERP.t8('Copy') %]", icon: "copy", disabled: disable_edit_text_block_commands },
118           paste:  { name: "[% LxERP.t8('Paste') %]", icon: "paste", disabled: disable_edit_text_block_commands }
119         }
120       });
121 });
122
123   -->
124 </script>