1 package SL::DB::RequirementSpecTextBlock;
5 use List::MoreUtils qw(any);
6 use Rose::DB::Object::Helpers;
7 use Rose::DB::Object::Util;
9 use SL::DB::MetaSetup::RequirementSpecTextBlock;
10 use SL::DB::Manager::RequirementSpecTextBlock;
11 use SL::DB::Helper::ActsAsList;
12 use SL::Locale::String;
14 __PACKAGE__->meta->initialize;
16 __PACKAGE__->configure_acts_as_list(group_by => [qw(requirement_spec_id output_position)]);
18 __PACKAGE__->before_save(\ &_before_save_invalidate_requirement_spec_version);
19 __PACKAGE__->before_delete(\&_before_delete_invalidate_requirement_spec_version);
25 push @errors, t8('The title is missing.') if !$self->title;
30 sub _before_save_invalidate_requirement_spec_version {
31 my ($self, %params) = @_;
34 return 1 if !$self->requirement_spec_id;
36 my %changed_columns = map { $_ => 1 } (Rose::DB::Object::Helpers::dirty_columns($self));
38 $self->requirement_spec->invalidate_version
39 if !Rose::DB::Object::Util::is_in_db($self) || any { $changed_columns{$_} } qw(title text position output_position);
44 sub _before_delete_invalidate_requirement_spec_version {
45 my ($self, %params) = @_;
47 $self->requirement_spec->invalidate_version if $self->requirement_spec_id;