Revision c88705d8
Von Moritz Bunkus vor etwa 10 Jahren hinzugefügt
SL/Controller/RequirementSpecItem.pm | ||
---|---|---|
14 | 14 |
use SL::DB::RequirementSpec; |
15 | 15 |
use SL::DB::RequirementSpecComplexity; |
16 | 16 |
use SL::DB::RequirementSpecItem; |
17 |
use SL::DB::RequirementSpecPredefinedText; |
|
17 | 18 |
use SL::DB::RequirementSpecRisk; |
18 | 19 |
use SL::Helper::Flash; |
19 | 20 |
use SL::JSON; |
... | ... | |
22 | 23 |
use Rose::Object::MakeMethods::Generic |
23 | 24 |
( |
24 | 25 |
scalar => [ qw(item visible_item visible_section clicked_item sections) ], |
25 |
'scalar --get_set_init' => [ qw(complexities risks js) ], |
|
26 |
'scalar --get_set_init' => [ qw(complexities risks js predefined_texts) ],
|
|
26 | 27 |
); |
27 | 28 |
|
28 | 29 |
__PACKAGE__->run_before('check_auth'); |
... | ... | |
528 | 529 |
return SL::DB::Manager::RequirementSpecRisk->get_all_sorted; |
529 | 530 |
} |
530 | 531 |
|
532 |
sub init_predefined_texts { |
|
533 |
return SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted(where => [ useable_for_sections => 1 ]); |
|
534 |
} |
|
535 |
|
|
531 | 536 |
sub init_js { |
532 | 537 |
my ($self) = @_; |
533 | 538 |
$self->js(SL::ClientJS->new); |
templates/webpages/requirement_spec_item/_section_form.html | ||
---|---|---|
25 | 25 |
[% L.input_tag(id_base _ '.title', SELF.item.title, style=style) %] |
26 | 26 |
</p> |
27 | 27 |
|
28 |
[%- IF SELF.predefined_texts.size %] |
|
29 |
<p> |
|
30 |
[%- LxERP.t8("Pre-defined Texts") %]:<br> |
|
31 |
[%- L.select_tag(id_base _ '_predefined_text_block', SELF.predefined_texts, title_key='description', style=style) %] |
|
32 |
<a href="#" onclick="insert_selected_predefined_text()">[%- LxERP.t8("Insert") %]</a> |
|
33 |
</p> |
|
34 |
[%- END %] |
|
35 |
|
|
28 | 36 |
<p> |
29 | 37 |
[%- LxERP.t8("Description") %]:<br> |
30 | 38 |
[% L.textarea_tag(id_base _ '.description_as_restricted_html', SELF.item.description_as_restricted_html, id=id_base _ '_description', rows=8, cols=80, style=style, class='texteditor') %] |
... | ... | |
34 | 42 |
[% L.ajax_submit_tag('controller.pl?action=RequirementSpecItem/ajax_' _ (SELF.item.id ? 'update' : 'create'), '#' _ id_base _ '_form', LxERP.t8('Save')) %] |
35 | 43 |
<a href="#" onclick="kivi.requirement_spec.cancel_edit_item_form('[% id_base %]', { to_show: '[% hidden %]' })">[%- LxERP.t8("Cancel") %]</a> |
36 | 44 |
</p> |
45 |
|
|
46 |
[%- IF SELF.predefined_texts.size %] |
|
47 |
<script type="text/javascript"> |
|
48 |
<!-- |
|
49 |
[% INCLUDE 'requirement_spec_text_block/_predefined_text_inserter.js' title_ctrl_id='_title' text_ctrl_id='_description' %] |
|
50 |
--> |
|
51 |
</script> |
|
52 |
[%- END %] |
|
37 | 53 |
</form> |
templates/webpages/requirement_spec_text_block/_form.html | ||
---|---|---|
1 |
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%][%- USE JavaScript -%][% SET style="width: 500px" %]
|
|
1 |
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%][% SET style="width: 500px" %] |
|
2 | 2 |
[% DEFAULT id_base = 'edit_text_block_' _ SELF.text_block.id %] |
3 | 3 |
<form method="post" id="[% id_base %]_form"> |
4 | 4 |
<h2> |
... | ... | |
48 | 48 |
[%- IF SELF.predefined_texts.size %] |
49 | 49 |
<script type="text/javascript"> |
50 | 50 |
<!-- |
51 |
function insert_selected_predefined_text() { |
|
52 |
var data = { |
|
53 |
[%- FOREACH pt = SELF.predefined_texts %] |
|
54 |
[% HTML.escape(pt.id) %]: { |
|
55 |
title: "[% JavaScript.escape(pt.title) %]", |
|
56 |
text: "[% JavaScript.escape(pt.text) %]" |
|
57 |
}[% UNLESS loop.last %],[% END %] |
|
58 |
[% END %] |
|
59 |
} |
|
60 |
|
|
61 |
var id = $('#[% id_base %]_predefined_text_block').val(); |
|
62 |
var pt = data[id]; |
|
63 |
if (!pt) { |
|
64 |
console.log("insert: case 1; id: " + id); |
|
65 |
return false; |
|
66 |
} |
|
67 |
|
|
68 |
var title_ctrl = $('#[% id_base %]_title'); |
|
69 |
|
|
70 |
if ( ((pt.title || '') != '') |
|
71 |
&& ( ((title_ctrl.val() || '') == '') |
|
72 |
|| confirm('[%- LxERP.t8("Do you want to overwrite your current title?") %]'))) |
|
73 |
title_ctrl.val(pt.title); |
|
74 |
|
|
75 |
if ((pt.text || '') != '') |
|
76 |
$('#[% id_base %]_text').ckeditorGet().insertHtml(pt.text); |
|
77 |
|
|
78 |
return false; |
|
79 |
} |
|
51 |
[% INCLUDE 'requirement_spec_text_block/_predefined_text_inserter.js' title_ctrl_id='_title' text_ctrl_id='_text' %] |
|
80 | 52 |
--> |
81 | 53 |
</script> |
82 | 54 |
[%- END %] |
templates/webpages/requirement_spec_text_block/_predefined_text_inserter.js | ||
---|---|---|
1 |
[% USE JavaScript %] |
|
2 |
function insert_selected_predefined_text() { |
|
3 |
var data = { |
|
4 |
[%- FOREACH pt = SELF.predefined_texts %] |
|
5 |
[% HTML.escape(pt.id) %]: { |
|
6 |
title: "[% JavaScript.escape(pt.title) %]", |
|
7 |
text: "[% JavaScript.escape(pt.text) %]" |
|
8 |
}[% UNLESS loop.last %],[% END %] |
|
9 |
[% END %] |
|
10 |
} |
|
11 |
|
|
12 |
var id = $('#[% id_base %]_predefined_text_block').val(); |
|
13 |
var pt = data[id]; |
|
14 |
if (!pt) |
|
15 |
return false; |
|
16 |
|
|
17 |
var title_ctrl = $('#[% id_base %][% title_ctrl_id %]'); |
|
18 |
|
|
19 |
if ( ((pt.title || '') != '') |
|
20 |
&& ( ((title_ctrl.val() || '') == '') |
|
21 |
|| confirm('[%- LxERP.t8("Do you want to overwrite your current title?") %]'))) |
|
22 |
title_ctrl.val(pt.title); |
|
23 |
|
|
24 |
if ((pt.text || '') != '') |
|
25 |
$('#[% id_base %][% text_ctrl_id %]').ckeditorGet().insertHtml(pt.text); |
|
26 |
|
|
27 |
return false; |
|
28 |
} |
Auch abrufbar als: Unified diff
Pflichtenhefte: vordef Textblöcke auch bei Abschnitten verwenden können