From 7c54e92fc42214744a82cec3f648d0e044ede238 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 12 Jan 2015 16:45:06 +0100 Subject: [PATCH] =?utf8?q?Pflichtenhefte:=20Ausgabem=C3=B6glichkeit=20als?= =?utf8?q?=20HTML?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. --- SL/Controller/RequirementSpec.pm | 31 +++++++++++++++- css/requirement_spec.css | 1 + image/text-html.png | Bin 0 -> 748 bytes js/locale/de.js | 1 + js/requirement_spec.js | 35 ++++++++++++++---- locale/de/all | 1 + templates/webpages/requirement_spec/show.html | 1 + 7 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 image/text-html.png diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index d65ce8926..3158cd09a 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -21,6 +21,7 @@ use SL::DB::RequirementSpecRisk; use SL::DB::RequirementSpecStatus; use SL::DB::RequirementSpecType; use SL::DB::RequirementSpec; +use SL::Helper::CreatePDF qw(); use SL::Helper::Flash; use SL::Locale::String; use SL::Template::LaTeX; @@ -29,7 +30,7 @@ use Rose::Object::MakeMethods::Generic ( scalar => [ qw(requirement_spec_item visible_item visible_section) ], '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 - current_text_block_output_position models time_based_units) ], + current_text_block_output_position models time_based_units html_template) ], ); __PACKAGE__->run_before('setup'); @@ -231,6 +232,27 @@ sub action_create_pdf { unlink $result{file_name}; } +sub action_create_html { + my ($self, %params) = @_; + + my $base_name = $self->requirement_spec->type->template_file_name || 'requirement_spec'; + my @pictures = $self->prepare_pictures_for_printing; + my $content = SL::Helper::CreatePDF->create_parsed_file( + template => "${base_name}.html", + format => 'html', + template_type => 'HTML', + variables => { + SELF => $self, + rspec => $self->requirement_spec, + }); + + # $content is now a scalar of bytes, but $self->render() expects a + # scalar of characters. + $content = Encode::decode('utf-8', $content); + + $self->render(\$content, { layout => 0, process => 0 }); +} + sub action_select_template_to_paste { my ($self) = @_; @@ -613,4 +635,11 @@ sub init_models { ); } +sub init_html_template { + my ($self) = @_; + my $base_name = $self->requirement_spec->type->template_file_name || 'requirement_spec'; + my $template = SL::Helper::CreatePDF->find_template(name => $base_name, extension => 'html'); + return !!$template; +} + 1; diff --git a/css/requirement_spec.css b/css/requirement_spec.css index 123713398..9dbd0d693 100644 --- a/css/requirement_spec.css +++ b/css/requirement_spec.css @@ -48,6 +48,7 @@ table.rs_input_field input, table.rs_input_field select { .context-menu-item.icon-save { background-image: url("../image/document-save.png"); } .context-menu-item.icon-revert { background-image: url("../image/edit-undo.png"); } .context-menu-item.icon-pdf { background-image: url("../image/application-pdf.png"); } +.context-menu-item.icon-html { background-image: url("../image/text-html.png"); } .context-menu-item.icon-add-picture { background-image: url("../image/add-picture.png"); } .context-menu-item.icon-download { background-image: url("../image/download.png"); } .context-menu-item.icon-renumber { background-image: url("../image/format-list-ordered.png"); } diff --git a/image/text-html.png b/image/text-html.png new file mode 100644 index 0000000000000000000000000000000000000000..4961d34f69289008e155a17ecdb8d56af9e135b1 GIT binary patch literal 748 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L02{9W02{9XUK)`c00007bV*G`2ipMw z5+NM6%{D6l00L}DL_t(I%axPgOH*+e#y{uBoS5m_)Jl^ISE5cr22mFcvml5NyY3>o zjQ)YV3<`t@yO3_{Ci0>nFbKS{g0d8|ADf{<=+ty>XFHplXXk9^e7h*c=`QNI{J!t= zywCG}c_jd!&sVK!S|_0LZz#Im?itfG(_0Vc#D4;~%#Mi)fVRGltjH*e%*Tl(5^0N# zT!DkWNc%2RhL3I5@YmJ4DZnfMkiOOR%Hxrndf6GTn#mHk*Oe^3PpqWJ$7Lyd-$z*dD*RP%3=Eyq*UXDenYipwQxEIZV z)|Lix!e&!(k(XtbwJiMuZ_7KFnp(xItfJYsk7B{W=T@nd1@oFg(JbO9GNuDv-5tCb zncXWeGZ*94_#%he8xg8P!2!!K@YlNdvF0ElP*so>n4OQ8i6DWQF&G}5V>O=TLwJ?< z-_}_ArDJaz*k+zwI)jzlK#0O#2kj^7vC}!MM24Z^X#y>E1nR4JGxw8)=?UzdfoxdV zhik?88#g6jwL~BoY{F$2STP;dwCD;QqvePPJrZZ;%g|PvaBNHJ3ZCu{bOb(!BjM65 zJbu_qM$eN^W*L4qNv#|9SN^H#x-RBtXQht7sXKZqbw3;lJA2mH)6>S&dlzsiGQwL! z(H2N*1%S|#NvXH5Z$OL3??$6hd&k!S&@F@*%jfgBRE5P@mIqJ9Sx%&I@(D5W=$7O^ z**2&p61R0-x5`~tX!o%=c2O9cS+Nvd5PrXZu%@QQU5=;%cs!nINs>alBmKpO$K&~) e$z%%U1bzd!UsExS`SoA`0000{texts} = { 'Create Chart of Accounts' => 'Zu verwendender Kontenplan', 'Create Dataset' => 'Neue Datenbank anlegen', 'Create Date' => 'Erstelldatum', + 'Create HTML' => 'HTML erzeugen', 'Create PDF' => 'PDF erzeugen', 'Create a new acceptance status' => 'Einen neuen Abnahmestatus anlegen', 'Create a new background job' => 'Einen neuen Hintergrund-Job anlegen', diff --git a/templates/webpages/requirement_spec/show.html b/templates/webpages/requirement_spec/show.html index c329a4e4d..285dcee15 100644 --- a/templates/webpages/requirement_spec/show.html +++ b/templates/webpages/requirement_spec/show.html @@ -92,6 +92,7 @@ $(function() { initially_open: initially_open , tree_data: tree_data , is_template: [% SELF.requirement_spec.is_template ? 'true' : 'false' %] + , html_template_exists: [% SELF.html_template ? 'true' : 'false' %] [% IF SELF.requirement_spec_item %] , initially_selected_node: '#fb-[% SELF.requirement_spec_item.id %]' [% END %] -- 2.20.1