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