Revision 91dc1ae9
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/Controller/RequirementSpecItem.pm | ||
---|---|---|
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
sub action_dragged_and_dropped { |
56 |
my ($self) = @_; |
|
56 |
my ($self) = @_;
|
|
57 | 57 |
|
58 |
my $position = $::form->{position} =~ m/^ (?: before | after | last ) $/x ? $::form->{position} : die "Unknown 'position' parameter"; |
|
59 |
my $dropped_item = $::form->{dropped_id} ? SL::DB::RequirementSpecItem->new(id => $::form->{dropped_id})->load : undef; |
|
58 |
my $position = $::form->{position} =~ m/^ (?: before | after | last ) $/x ? $::form->{position} : die "Unknown 'position' parameter";
|
|
59 |
my $dropped_item = $::form->{dropped_id} ? SL::DB::RequirementSpecItem->new(id => $::form->{dropped_id})->load : undef;
|
|
60 | 60 |
|
61 |
my $visible_section_id = $self->visible_section ? $self->visible_section->id : undef;
|
|
62 |
my $old_parent_id = $self->item->parent_id; |
|
63 |
my $old_type = $self->item->get_type; |
|
61 |
my $old_visible_section = $self->visible_section ? $self->visible_section : undef;
|
|
62 |
my $old_parent_id = $self->item->parent_id;
|
|
63 |
my $old_type = $self->item->get_type;
|
|
64 | 64 |
|
65 | 65 |
$self->item->db->do_transaction(sub { |
66 | 66 |
$self->item->remove_from_list; |
... | ... | |
71 | 71 |
my $js = SL::ClientJS->new; |
72 | 72 |
|
73 | 73 |
$self->item(SL::DB::RequirementSpecItem->new(id => $self->item->id)->load); |
74 |
my $new_section = $self->item->get_section; |
|
75 |
my $new_type = $self->item->get_type; |
|
74 |
my $new_section = $self->item->get_section; |
|
75 |
my $new_type = $self->item->get_type; |
|
76 |
my $new_visible_section = SL::DB::RequirementSpecItem->new(id => $self->visible_item->id)->load->get_section; |
|
77 |
|
|
78 |
return $self->render($js) if !$old_visible_section || ($new_type eq 'section'); |
|
76 | 79 |
|
77 |
return $self->render($js) if !$visible_section_id || ($new_type eq 'section');
|
|
80 |
# From here on $old_visible_section is definitely set.
|
|
78 | 81 |
|
79 | 82 |
my $old_parent = SL::DB::RequirementSpecItem->new(id => $old_parent_id)->load; |
80 | 83 |
my $old_section = $old_parent->get_section; |
81 | 84 |
|
82 |
# $::lxdebug->message(0, "old sec ID " . $old_section->id . " new " . $new_section->id . " visible $visible_section_id PARENT: old " . $old_parent->id . " new " . $self->item->parent_id . '/' . $self->item->parent->id); |
|
85 |
# $::lxdebug->message(0, "old sec ID " . $old_section->id . " new " . $new_section->id . " old visible " . $old_visible_section->id . " new visible " . $new_visible_section->id |
|
86 |
# . " PARENT: old " . $old_parent->id . " new " . $self->item->parent_id . '/' . $self->item->parent->id); |
|
87 |
|
|
88 |
if ($old_visible_section->id != $new_visible_section->id) { |
|
89 |
# The currently visible item has been dragged to a different section. |
|
90 |
return $self->render_list($js, $new_section, $self->item) |
|
91 |
->render($self); |
|
92 |
} |
|
83 | 93 |
|
84 |
if ($visible_section_id == $old_section->id) {
|
|
94 |
if ($old_visible_section->id == $old_section->id) {
|
|
85 | 95 |
my $id_prefix = $old_type eq 'sub-function-block' ? 'sub-' : ''; |
86 | 96 |
$js->remove('#' . $id_prefix . 'function-block-' . $self->item->id); |
87 | 97 |
|
... | ... | |
94 | 104 |
} |
95 | 105 |
} |
96 | 106 |
|
97 |
if ($visible_section_id == $new_section->id) {
|
|
107 |
if ($old_visible_section->id == $new_section->id) {
|
|
98 | 108 |
$js->hide('#section-list-empty'); |
99 | 109 |
|
100 | 110 |
my $id_prefix = $new_type eq 'sub-function-block' ? 'sub-' : ''; |
Auch abrufbar als: Unified diff
Pflichtenheftitems: Drag&Drop vom aktuell Ausgewählten fixen