epic-ts
[kivitendo-erp.git] / SL / Clipboard / RequirementSpecTextBlock.pm
1 package SL::Clipboard::RequirementSpecTextBlock;
2
3 use strict;
4
5 use parent qw(SL::Clipboard::Base);
6
7 use SL::Clipboard::RequirementSpecPicture;
8 use SL::Common;
9 use SL::Locale::String;
10
11 sub dump {
12   my ($self, $object) = @_;
13
14   $self->reload_object($object);
15
16   my $tree          = $self->as_tree($object, exclude => sub { ref($_[0]) !~ m/::RequirementSpecTextBlock$/ });
17   $tree->{pictures} = [ map { SL::Clipboard::RequirementSpecPicture->new->dump($_) } @{ $object->pictures } ];
18
19   return $tree;
20 }
21
22 sub describe {
23   my ($self) = @_;
24
25   return t8('Requirement spec text block "#1"; content: "#2"', $self->content->{title}, Common::truncate($self->content->{text}, strip => 'full'));
26 }
27
28 sub _fix_object {
29   my ($self, $object) = @_;
30
31   $object->$_(undef) for qw(output_position position requirement_spec_id);
32
33   SL::Clipboard::RequirementSpecPicture->new->_fix_object($_) for @{ $object->pictures || [] };
34
35   return $object;
36 }
37
38 1;
39 __END__
40
41 =pod
42
43 =encoding utf8
44
45 =head1 NAME
46
47 SL::Clipboard::RequirementSpecTextBlock - Clipboard specialization for
48 SL::DB::RequirementSpecTextBlock
49
50 =head1 FUNCTIONS
51
52 =over 4
53
54 =item C<describe>
55
56 Returns a human-readable description including the title and an
57 excerpt of its content.
58
59 =item C<dump $object>
60
61 This specialization reloads C<$object> from the database, loads all of
62 its pictures and dumps it. The pictures are dumped using the clipboard
63 specialization for it, L<SL::Clipboard::RequirementSpecPicture/dump>.
64
65 =item C<_fix_object $object>
66
67 Fixes C<$object> by clearing certain columns like the position. Lets
68 pictures be fixed by the clipboard specialization for it,
69 L<SL::Clipboard::RequirementSpecPicture/_fix_object>.
70
71 =back
72
73 =head1 BUGS
74
75 Nothing here yet.
76
77 =head1 AUTHOR
78
79 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
80
81 =cut