Revision 7fb610a5
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/Controller/CustomVariableConfig.pm | ||
---|---|---|
1 |
package SL::Controller::CustomVariableConfig; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use parent qw(SL::Controller::Base); |
|
6 |
|
|
7 |
use SL::DB::CustomVariableConfig; |
|
8 |
|
|
9 |
__PACKAGE__->run_before('check_auth'); |
|
10 |
|
|
11 |
# |
|
12 |
# actions |
|
13 |
# |
|
14 |
|
|
15 |
sub action_reorder { |
|
16 |
my ($self) = @_; |
|
17 |
|
|
18 |
my @ids = @{ $::form->{cvarcfg_id} || [] }; |
|
19 |
my $result = SL::DB::CustomVariableConfig->new->db->do_transaction(sub { |
|
20 |
foreach my $idx (0 .. scalar(@ids) - 1) { |
|
21 |
SL::DB::CustomVariableConfig->new(id => $ids[$idx])->load->update_attributes(sortkey => $idx + 1); |
|
22 |
} |
|
23 |
}); |
|
24 |
|
|
25 |
$self->render(type => 'js', inline => '1;'); |
|
26 |
} |
|
27 |
|
|
28 |
# |
|
29 |
# filters |
|
30 |
# |
|
31 |
|
|
32 |
sub check_auth { |
|
33 |
$::auth->assert('config'); |
|
34 |
} |
|
35 |
|
|
36 |
1; |
bin/mozilla/amcvar.pl | ||
---|---|---|
90 | 90 |
|
91 | 91 |
my @configs = @{ CVar->get_configs(module => $form->{module}) }; |
92 | 92 |
|
93 |
my $previous_config; |
|
94 |
|
|
95 | 93 |
foreach my $config (@configs) { |
96 | 94 |
$config->{type_tr} = $translations{$config->{type}}; |
97 |
|
|
98 |
if ($previous_config) { |
|
99 |
$previous_config->{next_id} = $config->{id}; |
|
100 |
$config->{previous_id} = $previous_config->{id}; |
|
101 |
} |
|
102 |
|
|
103 |
$previous_config = $config; |
|
104 | 95 |
} |
105 | 96 |
|
106 | 97 |
$form->{title} = $locale->text('List of custom variables'); |
... | ... | |
219 | 210 |
$main::lxdebug->leave_sub(); |
220 | 211 |
} |
221 | 212 |
|
222 |
sub swap_cvar_configs { |
|
223 |
$main::lxdebug->enter_sub(); |
|
224 |
|
|
225 |
my $form = $main::form; |
|
226 |
my %myconfig = %main::myconfig; |
|
227 |
|
|
228 |
AM->swap_sortkeys(\%myconfig, $form, 'custom_variable_configs'); |
|
229 |
|
|
230 |
list_cvar_configs(); |
|
231 |
|
|
232 |
$main::lxdebug->leave_sub(); |
|
233 |
} |
|
234 |
|
|
235 | 213 |
sub dispatcher { |
236 | 214 |
my $form = $main::form; |
237 | 215 |
my $locale = $main::locale; |
templates/webpages/amcvar/list_cvar_configs.html | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
[% USE HTML %]<body> |
|
1 |
[%- USE T8 %][% USE LxERP %][% USE L %] |
|
2 |
[% USE HTML %] |
|
3 |
|
|
4 |
<script type="text/javascript" src="js/jquery-ui.js"></script> |
|
5 |
|
|
6 |
<body> |
|
3 | 7 |
|
4 | 8 |
[% IF MESSAGE %]<p>[% MESSAGE %]</p>[% END %] |
5 | 9 |
|
... | ... | |
20 | 24 |
</p> |
21 | 25 |
|
22 | 26 |
<p> |
23 |
<table width="100%"> |
|
24 |
<tr> |
|
25 |
<td class="listheading" width="0%"></td> |
|
26 |
<td class="listheading" width="0%"></td> |
|
27 |
<td class="listheading" width="20%">[% 'Name' | $T8 %]</td> |
|
28 |
<td class="listheading" width="20%">[% 'Description' | $T8 %]</td> |
|
29 |
<td class="listheading" width="20%">[% 'Type' | $T8 %]</td> |
|
30 |
<td class="listheading" width="20%">[% 'Searchable' | $T8 %]</td> |
|
31 |
<td class="listheading" width="20%">[% 'Includeable in reports' | $T8 %]</td> |
|
27 |
<table width="100%" id="cvarcfg_list"> |
|
28 |
<tr class="listheading"> |
|
29 |
<th align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></th> |
|
30 |
<th width="20%">[% 'Name' | $T8 %]</th> |
|
31 |
<th width="20%">[% 'Description' | $T8 %]</th> |
|
32 |
<th width="20%">[% 'Type' | $T8 %]</th> |
|
33 |
<th width="20%">[% 'Searchable' | $T8 %]</th> |
|
34 |
<th width="20%">[% 'Includeable in reports' | $T8 %]</th> |
|
32 | 35 |
[%- IF module == 'IC' %] |
33 |
<td class="listheading" width="20%">[% 'Editable' | $T8 %]</td>
|
|
36 |
<th width="20%">[% 'Editable' | $T8 %]</th>
|
|
34 | 37 |
[%- END %] |
35 | 38 |
</tr> |
36 | 39 |
|
37 | 40 |
[%- FOREACH cfg = CONFIGS %] |
38 |
<tr class="listrow[% loop.count % 2 %]"> |
|
39 |
<td> |
|
40 |
[%- IF cfg.previous_id %] |
|
41 |
<a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.previous_id) %]&id2=[% HTML.url(cfg.id) %]"> |
|
42 |
<img border="0" src="image/up.png"></a> |
|
43 |
[%- END %] |
|
44 |
</td> |
|
45 |
|
|
46 |
<td> |
|
47 |
[%- IF cfg.next_id %] |
|
48 |
<a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.next_id) %]&id2=[% HTML.url(cfg.id) %]"> |
|
49 |
<img border="0" src="image/down.png"></a> |
|
50 |
[%- END %] |
|
51 |
</td> |
|
41 |
<tr class="listrow[% loop.count % 2 %]" id="cvarcfg_id_[% cfg.id %]"> |
|
42 |
<td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td> |
|
52 | 43 |
|
53 | 44 |
<td> |
54 | 45 |
<a href="amcvar.pl?action=edit_cvar_config&module=[% HTML.url(module) %]&id=[% HTML.url(cfg.id) %]&callback=[% HTML.url(callback) %]"> |
... | ... | |
98 | 89 |
</p> |
99 | 90 |
</form> |
100 | 91 |
|
92 |
[% L.sortable_element('#cvarcfg_list tbody', 'url' => 'controller.pl?action=CustomVariableConfig/reorder', 'with' => 'cvarcfg_id') %] |
|
93 |
|
|
101 | 94 |
</body> |
102 | 95 |
</html> |
Auch abrufbar als: Unified diff
Sortieren von benutzerdefinierten Variablen auf Drag-n-Drop & AJAX mittels jQuery UI Sortable umgestellt