X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FRequirementSpecTextBlock.pm;h=421293a87d5a9e006023c91279c22854accce28d;hb=9cddaf376822b4229457212a27d5d98958f11368;hp=832d3414f099d1b89c15d7a3457b6c50ce620819;hpb=13fbd33663c229ec309a858ac1d393fdd508ddbe;p=kivitendo-erp.git diff --git a/SL/DB/RequirementSpecTextBlock.pm b/SL/DB/RequirementSpecTextBlock.pm index 832d3414f..421293a87 100644 --- a/SL/DB/RequirementSpecTextBlock.pm +++ b/SL/DB/RequirementSpecTextBlock.pm @@ -2,6 +2,7 @@ package SL::DB::RequirementSpecTextBlock; use strict; +use Carp; use List::MoreUtils qw(any); use Rose::DB::Object::Helpers; use Rose::DB::Object::Util; @@ -11,6 +12,14 @@ use SL::DB::Manager::RequirementSpecTextBlock; use SL::DB::Helper::ActsAsList; use SL::Locale::String; +__PACKAGE__->meta->add_relationship( + pictures => { + type => 'one to many', + class => 'SL::DB::RequirementSpecPicture', + column_map => { id => 'text_block_id' }, + }, +); + __PACKAGE__->meta->initialize; __PACKAGE__->configure_acts_as_list(group_by => [qw(requirement_spec_id output_position)]); @@ -48,4 +57,12 @@ sub _before_delete_invalidate_requirement_spec_version { return 1; } +sub pictures_sorted { + my ($self, @args) = @_; + + croak "Not a writer" if @args; + + return [ sort { $a->position <=> $b->position } $self->pictures ]; +} + 1;