%#-- Begin HTML --# <& '/widgets/wrappers/sharky/header.mc', title => "$disp Profile", context => "Admin | Profile | $disp | $crumb" &>
<%perl>; $m->comp('/widgets/profile/hidden.mc', value => $id, name => 'action_id') if defined $id; $m->comp('/widgets/profile/hidden.mc', name => 'dest_id', value => $dest_id); # Output the key properties. $m->comp("/widgets/wrappers/sharky/table_top.mc", caption => "Properties"); my $used = { active => 1, ord => 1 }; my $label = 'next_dkgreen'; if (defined $id || $act->get_type) { # This is an existing action. Disallow ability to change the type. $m->comp('/widgets/profile/displayFormElement.mc', objref => $act, key => 'type', readOnly => 1); $used->{type} = 1; $label = 'save_red'; unless (defined $id) { # They've selected a type, but haven't yet set attributes. # Make sure that the callback knows to save the action. $m->comp('/widgets/profile/hidden.mc', name => 'type', value => $act->get_type); $m->comp('/widgets/profile/hidden.mc', name => 'save_it', value => 1); } } # Okay now, output the normal form fields. $m->comp('/widgets/profile/dumpRemainingFields.mc', objref => $act, fieldsUsed => $used, readOnly => $no_edit ); # Output the Order from field. # HACK. There should probably be a more elegant way for my_meths to determine # the upper limits of the select list, but currently there isn't one. So I create # one here by loading what my_meths() returns, and then setting the value and the # vals list manually. my $ord_vals = { %{ $act->my_meths->{ord} } }; $ord_vals->{props}{vals} = [1..($id ? $next_ord - 1 : $next_ord)]; $ord_vals->{value} = $act->get_ord; $m->comp('/widgets/profile/displayFormElement.mc', vals => $ord_vals, readOnly => $no_edit, key => 'ord'); # Close 'er up! $m->comp("/widgets/wrappers/sharky/table_bottom.mc"); $m->comp('/widgets/profile/formButtons.mc', type => $type, no_del => $no_del, section => $section, return => "/admin/profile/dest?id=$dest_id", val => $label, no_save => $no_edit, widget => 'action');
<& '/widgets/wrappers/sharky/footer.mc', param => \%ARGS &> %#-- End HTML --# %#-- Once Section --# <%once>; my $widget = 'profile'; my $section = 'admin'; my $type = 'action'; my $class = get_package_name($type); my $disp = get_disp_name($type); my $dest_key = 'dest'; my $dest_class = get_package_name($dest_key); %#-- Args Section --# <%args> $id => undef $next => undef $type => undef $dest_id => undef %#-- Init Section --# <%init>; # Do any redirects first. do_queued_redirect(); $id ||= $ARGS{action_id}; # Instantiate an object. my $act = $ARGS{obj} ? $ARGS{obj} : defined $id ? $class->lookup({ id => $id}) : $class->new; $id ||= $act->get_id; # Get the server type (destination profile) ID and instantiate the destination # object. $dest_id ||= get_state_data($widget, $dest_key) || $act->get_server_type_id; my $dest = $dest_class->lookup({ id => $dest_id }); # Check authorization. chk_authz($dest, EDIT); my $no_edit = !chk_authz($dest, EDIT, 1); my $no_del = !$id || $no_edit; # Set the ord to the next ord by default, if this is a new action. my $next_ord = Bric::Dist::Action->next_ord($dest_id); $act->set_ord($next_ord) unless defined $id; # Set the type, if it has already been selected. $act->set_type($type) if $next; # Get the name for the breadcrumb trail. my $crumb = $act->get_name; $crumb = $crumb ? ""$crumb"" : 'New'; <%doc> ################################################################################ =head1 NAME /admin/profile/action/dhandler - Interface for managing actions. =head1 VERSION $LastChangedRevision$ =head1 DATE $LastChangedDate$ =head1 DESCRIPTION This element handles the display for editing distribution actions.