Revision e4a28a8d
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/Controller/RequirementSpecTextBlock.pm | ||
---|---|---|
18 | 18 |
use SL::Helper::Flash; |
19 | 19 |
use SL::Locale::String; |
20 | 20 |
|
21 |
use constant SORTABLE_PICTURE_LIST => 'kivi.requirement_spec.make_text_block_picture_lists_sortable'; |
|
22 |
|
|
21 | 23 |
use Rose::Object::MakeMethods::Generic |
22 | 24 |
( |
23 | 25 |
scalar => [ qw(text_block) ], |
... | ... | |
48 | 50 |
|
49 | 51 |
$self->show_list(output_position => $new_where, id => $::form->{clicked_id}, set_type => 1) if ($new_where != ($current_where // -1)); |
50 | 52 |
|
51 |
$self->render($self->js); |
|
53 |
$self->js |
|
54 |
->run(SORTABLE_PICTURE_LIST()) |
|
55 |
->render($self); |
|
52 | 56 |
} |
53 | 57 |
|
54 | 58 |
sub action_ajax_add { |
... | ... | |
102 | 106 |
$self->invalidate_version |
103 | 107 |
->hide('#text-block-list-empty') |
104 | 108 |
->replaceWith('#' . $::form->{form_prefix} . '_form', $html) |
109 |
->run(SORTABLE_PICTURE_LIST()) |
|
105 | 110 |
->jstree->create_node('#tree', $insert_after ? ('#tb-' . $insert_after, 'after') : ('#tb-' . ($attributes->{output_position} == 0 ? 'front' : 'back'), 'last'), $node) |
106 | 111 |
->jstree->select_node('#tree', '#tb-' . $self->text_block->id); |
107 | 112 |
$self->add_new_text_block_form(output_position => $self->text_block->output_position, insert_after_id => $self->text_block->id, requirement_spec_id => $self->text_block->requirement_spec_id) |
... | ... | |
128 | 133 |
$self->invalidate_version |
129 | 134 |
->remove('#' . $prefix . '_form') |
130 | 135 |
->replaceWith('#text-block-' . $self->text_block->id, $html) |
136 |
->run(SORTABLE_PICTURE_LIST()) |
|
131 | 137 |
->jstree->rename_node('#tree', '#tb-' . $self->text_block->id, $self->text_block->title) |
132 | 138 |
->render($self); |
133 | 139 |
} |
... | ... | |
221 | 227 |
} |
222 | 228 |
} |
223 | 229 |
|
224 |
$self->js->render($self); |
|
230 |
$self->js |
|
231 |
->run(SORTABLE_PICTURE_LIST()) |
|
232 |
->render($self); |
|
225 | 233 |
} |
226 | 234 |
|
227 | 235 |
sub action_ajax_copy { |
... | ... | |
261 | 269 |
|
262 | 270 |
my $node = $self->presenter->requirement_spec_text_block_jstree_data($self->text_block); |
263 | 271 |
$self->invalidate_version |
272 |
->run(SORTABLE_PICTURE_LIST()) |
|
264 | 273 |
->jstree->create_node('#tree', $::form->{id} ? ('#tb-' . $::form->{id}, 'after') : ("#tb-${front_back}", 'last'), $node) |
265 | 274 |
->render($self); |
266 | 275 |
} |
... | ... | |
372 | 381 |
$self->paste_picture($copied); |
373 | 382 |
} |
374 | 383 |
|
384 |
sub action_reorder_pictures { |
|
385 |
my ($self) = @_; |
|
386 |
|
|
387 |
SL::DB::RequirementSpecPicture->reorder_list(@{ $::form->{picture_id} || [] }); |
|
388 |
|
|
389 |
$self->render(\'', { type => 'json' }); |
|
390 |
} |
|
391 |
|
|
375 | 392 |
# |
376 | 393 |
# filters |
377 | 394 |
# |
js/requirement_spec.js | ||
---|---|---|
243 | 243 |
return ns.handle_text_block_picture_popup_menu_markings(opt, false); |
244 | 244 |
}; |
245 | 245 |
|
246 |
ns.make_text_block_picture_lists_sortable = function() { |
|
247 |
kivi.run_once_for(".requirement-spec-text-block-picture-list", 'make-text-block-picture-list-sortable', function($elt) { |
|
248 |
$elt.sortable({ |
|
249 |
stop: function(event, ui) { |
|
250 |
$.post('controller.pl?action=RequirementSpecTextBlock/reorder_pictures', { |
|
251 |
'picture_id[]': $($elt.sortable('toArray')).map(function(idx, str) { return str.replace('text-block-picture-', ''); }).toArray() |
|
252 |
}); |
|
253 |
return ui; |
|
254 |
} |
|
255 |
, distance: 5 |
|
256 |
}); |
|
257 |
}); |
|
258 |
}; |
|
259 |
|
|
246 | 260 |
// -------------------------------------------------------------------------------- |
247 | 261 |
// ------------------------------ sections and items ------------------------------ |
248 | 262 |
// -------------------------------------------------------------------------------- |
templates/webpages/requirement_spec_text_block/_text_block.html | ||
---|---|---|
12 | 12 |
</div> |
13 | 13 |
[% END %] |
14 | 14 |
|
15 |
<div class="clearfix" id="text-block-[% HTML.escape(text_block.id) %]-pictures"[% UNLESS text_block.pictures.as_list.size %] style="display: none"[% END %]>
|
|
15 |
<div class="clearfix requirement-spec-text-block-picture-list" id="text-block-[% HTML.escape(text_block.id) %]-pictures" [% UNLESS text_block.pictures.as_list.size %] style="display: none"[% END %]>
|
|
16 | 16 |
[% FOREACH picture = text_block.pictures_sorted %] |
17 | 17 |
[% INCLUDE 'requirement_spec_text_block/_text_block_picture.html' picture=picture %] |
18 | 18 |
[% END %] |
Auch abrufbar als: Unified diff
Pflichtenhefttextblöcke: Anordnung Bilder via Drag&Drop ändern können