Löschen von Textblöcken
[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" style="border-right: 1px solid black">
16   <div style="min-height: 32px; height: 32px;">
17    <div style="float: left">
18     [% L.button_tag("new_section_form()", LxERP.t8("New section"), id="new-section-button") %]
19    </div>
20    <div id="spinner" class="clearfix" style="float: right; display: none; background:url('js/themes/requirement-spec/throbber.gif') center center no-repeat !important; min-height: 32px; height: 32px; min-width: 32px; width: 32px;"></div>
21   </div>
22
23   <div id="tree"></div>
24  </div>
25
26  <div id="content-column" class="clearfix">
27   [% L.hidden_tag('current_content_type', SELF.requirement_spec_item.id ? 'section' : '') %]
28   [% L.hidden_tag('current_content_id',   SELF.requirement_spec_item.id) %]
29
30   <div id="column-content">
31    [%- IF SELF.requirement_spec_item -%]
32     [%- INCLUDE 'requirement_spec_item/_single_section.html' requirement_spec_item=SELF.requirement_spec_item -%]
33    [%- ELSE -%]
34     no section
35     [%#- render :partial => 'requirement_spec_items/no_section' -%]
36    [%- END -%]
37   </div>
38  </div>
39 </div>
40
41 <script type="text/javascript">
42  <!--
43      var tree_data = [
44        { data:     [% JSON.json(LxERP.t8("Text blocks front")) %],
45          metadata: { type: "textblocks-front" },
46          attr:     { id: "tb-front", class: "text-block-context-menu" },
47          children: [
48 [% FOREACH tb = SELF.requirement_spec.text_blocks_for_position(0) %]
49  [% P.requirement_spec_text_block_jstree_data(tb).json %][% IF !loop.last %],[% END %]
50 [% END %]
51          ]
52        },
53
54        { data:     [% JSON.json(LxERP.t8("Sections")) %],
55          metadata: { type: "sections" },
56          attr:     { id: "sections" },
57          children: [
58
59 [% FOREACH section = SELF.requirement_spec.sections %]
60  [% P.requirement_spec_item_jstree_data(section).json %][% IF !loop.last %],[% END %]
61 [% END %]
62          ]
63        },
64
65        { data:     [% JSON.json(LxERP.t8("Text blocks back")) %],
66          metadata: { type: "textblocks-back" },
67          attr:     { id: "tb-back", class: "text-block-context-menu" },
68          children: [
69 [% FOREACH tb = SELF.requirement_spec.text_blocks_for_position(1) %]
70  [% P.requirement_spec_text_block_jstree_data(tb).json %][% IF !loop.last %],[% END %]
71 [% END %]
72          ]
73        }
74      ];
75
76      $(function() {
77        $('#tree').jstree({
78          core: {
79            animation: 0,
80            initially_open: [ "tb-front", "tb-back", "sections"
81 [%- FOREACH section = SELF.requirement_spec.sections -%]
82  , "fb-[% section.id %]"
83  [%- FOREACH function_block = section.children -%]
84   , "fb-[% function_block.id -%]"
85  [%- END -%]
86 [%- END -%]
87  ]
88          },
89          json_data: {
90            data: tree_data
91          },
92          crrm: {
93            move: {
94              check_move: requirement_spec_tree_check_move,
95              open_move:  true
96            }
97          },
98          themes: {
99            theme: "requirement-spec"
100          },
101          plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ]
102        })
103        .bind("move_node.jstree", requirement_spec_tree_node_moved)
104        .bind("click.jstree",     requirement_spec_tree_node_clicked);
105 [%- IF SELF.requirement_spec_item -%]
106        $.jstree._reference("#tree").select_node('fb-[% SELF.requirement_spec_item.id %]', true);
107 [%- END -%]
108      });
109
110 function ask_delete_text_block(key, opt) {
111   if (confirm("[% LxERP.t8("Are you sure?") %]"))
112     delete_text_block(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: add_text_block },
121           edit:   { name: "[% LxERP.t8('Edit text block') %]", icon: "edit", callback: edit_text_block, 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   -->
131 </script>