X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/1f592a0f4f88893b5c2cb29b2d10e2d07b444ac0..a9cc182f3613fd21a698c9f40b8c5908d92c9da5:/SL/Controller/RequirementSpecTextBlock.pm diff --git a/SL/Controller/RequirementSpecTextBlock.pm b/SL/Controller/RequirementSpecTextBlock.pm index ca620214f..931c27d59 100644 --- a/SL/Controller/RequirementSpecTextBlock.pm +++ b/SL/Controller/RequirementSpecTextBlock.pm @@ -19,7 +19,7 @@ use Rose::Object::MakeMethods::Generic 'scalar --get_set_init' => [ qw(predefined_texts) ], ); -__PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(ajax_edit ajax_update ajax_delete dragged_and_dropped)]); +__PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(ajax_edit ajax_update ajax_delete ajax_flag dragged_and_dropped)]); # # actions @@ -172,6 +172,19 @@ sub action_ajax_delete { ->render($self); } +sub action_ajax_flag { + my ($self) = @_; + + $self->text_block->update_attributes(is_flagged => !$self->text_block->is_flagged); + + my $current_where = $self->output_position_from_id($::form->{current_content_id}, $::form->{current_content_type}); + + SL::ClientJS->new + ->action_if($current_where == $self->text_block->output_position, 'toggleClass', '#text-block-' . $self->text_block->id, 'flagged') + ->toggleClass('#tb-' . $self->text_block->id, 'flagged') + ->render($self); +} + sub action_dragged_and_dropped { my ($self) = @_; @@ -226,7 +239,7 @@ sub action_dragged_and_dropped { if ($prior_text_block) { $js->insertAfter($html, '#text-block-' . $prior_text_block->id); } else { - $js->appendTo($html, '#text-block-list'); + $js->prependTo($html, '#text-block-list'); } } } @@ -260,7 +273,7 @@ sub output_position_from_id { return undef if $type !~ m/text-block/; } - my $text_block = SL::DB::Manager::RequirementSpecTextBlock->find_by(id => $id); + my $text_block = $id ? SL::DB::Manager::RequirementSpecTextBlock->find_by(id => $id) : undef; return $text_block ? $text_block->output_position : undef; }