Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8e082571

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 8e082571fb1ea2d8a46b863a764a56fb26823226
  • Vorgänger 73816905
  • Nachfolger 1ae7f9a1

Pflichtenheft: Projektverknüpfung anlegen, bearbeiten

- Pflichtenhefte mit einem bestehenden Projekt verknüpfen,
- neues Projekt anlegen,
- nicht mit einem Projekt verknüpfen.

Unterschiede anzeigen:

SL/Controller/RequirementSpec.pm
18 18
use SL::Controller::Helper::RequirementSpec;
19 19
use SL::DB::Customer;
20 20
use SL::DB::Project;
21
use SL::DB::ProjectStatus;
22
use SL::DB::ProjectType;
21 23
use SL::DB::RequirementSpecComplexity;
22 24
use SL::DB::RequirementSpecRisk;
23 25
use SL::DB::RequirementSpecStatus;
......
29 31

  
30 32
use Rose::Object::MakeMethods::Generic
31 33
(
32
  scalar                  => [ qw(requirement_spec_item customers types statuses visible_item visible_section) ],
33
  'scalar --get_set_init' => [ qw(requirement_spec complexities risks projects copy_source js current_text_block_output_position) ],
34
  scalar                  => [ qw(requirement_spec_item visible_item visible_section) ],
35
  'scalar --get_set_init' => [ qw(requirement_spec customers types statuses complexities risks projects project_types project_statuses default_project_type default_project_status copy_source js
36
                                  current_text_block_output_position) ],
34 37
);
35 38

  
36 39
__PACKAGE__->run_before('setup');
37
__PACKAGE__->run_before('load_select_options',  only => [ qw(new ajax_edit create update list) ]);
38 40

  
39 41
__PACKAGE__->make_filtered(
40 42
  MODEL      => 'RequirementSpec',
......
110 112
    ->render($self);
111 113
}
112 114

  
115
sub action_ajax_edit_project_link {
116
  my ($self) = @_;
117

  
118
  my $html   = $self->render('requirement_spec/_project_link_form', { output => 0 }, submit_as => 'ajax');
119

  
120
  $self->js
121
    ->hide('#basic_settings')
122
    ->after('#basic_settings', $html)
123
    ->render($self);
124
}
125

  
113 126
sub action_ajax_show_time_and_cost_estimate {
114 127
  my ($self) = @_;
115 128

  
......
186 199
  $self->create_or_update;
187 200
}
188 201

  
202
sub action_update_project_link {
203
  my $self   = shift;
204
  my $action = delete($::form->{project_link_action}) || 'keep';
205

  
206
  return $self->update_project_link_none_keep_existing($action) if $action =~ m{none|keep|existing};
207
  return $self->update_project_link_new($action)                if $action eq 'new';
208
  return $self->update_project_link_create($action)             if $action eq 'create';
209

  
210
  die "Unknown project link action '$action'";
211
}
212

  
189 213
sub action_destroy {
190 214
  my ($self) = @_;
191 215

  
......
273 297
  return 1;
274 298
}
275 299

  
276
sub init_complexities {
300
sub init_js                     { SL::ClientJS->new                                           }
301
sub init_complexities           { SL::DB::Manager::RequirementSpecComplexity->get_all_sorted  }
302
sub init_default_project_status { SL::DB::Manager::ProjectStatus->find_by(name => 'planning') }
303
sub init_default_project_type   { SL::DB::ProjectType->new(id => 1)->load                     }
304
sub init_project_statuses       { SL::DB::Manager::ProjectStatus->get_all_sorted              }
305
sub init_project_types          { SL::DB::Manager::ProjectType->get_all_sorted                }
306
sub init_projects               { SL::DB::Manager::Project->get_all_sorted                    }
307
sub init_risks                  { SL::DB::Manager::RequirementSpecRisk->get_all_sorted        }
308
sub init_statuses               { SL::DB::Manager::RequirementSpecStatus->get_all_sorted      }
309
sub init_types                  { SL::DB::Manager::RequirementSpecType->get_all_sorted        }
310

  
311
sub init_customers {
277 312
  my ($self) = @_;
278
  return SL::DB::Manager::RequirementSpecComplexity->get_all_sorted;
279
}
280 313

  
281
sub init_risks {
282
  my ($self) = @_;
283
  return SL::DB::Manager::RequirementSpecRisk->get_all_sorted;
284
}
314
  my @filter = ('!obsolete' => 1);
315
  @filter    = ( or => [ @filter, id => $self->requirement_spec->customer_id ] ) if $self->requirement_spec && $self->requirement_spec->customer_id;
285 316

  
286
sub init_projects {
287
  my ($self) = @_;
288
  $self->projects(SL::DB::Manager::Project->get_all_sorted);
317
  return SL::DB::Manager::Customer->get_all_sorted(where => \@filter);
289 318
}
290 319

  
291 320
sub init_requirement_spec {
......
298 327
  $self->copy_source(SL::DB::RequirementSpec->new(id => $::form->{copy_source_id})->load) if $::form->{copy_source_id};
299 328
}
300 329

  
301
sub init_js {
302
  my ($self) = @_;
303
  $self->js(SL::ClientJS->new);
304
}
305

  
306 330
sub init_current_text_block_output_position {
307 331
  my ($self) = @_;
308 332
  $self->current_text_block_output_position($::form->{current_content_type} !~ m/^(?:text-blocks|tb)-(front|back)/ ? -1 : $1 eq 'front' ? 0 : 1);
309 333
}
310 334

  
311
sub load_select_options {
312
  my ($self) = @_;
313

  
314
  my @filter = ('!obsolete' => 1);
315
  @filter    = ( or => [ @filter, id => $self->requirement_spec->customer_id ] ) if $self->requirement_spec && $self->requirement_spec->customer_id;
316

  
317
  $self->customers(SL::DB::Manager::Customer->get_all_sorted(where => \@filter));
318
  $self->statuses( SL::DB::Manager::RequirementSpecStatus->get_all_sorted);
319
  $self->types(    SL::DB::Manager::RequirementSpecType->get_all_sorted);
320
}
321

  
322 335
#
323 336
# helpers
324 337
#
......
502 515
  return @files;
503 516
}
504 517

  
518
sub update_project_link_none_keep_existing {
519
  my ($self, $action) = @_;
520

  
521
  $self->requirement_spec->update_attributes(project_id => undef)                     if $action eq 'none';
522
  $self->requirement_spec->update_attributes(project_id => $::form->{new_project_id}) if $action eq 'existing';
523

  
524
  return $self->invalidate_version
525
    ->replaceWith('#basic_settings', $self->render('requirement_spec/_show_basic_settings', { output => 0 }))
526
    ->remove('#project_link_form')
527
    ->flash('info', t8('The project link has been updated.'))
528
    ->render($self);
529
}
530

  
531
sub update_project_link_new {
532
  my ($self) = @_;
533

  
534
  return $self->js
535
    ->replaceWith('#project_link_form', $self->render('requirement_spec/_new_project_form', { output => 0 }))
536
    ->render($self);
537
}
538

  
539
sub update_project_link_create {
540
  my ($self)  = @_;
541
  my $params  = delete($::form->{project}) || {};
542
  my $project = SL::DB::Project->new(
543
    %{ $params },
544
    valid  => 1,
545
    active => 1,
546
  );
547

  
548
  my @errors = $project->validate;
549

  
550
  return $self->js->error(@errors)->render($self) if @errors;
551

  
552
  my $db = $self->requirement_spec->db;
553
  if (!$db->do_transaction(sub {
554
    $project->save;
555
    $self->requirement_spec->update_attributes(project_id => $project->id);
556

  
557
  })) {
558
    $::lxdebug->message(LXDebug::WARN(), "Error: " . $db->error);
559
    return $self->js->error(t8('Saving failed. Error message from the database: #1', $db->error))->render($self);
560
  }
561

  
562
  return $self->invalidate_version
563
    ->replaceWith('#basic_settings', $self->render('requirement_spec/_show_basic_settings', { output => 0 }))
564
    ->remove('#project_link_form')
565
    ->flash('info', t8('The project has been created.'))
566
    ->flash('info', t8('The project link has been updated.'))
567
    ->render($self);
568
}
569

  
505 570
1;

Auch abrufbar als: Unified diff