Pflichtenhefte: Auflisten von Abschnitten
[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/_section.html' requirement_spec_item=SELF.requirement_spec_item -%]
28    [%- ELSE -%]
29     [%- INCLUDE 'requirement_spec_item/_no_section.html' -%]
30    [%- END -%]
31   </div>
32  </div>
33 </div>
34
35 <script type="text/javascript">
36  <!--
37      var tree_data = [
38        { data:     [% JSON.json(LxERP.t8("Text blocks front")) %],
39          metadata: { type: "text-blocks-front" },
40          attr:     { id: "tb-front", class: "text-block-context-menu" },
41          children: [
42 [% FOREACH tb = SELF.requirement_spec.text_blocks_for_position(0) %]
43  [% P.requirement_spec_text_block_jstree_data(tb).json %][% IF !loop.last %],[% END %]
44 [% END %]
45          ]
46        },
47
48        { data:     [% JSON.json(LxERP.t8("Sections")) %],
49          metadata: { type: "sections" },
50          attr:     { id: "sections", class: "section-context-menu" },
51          children: [
52
53 [% FOREACH section = SELF.requirement_spec.sections %]
54  [% P.requirement_spec_item_jstree_data(section).json %][% IF !loop.last %],[% END %]
55 [% END %]
56          ]
57        },
58
59        { data:     [% JSON.json(LxERP.t8("Text blocks back")) %],
60          metadata: { type: "text-blocks-back" },
61          attr:     { id: "tb-back", class: "text-block-context-menu" },
62          children: [
63 [% FOREACH tb = SELF.requirement_spec.text_blocks_for_position(1) %]
64  [% P.requirement_spec_text_block_jstree_data(tb).json %][% IF !loop.last %],[% END %]
65 [% END %]
66          ]
67        }
68      ];
69
70      $(function() {
71        $('#tree').jstree({
72          core: {
73            animation: 0,
74            initially_open: [ "tb-front", "tb-back", "sections"
75 [%- FOREACH section = SELF.requirement_spec.sections -%]
76  , "fb-[% section.id %]"
77  [%- FOREACH function_block = section.children -%]
78   , "fb-[% function_block.id -%]"
79  [%- END -%]
80 [%- END -%]
81  ]
82          },
83          json_data: {
84            data: tree_data
85          },
86          crrm: {
87            move: {
88              check_move: requirement_spec_tree_check_move,
89              open_move:  true
90            }
91          },
92          themes: {
93            theme: "requirement-spec"
94          },
95          plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ]
96        })
97        .bind("move_node.jstree", requirement_spec_tree_node_moved)
98        .bind("click.jstree",     requirement_spec_tree_node_clicked);
99 [%- IF SELF.requirement_spec_item -%]
100        $.jstree._reference("#tree").select_node('fb-[% SELF.requirement_spec_item.id %]', true);
101 [%- END -%]
102      });
103
104 function ask_delete_text_block(key, opt) {
105   if (confirm("[% LxERP.t8("Are you sure?") %]"))
106     standard_text_block_ajax_call(key, opt);
107   return true;
108 }
109
110 function ask_delete_item(key, opt) {
111   if (confirm("[% LxERP.t8("Are you sure?") %]"))
112     standard_item_ajax_call(key, opt);
113   return true;
114 }
115
116 $(function(){
117   $.contextMenu({
118     selector: '.text-block-context-menu',
119     items: {
120       add:    { name: "[% LxERP.t8('Add text block') %]",    icon: "add",    callback: standard_text_block_ajax_call },
121       edit:   { name: "[% LxERP.t8('Edit text block') %]",   icon: "edit",   callback: standard_text_block_ajax_call, disabled: disable_edit_text_block_commands },
122       delete: { name: "[% LxERP.t8('Delete text block') %]", icon: "delete", callback: ask_delete_text_block,         disabled: disable_edit_text_block_commands },
123       sep1:   "---------",
124       copy:   { name: "[% LxERP.t8('Copy') %]",              icon: "copy",  disabled: disable_edit_text_block_commands },
125       paste:  { name: "[% LxERP.t8('Paste') %]",             icon: "paste", disabled: disable_edit_text_block_commands }
126     }
127   });
128
129
130   $.contextMenu({
131     selector: '.section-context-menu',
132     items: {
133       add_section:        { name: "[% LxERP.t8('Add section') %]",        icon: "add",    callback: standard_item_ajax_call },
134       add_function_block: { name: "[% LxERP.t8('Add function block') %]", icon: "add",    callback: standard_text_block_ajax_call },
135       sep1:               "---------",
136       edit:               { name: "[% LxERP.t8('Edit') %]",               icon: "edit",   callback: standard_item_ajax_call, disabled: disable_edit_item_commands },
137       delete:             { name: "[% LxERP.t8('Delete') %]",             icon: "delete", callback: ask_delete_item,         disabled: disable_edit_item_commands },
138       sep2:               "---------",
139       copy:               { name: "[% LxERP.t8('Copy') %]",               icon: "copy",  disabled: disable_edit_item_commands },
140       paste:              { name: "[% LxERP.t8('Paste') %]",              icon: "paste", disabled: disable_edit_item_commands }
141     }
142   });
143
144   $.contextMenu({
145     selector: '.function-block-context-menu,.sub-function-block-context-menu',
146     items: {
147       new_item:     { name: "[% LxERP.t8('Add function block') %]",     icon: "add", callback: standard_item_ajax_call },
148       new_sub_item: { name: "[% LxERP.t8('Add sub function block') %]", icon: "add", callback: standard_item_ajax_call },
149       sep1:         "---------",
150       edit:         { name: "[% LxERP.t8('Edit') %]",   icon: "edit",   callback: standard_item_ajax_call, disabled: disable_edit_item_commands },
151       delete:       { name: "[% LxERP.t8('Delete') %]", icon: "delete", callback: standard_item_ajax_call, disabled: disable_edit_item_commands },
152       sep2:         "---------",
153       copy:         { name: "[% LxERP.t8('Copy') %]",  icon: "copy",  disabled: disable_edit_item_commands },
154       paste:        { name: "[% LxERP.t8('Paste') %]", icon: "paste", disabled: disable_edit_item_commands }
155     }
156   });
157 });
158
159 function edit_section_header() {
160   $.post("controller.pl?action=RequirementSpecItem/edit_section&id=" + encodeURIComponent($('#active_section_id').val()), function(data) {
161     var header = $('#section-header');
162     header.data('old-elements', header.children().detach());
163     header.html(data);
164   });
165 }
166
167 function submit_section_form() {
168   $.post("controller.pl?action=RequirementSpecItem/update_section&id=" + $('#section-form form').serialize(), function(data) {
169     var header = $('#section-header');
170     header.removeData('old-elements');
171     header.html(data['header_html']);
172     $('#tree').jstree('rename_node', '#fb-' + data['id'], data['node_name']);
173   });
174 }
175
176 function cancel_section_form() {
177   var header = $('#section-header');
178   header.empty();
179   header.append(header.data('old-elements'));
180   header.removeData('old-elements');
181 }
182
183
184
185
186
187
188   -->
189 </script>