" class="item">
class="version<% ($highlight eq 'id' ? ' sorted' : '') %>"><% $id%> v.<% $obj->get_version %>
<% $uri || $name %>
% if ($user) { <% $user %> % } else { <% $desk->get_name %> Desk % }
<& publish_status_span.mc, sorted => $highlight eq 'name' ? ' sorted' : '', asset => $obj &>
% if ($class ne 'template') {
<% $lang->maketext('Primary URI') %>:
<% $obj->get_primary_uri || ' ' %>
% }
<% $lang->maketext($date_label) %>:
<% $date || ' ' %>
% if ($class eq 'template') {
<% $lang->maketext('Output Channel') %>:
<% $obj->get_output_channel_name || ' ' %>
% } else {
<% $lang->maketext($type_label) %>:
<% $type || ' ' %>
% } % if (@$sites > 1) {
<% $lang->maketext('Site') %>:
<% $site %>
% }
<% $lang->maketext('Priority') %>:
<% $lang->maketext($priors->{$obj->get_priority}) %>
<%once>; my $priors = Bric::Biz::Asset->list_priorities; <%args> $widget => 'desk_asset' $obj $highlight $desk_type $work_id => undef <%init>; my ($id, $class); unless (ref $obj) { ($class, $id) = split /_/, $obj; $obj = get_package_name($class)->lookup({ id => $id }); } else { $class = $obj->key_name; $id = $obj->get_id; } # Grab the type name. my $atid = $obj->get_element_type_id; my $type = defined $atid ? $obj->get_element_name : ''; # Grab the User ID. my $user_id = $obj->get_user__id; my $checked_out_by_current_user = defined $user_id && get_user_id() == $user_id; # Figure out the Checkout status. my ($user); my $desk = $obj->get_current_desk; my $desk_id = $desk->get_id; my $workflow = $obj->get_workflow_object; my $can_publish = $desk->can_publish && chk_authz($obj, PUBLISH, 1); my $can_edit = $can_publish || chk_authz($obj, EDIT, 1); my $action = 'checkout_cb'; my $checkin_opts = []; my $move_opts = []; if ($checked_out_by_current_user) { $action = 'checkin_cb'; } elsif (defined $user_id) { $checkin_opts = undef; $user = $obj->get_user->format_name; } # Assemble the list of desks we can move this to. my $to = $lang->maketext('to') . ' '; if ($checkin_opts || $move_opts) { my %seen; my $workflow_id = $workflow->get_id; foreach my $d ($workflow->allowed_desks) { next unless chk_authz(undef, READ, 1, $d->get_asset_grp); my $did = $d->get_id; my $key = join('-', $did, $workflow_id); my $value = $to . $d->get_name; push @$checkin_opts, [$key, $value]; push @$move_opts, [$key, $value] unless $did == $desk_id; $seen{$did} = 1; } if (ALLOW_WORKFLOW_TRANSFER) { # Find all the other workflows this desk is in. foreach my $wf (Bric::Biz::Workflow->list({ desk_id => $desk_id })) { my $wid = $wf->get_id; next if $wid == $workflow_id; # Add all of their desks to the list. foreach ($wf->allowed_desks) { my $did = $_->get_id; next if $seen{$did}; my $key = join('-', $did, $wid); my $value = $to . $_->get_name; push @$checkin_opts, [$key, $value]; push @$move_opts, [$key, $value] unless $did == $desk_id; $seen{$did} = 1; } } } if ($checked_out_by_current_user && chk_authz($obj, PUBLISH, 1)) { if ($class eq 'template') { my @and_deploy = ['deploy', $lang->maketext('and Deploy')]; push @$checkin_opts, @and_deploy; } else { my @and_publish = ['publish', $lang->maketext('and Publish')]; push @$checkin_opts, @and_publish; } } push @$checkin_opts, ( ['shelve', $lang->maketext('and Shelve')], ['revert', $lang->maketext('and ' . ($obj->get_version == 0 ? 'Delete' : 'Revert'))], ); } my ($name, $date, $date_label, $type_label, $uri, $uuid); my $alias = ''; my $site = $obj->get_site->get_name; my $sites = $c->get('__SITES__') || Bric::Biz::Site->list({ active => 1 }); my $vlabel = $can_edit && $checked_out_by_current_user ? 'Edit' : 'View'; if ($class eq 'template') { $date = $obj->get_deploy_date; $date_label = 'Deployed Date'; $name = $obj->get_uri; } else { $name = $obj->get_name; $date = $obj->get_cover_date; $date_label = 'Cover Date'; $type_label = get_disp_name($class) . " Type"; $uuid = $obj->get_uuid; $alias = ' alias' if $obj->get_alias_id; $uri = $m->comp( '/widgets/profile/preview_link.mc', type => $class, doc => $obj, value => $name, ) unless $class eq 'media' && !$obj->get_file_name; } my @query_string; push @query_string, 'return=' . $desk->get_id if $desk_type eq 'workflow'; push @query_string, 'checkout=1' if $vlabel eq 'Edit'; my $ppage = "/workflow/profile/$class"; my $link = $ppage . '/' . $id; $link .= '?' . join("&", @query_string) if scalar @query_string; # Create alternating row colors my $count = 1; my $rowtype = sub { # Print "odd" for 1st and 2nd cell (odd rows), "even" for 3rd and 4th $m->out(($count++ <= 2) ? 'odd' : 'even'); $count = 1 if ($count > 4); return; }; my $drop_js = sub { my ($class, $id) = @_; # JS to drop out the asset being removed from a desk, and also to drop out # the asset header with sort select list if there are no other items below # it. return "function (r) { var e = \$('${class}_${id}'); Effect.DropOut(e); if (!Selector.findChildElements(e.up(), ['.item']).find(function (s) { return s.id != '${class}_${id}' && s.visible() })) { Effect.DropOut(e.up().previous('.desk-top')); } }" }; my $checkin_js = sub { my $next_desk = shift; if ($desk_type eq 'workspace' || $next_desk !~ m/^$desk_id/) { # The workspace only shows assets that are checked out, so the # asset needs to disappear when it's checked in. # # Similarly, workflow desks only show assets assigned to them. # If the next desk isn't the same as the current desk, it needs # to disappear. my $uri = $r->uri; my $parameters = join('&', "desk_asset|checkin_cb=${class}_${id}", ($next_desk ? ("desk_asset|next_desk=$next_desk") : ())); return "Desk.request({ parameters: '$parameters' }, " . $drop_js->($class, $id) . " ); return false"; } else { my $parameters = join('&', "desk_type=workflow", "obj=${class}_${id}", "highlight=$highlight", "desk_asset|checkin_cb=${class}_${id}", "desk_asset|next_desk=$next_desk"); return "Desk.update('${class}_${id}', { parameters: '$parameters' }); return false"; } }; my $move_js = sub { my $next_desk = shift; if ($desk_type eq 'workflow') { # Workflows only show assets from one desk, so the asset needs to # disappear when it's moved to a different desk. my $uri = $r->uri; my $parameters = join('&', "desk_asset|move_cb=$class\_$id", "desk_asset|next_desk=$next_desk"); return "Desk.request({ parameters: '$parameters' }, " . $drop_js->($class, $id) . '); return false'; } else { # The workspace shows assets from many desks, so the asset needs # to be updated. my $parameters = join('&', "desk_type=$desk_type", "obj=${class}_${id}", "highlight=$highlight", "desk_asset|move_cb=${class}_${id}", "desk_asset|next_desk=$next_desk"); if ($next_desk eq 'shelve') { return "Desk.request({ parameters: '$parameters' }, " . $drop_js->($class, $id) . '); return false'; } else { return "Desk.update('${class}_${id}', { parameters: '$parameters' }); return false"; } } }; my $publish_js = sub { my $version_id = $obj->get_version_id; my $uri = $r->uri; if ($class eq 'template') { my $parameters = join('&', "desk_asset|deploy_cb=1", "desk_asset|template_pub_ids=${version_id}"); return "Desk.request({ parameters: '$parameters' }, " . $drop_js->('template', $id) . '); return false'; } else { my $parameters = join('&', "desk_asset|publish_cb=1", "${class}_pub=${class}_${version_id}"); return "Desk.request({ parameters: '$parameters' }, " . $drop_js->($class, $id) . '); return false'; } }; <%doc> ############################################################################### =head1 Name /widgets/desk/desk_item.html - Desk Item Presentation. =head1 Description This element handles the display of individual assets on a desk or workspace.