Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 84fc52bd

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 84fc52bdc02b7b84f7a644cf2bed484f1213d9ce
  • Vorgänger dc1cf0b0
  • Nachfolger d9ddb4ea

Pflichtenhefte: PDFs zu Arbeitskopie und Versionen erzeugen

Unterschiede anzeigen:

SL/DB/RequirementSpec.pm
8 8
use SL::DB::MetaSetup::RequirementSpec;
9 9
use SL::DB::Manager::RequirementSpec;
10 10
use SL::Locale::String;
11
use SL::Util qw(_hashify);
11 12

  
12 13
__PACKAGE__->meta->add_relationship(
13 14
  items            => {
......
49 50
  return 1;
50 51
}
51 52

  
52
sub text_blocks_for_position {
53
  my ($self, $output_position) = @_;
53
sub text_blocks_sorted {
54
  my ($self, %params) = _hashify(1, @_);
54 55

  
55
  return [ sort { $a->position <=> $b->position } grep { $_->output_position == $output_position } @{ $self->text_blocks } ];
56
  my @text_blocks = @{ $self->text_blocks };
57
  @text_blocks    = grep { $_->output_position == $params{output_position} } @text_blocks if exists $params{output_position};
58
  @text_blocks    = sort { $a->position        <=> $b->position            } @text_blocks;
59

  
60
  return wantarray ? @text_blocks : \@text_blocks;
56 61
}
57 62

  
58
sub sections {
63
sub sections_sorted {
59 64
  my ($self, @rest) = @_;
60 65

  
61 66
  croak "This sub is not a writer" if @rest;
62 67

  
63
  return [ sort { $a->position <=> $b->position } grep { !$_->parent_id } @{ $self->items } ];
68
  my @sections = sort { $a->position <=> $b->position } grep { !$_->parent_id } @{ $self->items };
69
  return wantarray ? @sections : \@sections;
64 70
}
65 71

  
72
sub sections { &sections_sorted; }
73

  
66 74
sub displayable_name {
67 75
  my ($self) = @_;
68 76

  
69 77
  return sprintf('%s: "%s"', $self->type->description, $self->title);
70 78
}
71 79

  
80
sub versioned_copies_sorted {
81
  my ($self, %params) = _hashify(1, @_);
82

  
83
  my @copies = @{ $self->versioned_copies };
84
  @copies    = grep { $_->version->version_number <=  $params{max_version_number} } @copies if $params{max_version_number};
85
  @copies    = sort { $a->version->version_number <=> $b->version->version_number } @copies;
86

  
87
  return wantarray ? @copies : \@copies;
88
}
89

  
72 90
sub create_copy {
73 91
  my ($self, %params) = @_;
74 92

  
......
195 213
sub create_version {
196 214
  my ($self, %attributes) = @_;
197 215

  
216
  croak "Cannot work on a versioned copy" if $self->working_copy_id;
217

  
198 218
  my ($copy, $version);
199 219
  my $ok = $self->db->do_transaction(sub {
200 220
    delete $attributes{version_number};
......
213 233
sub invalidate_version {
214 234
  my ($self, %params) = @_;
215 235

  
216
  $::lxdebug->message(0, "Invalidate version called for id " . $self->id . " version " . $self->version_id);
217
  $::lxdebug->show_backtrace(1);
236
  croak "Cannot work on a versioned copy" if $self->working_copy_id;
218 237

  
219 238
  return if !$self->id || !$self->version_id;
220 239
  $self->update_attributes(version_id => undef);

Auch abrufbar als: Unified diff