1 [%- USE LxERP -%][%- USE L -%][%- USE HTML -%][%- USE JavaScript -%][% SET style="width: 500px" %]
2 [% DEFAULT id_base = 'edit_text_block_' _ SELF.text_block.id %]
3 <form method="post" id="[% id_base %]_form">
5 [%- IF SELF.text_block.id %]
6 [%- SET title = SELF.text_block.title || '(' _ LxERP.t8('No title yet') _ ')' %]
7 [%- LxERP.t8("Edit text block '#1'", title) %]
9 [%- LxERP.t8("Add text block") %]
13 [% L.hidden_tag(id_base _ '_id', SELF.text_block.id) %]
14 [% L.hidden_tag(id_base _ '.requirement_spec_id', SELF.text_block.requirement_spec_id) %]
15 [% L.hidden_tag(id_base _ '.output_position', SELF.text_block.output_position) %]
19 <th align="right">[%- LxERP.t8("Title") %]:</th>
20 <td>[% L.input_tag(id_base _ '.title', SELF.text_block.title, style = style) %]</td>
23 [%- IF SELF.predefined_texts.size %]
25 <th align="right">[%- LxERP.t8("Pre-defined Texts") %]:</th>
27 [%- L.select_tag(id_base _ '_predefined_text_block', SELF.predefined_texts, title_key='description', style=style) %]
28 <a href="#" onclick="insert_selected_predefined_text()">[%- LxERP.t8("Insert") %]</a>
34 <th align="right" valign="top">[%- LxERP.t8("Description") %]:</th>
35 <td valign="top">[% L.textarea_tag(id_base _ '.text', SELF.text_block.text, style = style, rows = 10) %]</td>
40 [% L.button_tag('submit_edit_text_block_form("' _ id_base _ '")', LxERP.t8('Save')) %]
41 <a href="#" onclick="cancel_edit_text_block_form('[% id_base %]')">[%- LxERP.t8("Cancel") %]</a>
44 [%- IF SELF.predefined_texts.size %]
45 <script type="text/javascript">
47 function insert_selected_predefined_text() {
49 [%- FOREACH pt = SELF.predefined_texts %]
50 [% HTML.escape(pt.id) %]: {
51 title: "[% JavaScript.escape(pt.title) %]",
52 text: "[% JavaScript.escape(pt.text) %]"
53 }[% UNLESS loop.last %],[% END %]
57 var id = $('#[% id_base %]_predefined_text_block').val();
60 console.log("insert: case 1; id: " + id);
64 var title_ctrl = $('#[% id_base %]_title');
66 if ( ((title_ctrl.val() || '') != '')
67 && ((pt.title || '') != '')
68 && confirm('[%- LxERP.t8("Do you want to overwrite your current title?") %]'))
69 title_ctrl.val(pt.title);
71 if ((pt.text || '') != '') {
72 var text_ctrl = $('#[% id_base %]_text');
73 var text = text_ctrl.val() || '';
77 text_ctrl.val(text + pt.text);