Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b0ac4850

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID b0ac485034697396a72f36f9bf48f0171b9b1692
  • Vorgänger 0eb8e223
  • Nachfolger 85c4af4a

Pflichtenheftitems: Abschnitte anlegen

Unterschiede anzeigen:

SL/Controller/RequirementSpecItem.pm
92 92
    $js->hide('#section-list-empty');
93 93

  
94 94
    my $id_prefix = $new_type eq 'sub-function-block' ? 'sub-' : '';
95
    my $template  = apply { s/-/_/g; $_ } $new_type;
96
    my $html      = "" . $self->render('requirement_spec_item/_' . $template, { output => 0 }, requirement_spec_item => $self->item);
95
    my $template  = 'requirement_spec_item/_' . (apply { s/-/_/g; $_ } $new_type);
96
    my $html      = "" . $self->render($template, { output => 0 }, requirement_spec_item => $self->item);
97 97
    my $next_item = $self->item->get_next_in_list;
98 98

  
99 99
    if ($next_item) {
......
112 112
  $self->render($js);
113 113
}
114 114

  
115
sub action_ajax_add {
115
sub action_ajax_add_section {
116 116
  my ($self, %params) = @_;
117 117

  
118
  die "TODO: add action";
118
  die "Missing parameter 'requirement_spec_id'" if !$::form->{requirement_spec_id};
119

  
120
  $self->item(SL::DB::RequirementSpecItem->new(requirement_spec_id => $::form->{requirement_spec_id}));
121

  
122
  my $insert_after = $::form->{id} ? SL::DB::RequirementSpecItem->new(id => $::form->{id})->load->get_section->id : undef;
123
  my $html         = $self->render('requirement_spec_item/_section_form', { output => 0 }, id_base => 'new_section', insert_after => $insert_after);
124

  
125
  SL::ClientJS->new
126
    ->remove('#new_section_form')
127
    ->hide('#column-content > *')
128
    ->appendTo($html, '#column-content')
129
    ->focus('#new_section_title')
130
    ->render($self);
131
}
132

  
133
sub action_ajax_create {
134
  my ($self, %params) = @_;
135

  
136
  my $js              = SL::ClientJS->new;
137
  my $prefix          = $::form->{form_prefix} || die "Missing parameter 'form_prefix'";
138
  my $attributes      = $::form->{$prefix}     || die "Missing parameter group '${prefix}'";
139
  my $insert_after    = delete $attributes->{insert_after};
140

  
141
  my @errors = $self->item(SL::DB::RequirementSpecItem->new(%{ $attributes }))->validate;
142
  return $js->error(@errors)->render($self) if @errors;
143

  
144
  $self->item->save;
145
  $self->item->add_to_list(position => 'after', reference => $insert_after) if $insert_after;
146

  
147
  my $type = $self->item->get_type;
148

  
149
  if ($type eq 'section') {
150
    my $node = $self->presenter->requirement_spec_item_jstree_data($self->item);
151
    return $self->render_list($js, $self->item)
152
      ->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : ('#sections', 'last'), $node)
153
      ->jstree->select_node('#tree', '#fb-' . $self->item->id)
154
      ->render($self);
155
  }
156

  
157
  die 'TODO: create item';
119 158
}
120 159

  
121 160
sub action_ajax_edit {
......
178 217
  my ($self, %params) = @_;
179 218

  
180 219
  my $js         = SL::ClientJS->new;
181
  my $prefix     = $::form->{form_prefix} || 'function_block';
220
  my $prefix     = $::form->{form_prefix} || die "Missing parameter 'form_prefix'";
182 221
  my $attributes = $::form->{$prefix}     || {};
183 222

  
184 223
  foreach (qw(requirement_spec_id parent_id position)) {

Auch abrufbar als: Unified diff