1 package SL::Controller::RequirementSpecStatus;
5 use parent qw(SL::Controller::Base);
7 use SL::DB::RequirementSpecStatus;
9 use SL::Locale::String;
11 use Rose::Object::MakeMethods::Generic
13 scalar => [ qw(requirement_spec_status valid_names) ],
16 __PACKAGE__->run_before('check_auth');
17 __PACKAGE__->run_before('load_requirement_spec_status', only => [ qw(edit update destroy) ]);
18 __PACKAGE__->run_before(sub { $_[0]->valid_names(\@SL::DB::RequirementSpecStatus::valid_names) });
27 $self->render('requirement_spec_status/list',
28 title => t8('Requirement Spec Statuses'),
29 REQUIREMENT_SPEC_STATUSES => SL::DB::Manager::RequirementSpecStatus->get_all_sorted);
35 $self->{requirement_spec_status} = SL::DB::RequirementSpecStatus->new;
36 $self->render('requirement_spec_status/form', title => t8('Create a new requirement spec status'));
41 $self->render('requirement_spec_status/form', title => t8('Edit requirement spec status'));
47 $self->{requirement_spec_status} = SL::DB::RequirementSpecStatus->new;
48 $self->create_or_update;
53 $self->create_or_update;
59 if (eval { $self->{requirement_spec_status}->delete; 1; }) {
60 flash_later('info', t8('The requirement spec status has been deleted.'));
62 flash_later('error', t8('The requirement spec status is in use and cannot be deleted.'));
65 $self->redirect_to(action => 'list');
71 SL::DB::RequirementSpecStatus->reorder_list(@{ $::form->{requirement_spec_status_id} || [] });
73 $self->render(\'', { type => 'json' });
81 $::auth->assert('config');
88 sub create_or_update {
90 my $is_new = !$self->{requirement_spec_status}->id;
91 my $params = delete($::form->{requirement_spec_status}) || { };
92 my $title = $is_new ? t8('Create a new requirement spec status') : t8('Edit requirement spec status');
94 $self->{requirement_spec_status}->assign_attributes(%{ $params });
96 my @errors = $self->{requirement_spec_status}->validate;
99 flash('error', @errors);
100 $self->render('requirement_spec_status/form', title => $title);
104 $self->{requirement_spec_status}->save;
106 flash_later('info', $is_new ? t8('The requirement spec status has been created.') : t8('The requirement spec status has been saved.'));
107 $self->redirect_to(action => 'list');
110 sub load_requirement_spec_status {
112 $self->{requirement_spec_status} = SL::DB::RequirementSpecStatus->new(id => $::form->{id})->load;