reset params used in query

This commit is contained in:
Oliver Gorwits
2013-09-13 08:36:16 +01:00
parent d2b39a3f0e
commit 3377518634

View File

@@ -84,22 +84,32 @@ hook 'before' => sub {
# copy ports form defaults into request query params if this is # copy ports form defaults into request query params if this is
# a redirect from within the application (tab param is not set) # a redirect from within the application (tab param is not set)
if (param('reset') or not param('tab') or param('tab') ne 'ports') {
foreach my $col (@{ var('port_columns') }) { foreach my $col (@{ var('port_columns') }) {
next unless $col->{default} eq 'on'; delete params->{$col->{name}};
params->{$col->{name}} = 'checked' params->{$col->{name}} = 'checked'
if not param('tab') or param('tab') ne 'ports'; if $col->{default} eq 'on';
} }
foreach my $col (@{ var('connected_properties') }) { foreach my $col (@{ var('connected_properties') }) {
next unless $col->{default} eq 'on'; delete params->{$col->{name}};
params->{$col->{name}} = 'checked' params->{$col->{name}} = 'checked'
if not param('tab') or param('tab') ne 'ports'; if $col->{default} eq 'on';
} }
if (not param('tab') or param('tab') ne 'ports') { # not stored in the cookie
params->{'age_num'} ||= 3; params->{'age_num'} ||= 3;
params->{'age_unit'} ||= 'months'; params->{'age_unit'} ||= 'months';
params->{'mac_format'} ||= 'IEEE'; params->{'mac_format'} ||= 'IEEE';
if (param('reset')) {
params->{'age_num'} = 3;
params->{'age_unit'} = 'months';
params->{'mac_format'} = 'IEEE';
# nuke the port params cookie
cookie('nd_ports-form' => '', expires => '-1 day');
}
} }
}; };