Revision 602e604a
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/Controller/RequirementSpecTextBlock.pm | ||
---|---|---|
6 | 6 |
|
7 | 7 |
use SL::ClientJS; |
8 | 8 |
use SL::DB::RequirementSpec; |
9 |
use SL::DB::RequirementSpecPredefinedText; |
|
9 | 10 |
use SL::DB::RequirementSpecTextBlock; |
10 | 11 |
use SL::Helper::Flash; |
11 | 12 |
use SL::JSON; |
... | ... | |
16 | 17 |
scalar => [ qw(requirement_spec text_block) ], |
17 | 18 |
); |
18 | 19 |
|
19 |
__PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(dragged_and_dropped)]); |
|
20 |
__PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(ajax_edit update dragged_and_dropped)]);
|
|
20 | 21 |
|
21 | 22 |
# |
22 | 23 |
# actions |
... | ... | |
41 | 42 |
my $js = SL::ClientJS->new; |
42 | 43 |
|
43 | 44 |
if (!defined($current_where) || ($new_where != $current_where)) { |
44 |
my $text_blocks = SL::DB::Manager::RequirementSpecTextBlock->get_all_sorted(where => [ output_position => $new_where ]); |
|
45 |
my $html = $self->render('requirement_spec_text_block/ajax_list', { output => 0 }, TEXT_BLOCKS => $text_blocks, output_position => $new_where, nownow => DateTime->now_local);
|
|
45 |
my $text_blocks = SL::DB::Manager::RequirementSpecTextBlock->get_all_sorted(where => [ output_position => $new_where, requirement_spec_id => $::form->{requirement_spec_id} ]);
|
|
46 |
my $html = $self->render('requirement_spec_text_block/ajax_list', { output => 0 }, TEXT_BLOCKS => $text_blocks, output_position => $new_where); |
|
46 | 47 |
|
47 | 48 |
$js->html('#column-content', $html) |
48 | 49 |
} |
... | ... | |
50 | 51 |
$self->render($js); |
51 | 52 |
} |
52 | 53 |
|
54 |
sub action_ajax_edit { |
|
55 |
my ($self) = @_; |
|
56 |
|
|
57 |
my $js = SL::ClientJS->new; |
|
58 |
|
|
59 |
my $current_where = $self->output_position_from_id($::form->{current_content_id}, $::form->{current_content_type}) // -1; |
|
60 |
if ($self->text_block->output_position != $current_where) { |
|
61 |
my $text_blocks = $self->text_block->get_full_list; |
|
62 |
my $html = $self->render('requirement_spec_text_block/ajax_list', { output => 0 }, TEXT_BLOCKS => $text_blocks, output_position => $self->text_block->output_position); |
|
63 |
|
|
64 |
$js->html('#column-content', $html) |
|
65 |
->val('#current_content_type', 'text-block') |
|
66 |
->val('#current_content_id', $self->text_block->id); |
|
67 |
} |
|
68 |
|
|
69 |
my $predefined_texts = SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted; |
|
70 |
my $html = $self->render('requirement_spec_text_block/_form', { output => 0 }, PREDEFINED_TEXTS => $predefined_texts); |
|
71 |
|
|
72 |
$js->hide('#text-block-' . $self->text_block->id) |
|
73 |
->insertAfter($html, '#text-block-' . $self->text_block->id) |
|
74 |
->jstree->select_node('#tree', '#tb-' . $self->text_block->id) |
|
75 |
->render($self); |
|
76 |
} |
|
77 |
|
|
78 |
sub action_update { |
|
79 |
my ($self, %params) = @_; |
|
80 |
|
|
81 |
my $prefix = $::form->{form_prefix} || 'text_block'; |
|
82 |
my $attributes = $::form->{$prefix} || {}; |
|
83 |
|
|
84 |
foreach (qw(requirement_spec_id output_position)) { |
|
85 |
delete $attributes->{$_} if !defined $attributes->{$_}; |
|
86 |
} |
|
87 |
|
|
88 |
$self->text_block->update_attributes(%{ $attributes }); |
|
89 |
|
|
90 |
my $html = $self->render('requirement_spec_text_block/_text_block', { output => 0 }, text_block => $self->text_block); |
|
91 |
|
|
92 |
SL::ClientJS->new |
|
93 |
->remove('#' . $prefix . '_form') |
|
94 |
->replaceWith('#text-block-' . $self->text_block->id, $html) |
|
95 |
->jstree->rename_node('#tree', '#tb-' . $self->text_block->id, $self->text_block->title) |
|
96 |
->render($self); |
|
97 |
} |
|
98 |
|
|
99 |
|
|
53 | 100 |
sub action_dragged_and_dropped { |
54 | 101 |
my ($self) = @_; |
55 | 102 |
|
Auch abrufbar als: Unified diff
Textblöcke bearbeiten