/
edit_contributors.html
113 lines (107 loc) · 3.28 KB
/
edit_contributors.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<%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 @roles = $c->get_roles;
return $val unless @roles > 1;
my $role = $story->get_contributor_role($c) || 'DEFAULT';
return $val . qq{ (Role: <a href="$uri?story_prof|assoc_contrib_cb=} .
$c->get_id . qq{">$role</a>)};
};
$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 => '',
state_key => 'story_contrib_assoc',
no_pagination => 1,
);
$m->comp('/widgets/wrappers/sharky/table_bottom.mc');
</%perl>
<script language="javascript">
var selectOrderNames = new Array(<% join ', ', @sort_array %>);
</script>
<& /widgets/search/search.mc,
object => 'contrib',
field => 'lname',
type => 'dual',
state_key => 'story_contrib',
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',
state_key => 'story_contrib',
&>
<& '/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>