Revision 7c54e92f
Von Moritz Bunkus vor fast 10 Jahren hinzugefügt
SL/Controller/RequirementSpec.pm | ||
---|---|---|
21 | 21 |
use SL::DB::RequirementSpecStatus; |
22 | 22 |
use SL::DB::RequirementSpecType; |
23 | 23 |
use SL::DB::RequirementSpec; |
24 |
use SL::Helper::CreatePDF qw(); |
|
24 | 25 |
use SL::Helper::Flash; |
25 | 26 |
use SL::Locale::String; |
26 | 27 |
use SL::Template::LaTeX; |
... | ... | |
29 | 30 |
( |
30 | 31 |
scalar => [ qw(requirement_spec_item visible_item visible_section) ], |
31 | 32 |
'scalar --get_set_init' => [ qw(requirement_spec customers types statuses complexities risks projects project_types project_statuses default_project_type default_project_status copy_source js |
32 |
current_text_block_output_position models time_based_units) ], |
|
33 |
current_text_block_output_position models time_based_units html_template) ],
|
|
33 | 34 |
); |
34 | 35 |
|
35 | 36 |
__PACKAGE__->run_before('setup'); |
... | ... | |
231 | 232 |
unlink $result{file_name}; |
232 | 233 |
} |
233 | 234 |
|
235 |
sub action_create_html { |
|
236 |
my ($self, %params) = @_; |
|
237 |
|
|
238 |
my $base_name = $self->requirement_spec->type->template_file_name || 'requirement_spec'; |
|
239 |
my @pictures = $self->prepare_pictures_for_printing; |
|
240 |
my $content = SL::Helper::CreatePDF->create_parsed_file( |
|
241 |
template => "${base_name}.html", |
|
242 |
format => 'html', |
|
243 |
template_type => 'HTML', |
|
244 |
variables => { |
|
245 |
SELF => $self, |
|
246 |
rspec => $self->requirement_spec, |
|
247 |
}); |
|
248 |
|
|
249 |
# $content is now a scalar of bytes, but $self->render() expects a |
|
250 |
# scalar of characters. |
|
251 |
$content = Encode::decode('utf-8', $content); |
|
252 |
|
|
253 |
$self->render(\$content, { layout => 0, process => 0 }); |
|
254 |
} |
|
255 |
|
|
234 | 256 |
sub action_select_template_to_paste { |
235 | 257 |
my ($self) = @_; |
236 | 258 |
|
... | ... | |
613 | 635 |
); |
614 | 636 |
} |
615 | 637 |
|
638 |
sub init_html_template { |
|
639 |
my ($self) = @_; |
|
640 |
my $base_name = $self->requirement_spec->type->template_file_name || 'requirement_spec'; |
|
641 |
my $template = SL::Helper::CreatePDF->find_template(name => $base_name, extension => 'html'); |
|
642 |
return !!$template; |
|
643 |
} |
|
644 |
|
|
616 | 645 |
1; |
css/requirement_spec.css | ||
---|---|---|
48 | 48 |
.context-menu-item.icon-save { background-image: url("../image/document-save.png"); } |
49 | 49 |
.context-menu-item.icon-revert { background-image: url("../image/edit-undo.png"); } |
50 | 50 |
.context-menu-item.icon-pdf { background-image: url("../image/application-pdf.png"); } |
51 |
.context-menu-item.icon-html { background-image: url("../image/text-html.png"); } |
|
51 | 52 |
.context-menu-item.icon-add-picture { background-image: url("../image/add-picture.png"); } |
52 | 53 |
.context-menu-item.icon-download { background-image: url("../image/download.png"); } |
53 | 54 |
.context-menu-item.icon-renumber { background-image: url("../image/format-list-ordered.png"); } |
js/locale/de.js | ||
---|---|---|
16 | 16 |
"Copy requirement spec":"Pflichtenheft kopieren", |
17 | 17 |
"Copy template":"Vorlage kopieren", |
18 | 18 |
"Create":"Anlegen", |
19 |
"Create HTML":"HTML erzeugen", |
|
19 | 20 |
"Create PDF":"PDF erzeugen", |
20 | 21 |
"Create a new version":"Eine neue Version anlegen", |
21 | 22 |
"Create new quotation/order":"Neues Angebot/neuen Auftrag anlegen", |
js/requirement_spec.js | ||
---|---|---|
151 | 151 |
plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ] |
152 | 152 |
}); |
153 | 153 |
|
154 |
ns.create_context_menus(data.is_template);
|
|
154 |
ns.create_context_menus(data); |
|
155 | 155 |
$('#requirement_spec_tabs').on("tabsbeforeactivate", ns.tabs_before_activate); |
156 | 156 |
|
157 | 157 |
ns.time_based_units = data.time_based_units; |
... | ... | |
647 | 647 |
$.download("controller.pl", data); |
648 | 648 |
}; |
649 | 649 |
|
650 |
ns.create_reqspec_html = function(key, opt) { |
|
651 |
window.open("controller.pl?action=RequirementSpec/create_html&id=" + encodeURIComponent($('#requirement_spec_id').val()), '_blank'); |
|
652 |
return true; |
|
653 |
}; |
|
654 |
|
|
650 | 655 |
ns.copy_reqspec = function(key, opt) { |
651 | 656 |
window.location.href = "controller.pl?action=RequirementSpec/new©_source_id=" + encodeURIComponent($('#requirement_spec_id').val()); |
652 | 657 |
return true; |
... | ... | |
697 | 702 |
return true; |
698 | 703 |
}; |
699 | 704 |
|
705 |
ns.create_html_for_versioned_copy_ajax_call = function(key, opt) { |
|
706 |
window.open("controller.pl?action=RequirementSpec/create_html&id=" + encodeURIComponent(ns.find_versioned_copy_id(opt.$trigger) || $('#requirement_spec_id').val()), '_blank'); |
|
707 |
return true; |
|
708 |
}; |
|
709 |
|
|
700 | 710 |
ns.revert_to_versioned_copy_ajax_call = function(key, opt) { |
701 | 711 |
if (!confirm(kivi.t8('Do you really want to revert to this version?'))) |
702 | 712 |
return true; |
... | ... | |
862 | 872 |
// ----------------------------- context menus ----------------------------- |
863 | 873 |
// ------------------------------------------------------------------------- |
864 | 874 |
|
865 |
ns.create_context_menus = function(is_template) {
|
|
866 |
if (is_template) { |
|
875 |
ns.create_context_menus = function(data) {
|
|
876 |
if (data.is_template) {
|
|
867 | 877 |
var general_actions = { |
868 | 878 |
sep98: "---------" |
869 | 879 |
, general_actions: { name: kivi.t8('Requirement spec template actions'), className: 'context-menu-heading' } |
... | ... | |
887 | 897 |
sep98: "---------" |
888 | 898 |
, general_actions: { name: kivi.t8('Requirement spec actions'), className: 'context-menu-heading' } |
889 | 899 |
, create_pdf: { name: kivi.t8('Create PDF'), icon: "pdf", callback: kivi.requirement_spec.create_reqspec_pdf } |
900 |
, create_html: { name: kivi.t8('Create HTML'), icon: "html", callback: kivi.requirement_spec.create_reqspec_html } |
|
890 | 901 |
, create_version: { name: kivi.t8('Create new version'), icon: "new", callback: kivi.requirement_spec.create_version, disabled: kivi.requirement_spec.disable_commands } |
891 | 902 |
, copy_reqspec: { name: kivi.t8('Copy requirement spec'), icon: "copy", callback: kivi.requirement_spec.copy_reqspec } |
892 | 903 |
, delete_reqspec: { name: kivi.t8('Delete requirement spec'), icon: "delete", callback: kivi.requirement_spec.delete_reqspec } |
... | ... | |
896 | 907 |
, paste_template: { name: kivi.t8('Paste template'), icon: "paste", callback: kivi.requirement_spec.paste_template } |
897 | 908 |
}; |
898 | 909 |
|
910 |
var versioned_copy_actions = { |
|
911 |
heading: { name: kivi.t8('Version actions'), className: 'context-menu-heading' } |
|
912 |
, create_version_pdf: { name: kivi.t8('Create PDF'), icon: "pdf", callback: kivi.requirement_spec.create_pdf_for_versioned_copy_ajax_call } |
|
913 |
, create_version_html: { name: kivi.t8('Create HTML'), icon: "html", callback: kivi.requirement_spec.create_html_for_versioned_copy_ajax_call } |
|
914 |
, revert_to_version: { name: kivi.t8('Revert to version'), icon: "revert", callback: kivi.requirement_spec.revert_to_versioned_copy_ajax_call, disabled: kivi.requirement_spec.disable_versioned_copy_item_commands } |
|
915 |
}; |
|
916 |
|
|
917 |
if (!data.html_template_exists) { |
|
918 |
delete general_actions.create_html; |
|
919 |
delete versioned_copy_actions.create_version_html; |
|
920 |
} |
|
921 |
|
|
899 | 922 |
$.contextMenu({ |
900 | 923 |
selector: '.versioned-copy-context-menu', |
901 |
items: $.extend({ |
|
902 |
heading: { name: kivi.t8('Version actions'), className: 'context-menu-heading' } |
|
903 |
, create_version_pdf: { name: kivi.t8('Create PDF'), icon: "pdf", callback: kivi.requirement_spec.create_pdf_for_versioned_copy_ajax_call } |
|
904 |
, revert_to_version: { name: kivi.t8('Revert to version'), icon: "revert", callback: kivi.requirement_spec.revert_to_versioned_copy_ajax_call, disabled: kivi.requirement_spec.disable_versioned_copy_item_commands } |
|
905 |
}, general_actions) |
|
924 |
items: $.extend(versioned_copy_actions, general_actions) |
|
906 | 925 |
}); |
907 | 926 |
|
908 | 927 |
$.contextMenu({ |
locale/de/all | ||
---|---|---|
586 | 586 |
'Create Chart of Accounts' => 'Zu verwendender Kontenplan', |
587 | 587 |
'Create Dataset' => 'Neue Datenbank anlegen', |
588 | 588 |
'Create Date' => 'Erstelldatum', |
589 |
'Create HTML' => 'HTML erzeugen', |
|
589 | 590 |
'Create PDF' => 'PDF erzeugen', |
590 | 591 |
'Create a new acceptance status' => 'Einen neuen Abnahmestatus anlegen', |
591 | 592 |
'Create a new background job' => 'Einen neuen Hintergrund-Job anlegen', |
templates/webpages/requirement_spec/show.html | ||
---|---|---|
92 | 92 |
initially_open: initially_open |
93 | 93 |
, tree_data: tree_data |
94 | 94 |
, is_template: [% SELF.requirement_spec.is_template ? 'true' : 'false' %] |
95 |
, html_template_exists: [% SELF.html_template ? 'true' : 'false' %] |
|
95 | 96 |
[% IF SELF.requirement_spec_item %] |
96 | 97 |
, initially_selected_node: '#fb-[% SELF.requirement_spec_item.id %]' |
97 | 98 |
[% END %] |
Auch abrufbar als: Unified diff
Pflichtenhefte: Ausgabemöglichkeit als HTML
Menüpunkte dafür werden aber nur eingeblendet, sofern auch eine Vorlage
dafür im Vorlagenverzeichnis existiert.
Die erzeugte HTML-Seite wird in einem neuen Browserfenster angezeigt.