%perl>;
my $order_vals = [ map { [ $_ => $_ ] } 1..@contribs ];
my ($i, @sort_array);
my $order_sub = sub {
return unless $_[1] eq 'order';
my $id = $_[0]->get_id;
push @sort_array, qq{"$widget|reorder_$id"};
$m->scomp('/widgets/profile/select.mc',
name => "$widget|reorder_$id",
disp => '',
value => ++$i,
options => $order_vals,
useTable => 0,
js => qq{onChange="reorder(this, 'theForm')"}
)
};
my $uri = $r->uri;
my $role_sub = sub {
my ($val, $c) = @_;
my $role = $story->get_contributor_role($c);
$val .= qq{ (Role: $role)} if $role;
$val;
};
$m->comp('/widgets/wrappers/sharky/table_top.mc', caption => 'Current Contributors');
$m->comp('/widgets/listManager/listManager.mc',
object => 'contrib',
userSort => 0,
def_sort_field => 'order',
objs => \@contribs,
profile => undef,
alter => { type => $role_sub },
fields => [qw(lname fname type order)],
field_titles => { order => 'Order' },
field_values => $order_sub,
select => ['Delete', "$widget|delete_id"],
addition => ''
);
$m->comp('/widgets/wrappers/sharky/table_bottom.mc');
%perl>
<& /widgets/search/search.mc,
object => 'contrib',
field => 'lname',
type => 'dual',
use_form_tag => 0
&>
<& '/widgets/wrappers/sharky/table_top.mc', caption => 'Choose Contributors' &>
<& /widgets/listManager/listManager.mc,
object => 'contrib',
title => 'Choose Contributors',
select => undef,
profile => $contrib_profile,
exclude => \@existing_contribs,
fields => [qw(lname fname type)],
constrain => { no_grp_id => Bric::Biz::Person->INSTANCE_GROUP_ID },
addition => '',
behavior => 'expand',
&>
<& '/widgets/wrappers/sharky/table_bottom.mc' &>
<& "/widgets/buttons/submit.mc",
disp => 'Save',
widget => $widget,
cb => 'save_contrib_cb',
button => 'save_red',
useTable => 0
&>
<& "/widgets/buttons/submit.mc",
disp => 'Save and Stay',
widget => $widget,
cb => 'save_and_stay_contrib_cb',
button => 'save_and_stay_lgreen',
useTable => 0
&>
<& "/widgets/buttons/submit.mc",
disp => 'Return',
widget => $widget,
cb => 'leave_contrib_cb',
button => 'return_dgreen',
useTable => 0
&>
<%args>
$widget
%args>
<%init>
my $story = get_state_data($widget, 'story');
my @existing_contribs = map { $_->get_id } $story->get_contributors;
my @contribs = $story->get_contributors();
%init>
<%once>
my $contrib_profile = sub {
my ($o,$flags) = @_;
unless ($flags->{'featured'}) {
return ['Associate', $r->uri, "story_prof|assoc_contrib_cb=".$o->get_id];
} else {
return ['Un-Associate', $r->uri, "story_prof|unassoc_contrib_cb=".$o->get_id];
}
};
%once>