From 6ef53d3f84ed5471a251856b0d4b2ca42e2e3992 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 19 Dec 2017 15:28:07 +0100 Subject: [PATCH] Presenter: Neue Struktur in RequirementSpecs umgesetzt --- SL/Controller/RequirementSpec.pm | 8 ++++---- SL/Controller/RequirementSpecItem.pm | 13 +++++++------ SL/Controller/RequirementSpecTextBlock.pm | 4 ++-- templates/print/RB/requirement_spec.tex | 4 ++-- templates/webpages/requirement_spec/show.html | 6 +++--- .../_function_block_content_bottom.html | 2 +- .../requirement_spec_order/_assignment_form.html | 4 ++-- templates/webpages/requirement_spec_part/_edit.html | 2 +- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index 3e1b6433a..b22e15f65 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -490,9 +490,9 @@ sub prepare_report { if (!$is_template) { %column_defs = ( %column_defs, - customer => { raw_data => sub { $self->presenter->customer($_[0]->customer, display => 'table-cell', callback => $callback) }, + customer => { raw_data => sub { $_[0]->customer->presenter->customer(display => 'table-cell', callback => $callback) }, sub => sub { $_[0]->customer->name } }, - projectnumber => { raw_data => sub { $self->presenter->project($_[0]->project, display => 'table-cell', callback => $callback) }, + projectnumber => { raw_data => sub { $_[0]->project ? $_[0]->project->presenter->project(display => 'table-cell', callback => $callback) : '' }, sub => sub { $_[0]->project_id ? $_[0]->project->projectnumber : '' } }, status => { sub => sub { $_[0]->status->description } }, type => { sub => sub { $_[0]->type->description } }, @@ -555,7 +555,7 @@ sub render_pasted_text_block { ->hide('#text-block-list-empty'); } - my $node = $self->presenter->requirement_spec_text_block_jstree_data($text_block); + my $node = $text_block->presenter->jstree_data; my $front_back = $text_block->output_position == 0 ? 'front' : 'back'; $self->js ->jstree->create_node('#tree', "#tb-${front_back}", 'last', $node) @@ -577,7 +577,7 @@ sub set_default_filter_args { sub render_pasted_section { my ($self, $item, $parent_id) = @_; - my $node = $self->presenter->requirement_spec_item_jstree_data($item); + my $node = $item->presenter->jstree_data; $self->js ->jstree->create_node('#tree', $parent_id ? "#fb-${parent_id}" : '#sections', 'last', $node) ->jstree->open_node( '#tree', $parent_id ? "#fb-${parent_id}" : '#sections'); diff --git a/SL/Controller/RequirementSpecItem.pm b/SL/Controller/RequirementSpecItem.pm index b74ebefd0..1c714ffe4 100644 --- a/SL/Controller/RequirementSpecItem.pm +++ b/SL/Controller/RequirementSpecItem.pm @@ -19,6 +19,7 @@ use SL::DB::RequirementSpecRisk; use SL::Helper::Flash; use SL::JSON; use SL::Locale::String; +use SL::Presenter::Text qw(truncate); use Rose::Object::MakeMethods::Generic ( @@ -192,7 +193,7 @@ sub action_ajax_create { my $type = $self->item->item_type; if ($type eq 'section') { - my $node = $self->presenter->requirement_spec_item_jstree_data($self->item); + my $node = $self->item->presenter->jstree_data; $self->invalidate_version; $self->render_list($self->item) ->hide('#section-list-empty') @@ -205,7 +206,7 @@ sub action_ajax_create { my $template = 'requirement_spec_item/_' . (apply { s/-/_/g; $_ } $type); my $html = $self->render($template, { output => 0 }, requirement_spec_item => $self->item, id_prefix => $type eq 'function-block' ? '' : 'sub-'); - my $node = $self->presenter->requirement_spec_item_jstree_data($self->item); + my $node = $self->item->presenter->jstree_data; $self->js ->replaceWith('#' . $prefix . '_form', $html) @@ -298,7 +299,7 @@ sub action_ajax_update { ->remove('#edit_section_form') ->html('#section-header-' . $self->item->id, $html) ->show('#section-header-' . $self->item->id) - ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $::request->presenter->requirement_spec_item_tree_node_title($self->item)) + ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $self->item->presenter->tree_node_title) ->prop('#fb-' . $self->item->id . ' a', 'title', $self->item->content_excerpt) ->addClass('#fb-' . $self->item->id . ' a', 'tooltip') ->reinit_widgets @@ -319,7 +320,7 @@ sub action_ajax_update { ->prop('#fb-' . $self->item->id . ' a', 'title', $self->item->content_excerpt) ->addClass('#fb-' . $self->item->id . ' a', 'tooltip') ->reinit_widgets - ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $::request->presenter->requirement_spec_item_tree_node_title($self->item)); + ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $self->item->presenter->tree_node_title); $self->replace_bottom($self->item, id_prefix => $id_prefix); $self->replace_bottom($self->item->parent) if $type eq 'sub-function-block'; @@ -439,7 +440,7 @@ sub assign_requirement_spec_id_rec { sub create_and_insert_node_rec { my ($self, $item, $new_parent_id, $insert_after) = @_; - my $node = $self->presenter->requirement_spec_item_jstree_data($item); + my $node = $item->presenter->jstree_data; $self->js->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : $new_parent_id ? ('#fb-' . $new_parent_id, 'last') : ('#sections', 'last'), $node); $self->create_and_insert_node_rec($_, $item->id) for @{ $item->children || [] }; @@ -562,7 +563,7 @@ sub select_node { sub create_dependency_item { my $self = shift; - [ $_[0]->id, $self->presenter->truncate(join(' ', grep { $_ } ($_[1], $_[0]->fb_number, $_[0]->description_as_stripped_html))) ]; + [ $_[0]->id, truncate(join(' ', grep { $_ } ($_[1], $_[0]->fb_number, $_[0]->description_as_stripped_html))) ]; } sub create_dependencies { diff --git a/SL/Controller/RequirementSpecTextBlock.pm b/SL/Controller/RequirementSpecTextBlock.pm index 055281907..ca34ede99 100644 --- a/SL/Controller/RequirementSpecTextBlock.pm +++ b/SL/Controller/RequirementSpecTextBlock.pm @@ -102,7 +102,7 @@ sub action_ajax_create { $self->text_block->add_to_list(position => 'after', reference => $insert_after) if $insert_after; my $html = $self->render('requirement_spec_text_block/_text_block', { output => 0 }, text_block => $self->text_block); - my $node = $self->presenter->requirement_spec_text_block_jstree_data($self->text_block); + my $node = $self->text_block->presenter->jstree_data; $self->invalidate_version ->hide('#text-block-list-empty') @@ -272,7 +272,7 @@ sub action_ajax_paste { $self->js->action($::form->{id} ? 'insertAfter' : 'appendTo', $html, '#text-block-' . ($::form->{id} || 'list')); } - my $node = $self->presenter->requirement_spec_text_block_jstree_data($self->text_block); + my $node = $self->text_block->presenter->jstree_data; $self->invalidate_version ->run(SORTABLE_PICTURE_LIST()) ->jstree->create_node('#tree', $::form->{id} ? ('#tb-' . $::form->{id}, 'after') : ("#tb-${front_back}", 'last'), $node) diff --git a/templates/print/RB/requirement_spec.tex b/templates/print/RB/requirement_spec.tex index 84ebec04a..1d22e9cbc 100644 --- a/templates/print/RB/requirement_spec.tex +++ b/templates/print/RB/requirement_spec.tex @@ -145,7 +145,7 @@ $( PROCESS text_block_outputter output_position=0 heading='Allgemeines' )$ \begin{longtable}{p{2.8cm}p{11.7cm}} Funktionsblock & $( KiviLatex.filter(item.fb_number) )$\\ Beschreibung & $( KiviLatex.filter_html(item.description_as_restricted_html) )$\\ - Abhängigkeiten & $( KiviLatex.filter(P.requirement_spec_item_dependency_list(item)) )$ + Abhängigkeiten & $( KiviLatex.filter(item.presenter.requirement_spec_item_dependency_list) )$ \end{longtable}} % $( FOREACH sub_item = item.children_sorted )$ @@ -155,7 +155,7 @@ $( PROCESS text_block_outputter output_position=0 heading='Allgemeines' )$ \begin{longtable}{p{2.8cm}p{11.7cm}} Unterfunktionsblock & $( KiviLatex.filter(sub_item.fb_number) )$\\ Beschreibung & $( KiviLatex.filter_html(sub_item.description_as_restricted_html) )$\\ - Abhängigkeiten & $( KiviLatex.filter(P.requirement_spec_item_dependency_list(sub_item)) )$ + Abhängigkeiten & $( KiviLatex.filter(sub_item.presenter.requirement_spec_item_dependency_list) )$ \end{longtable}} % $( END )$ diff --git a/templates/webpages/requirement_spec/show.html b/templates/webpages/requirement_spec/show.html index c627a1685..3cd23ef75 100644 --- a/templates/webpages/requirement_spec/show.html +++ b/templates/webpages/requirement_spec/show.html @@ -56,7 +56,7 @@ $(function() { attr: { id: "tb-front", class: "text-block-context-menu" }, children: [ [% FOREACH tb = SELF.requirement_spec.text_blocks_sorted(output_position=0) %] - [% P.requirement_spec_text_block_jstree_data(tb).json %][% IF !loop.last %],[% END %] + [% tb.presenter.jstree_data.json %][% IF !loop.last %],[% END %] [% END %] ]}, @@ -65,7 +65,7 @@ $(function() { attr: { id: "sections", class: "section-context-menu" }, children: [ [% FOREACH section = sections %] - [% P.requirement_spec_item_jstree_data(section).json %][% IF !loop.last %],[% END %] + [% section.presenter.jstree_data.json %][% IF !loop.last %],[% END %] [% END %] ]}, @@ -74,7 +74,7 @@ $(function() { attr: { id: "tb-back", class: "text-block-context-menu" }, children: [ [% FOREACH tb = SELF.requirement_spec.text_blocks_sorted(output_position=1) %] - [% P.requirement_spec_text_block_jstree_data(tb).json %][% IF !loop.last %],[% END %] + [% tb.presenter.jstree_data.json %][% IF !loop.last %],[% END %] [% END %] ]} ]; diff --git a/templates/webpages/requirement_spec_item/_function_block_content_bottom.html b/templates/webpages/requirement_spec_item/_function_block_content_bottom.html index 55fbeef62..0f8c01f20 100644 --- a/templates/webpages/requirement_spec_item/_function_block_content_bottom.html +++ b/templates/webpages/requirement_spec_item/_function_block_content_bottom.html @@ -1,7 +1,7 @@ [%- USE LxERP -%][%- USE P -%]
[%- IF requirement_spec_item.dependencies.size -%] - [%- LxERP.t8("Dependencies") -%]: [%- P.requirement_spec_item_dependency_list(requirement_spec_item) -%] + [%- LxERP.t8("Dependencies") -%]: [%- requirement_spec_item.presenter.requirement_spec_item_dependency_list -%]
[%- END -%] diff --git a/templates/webpages/requirement_spec_order/_assignment_form.html b/templates/webpages/requirement_spec_order/_assignment_form.html index 634cb2446..9ec6d13d2 100644 --- a/templates/webpages/requirement_spec_order/_assignment_form.html +++ b/templates/webpages/requirement_spec_order/_assignment_form.html @@ -18,7 +18,7 @@ [% LxERP.t8("Assign the following article to all sections") %]: - [% P.part_picker('quotations_and_orders_dummy', SELF.section_order_part.id, id='quotations_and_orders_order_id', style=style) %] + [% P.part.picker('quotations_and_orders_dummy', SELF.section_order_part.id, id='quotations_and_orders_order_id', style=style) %] [% L.button_tag('kivi.requirement_spec.assign_order_part_id_to_all()', LxERP.t8('Assign article')) %] @@ -43,7 +43,7 @@ [% HTML.escape(section.fb_number) %] [% HTML.escape(section.title) %] [% HTML.escape(P.truncate(section.description_as_stripped_html)) %] - [% P.part_picker('sections[].order_part_id', section.order_part_id, id='quotations_and_orders_sections_order_pard_id_' _ loop.count, style=style) %] + [% P.part.picker('sections[].order_part_id', section.order_part_id, id='quotations_and_orders_sections_order_pard_id_' _ loop.count, style=style) %] [% HTML.escape(section.order_part.unit) %] [% IF section.order_part_id && section.order_part.unit_obj.is_time_based %] diff --git a/templates/webpages/requirement_spec_part/_edit.html b/templates/webpages/requirement_spec_part/_edit.html index c1b2795ba..2c68e76b1 100644 --- a/templates/webpages/requirement_spec_part/_edit.html +++ b/templates/webpages/requirement_spec_part/_edit.html @@ -7,7 +7,7 @@
[% LxERP.t8("Add part") %]: - [% P.part_picker('additional_parts_add_part_id', '', style="width: 300px") %] + [% P.part.picker('additional_parts_add_part_id', '', style="width: 300px") %] [% L.button_tag('kivi.requirement_spec.add_additional_part()', LxERP.t8('Add part')) %]
-- 2.20.1