X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/80547a321cf7337027768e99e68eb0d0adbb370d..442b26e2b4f442a41fbe5fa256b12c0e01219190:/SL/DB/RequirementSpecItem.pm diff --git a/SL/DB/RequirementSpecItem.pm b/SL/DB/RequirementSpecItem.pm index 9322c32b7..1bc44c28d 100644 --- a/SL/DB/RequirementSpecItem.pm +++ b/SL/DB/RequirementSpecItem.pm @@ -7,10 +7,22 @@ use SL::DB::Manager::RequirementSpecItem; use SL::DB::Helper::ActsAsList; __PACKAGE__->meta->add_relationship( - children => { - type => 'one to many', - class => 'SL::DB::RequirementSpecItem', - column_map => { id => 'parent_id' }, + children => { + type => 'one to many', + class => 'SL::DB::RequirementSpecItem', + column_map => { id => 'parent_id' }, + }, + dependencies => { + map_class => 'SL::DB::RequirementSpecDependency', + map_from => 'depending_item', + map_to => 'depended_item', + type => 'many to many', + }, + dependents => { + map_class => 'SL::DB::RequirementSpecDependency', + map_from => 'depended_item', + map_to => 'depending_item', + type => 'many to many', }, ); @@ -31,10 +43,34 @@ sub _before_delete_delete_children { 1; } +sub validate { + my ($self) = @_; + + my @errors; + push @errors, t8('The title is missing.') if !$self->parent_id && !$self->title; + + return @errors; +} + sub sorted_children { my ($self) = @_; return [ sort { $a->position <=> $b->position } @{ $self->children } ]; } +sub get_section { + my ($self) = @_; + + $self = $self->parent while $self->parent_id; + + return $self; +} + +sub get_type { + my ($self) = @_; + + return 'section' if !$self->parent_id; + return $self->parent->parent_id ? 'sub-function-block' : 'function-block'; +} + 1;