<div class="item">
  <div class="head">
    <div <% $uuid ? qq{title="$uuid" } : '' %>class="version<% ($highlight eq 'id' ? ' sorted' : '') %>"><% $id%> v.<% $obj->get_version %></div>
    <div class="title<% ($highlight eq 'name' ? ' sorted' : $alias ? $alias : '') %>"><% $uri || $name %></div>
    <% $m->comp('publish_status_span.mc',
                sorted => $highlight eq 'name' ? ' sorted' : '',
                asset => $obj) %>
  </div>
  <div class="body<% (@$sites <= 1 && $class eq 'template') ? ' short' : ' tall' %>">
    <dl>
% if ($class ne 'template') {
      <dt name="uri" class="<% &$rowtype %><% ($highlight eq 'uri' ? ' sorted' : '') %>"><% $lang->maketext('Primary URI') %>:</dt>
      <dd name="uri" class="<% &$rowtype %><% ($highlight eq 'uri' ? ' sorted' : '') %>"><% $obj->get_primary_uri || '&nbsp;' %></dd>
% }
      <dt name="date" class="<% &$rowtype %><% ($highlight =~ m/date/ ? ' sorted' : '') %>"><% $lang->maketext($date_label) %>:</dt>
      <dd name="date" class="<% &$rowtype %><% ($highlight =~ m/date/ ? ' sorted' : '') %>"><% $date || '&nbsp;' %></dd>
% if ($class eq 'template') {
      <dt name="oc" class="<% &$rowtype %><% ($highlight eq 'output_channel' ? ' sorted' : '') %>"><% $lang->maketext('Output Channel') %>:</dt>
      <dd name="oc" class="<% &$rowtype %><% ($highlight eq 'output_channel' ? ' sorted' : '') %>"><% $oc || '&nbsp;' %></dd>
% } else {
      <dt name="type" class="<% &$rowtype %><% ($highlight eq 'element_type' ? ' sorted' : '') %>"><% $lang->maketext($type_label) %>:</dt>
      <dd name="type" class="<% &$rowtype %><% ($highlight eq 'element_type' ? ' sorted' : '') %>"><% $type || '&nbsp;' %></dd>
% }
% if (@$sites > 1) {
      <dt name="site" class="<% &$rowtype %><% ($highlight eq 'site_id' ? ' sorted' : '') %>"><% $lang->maketext('Site') %>:</dt>
      <dd name="site" class="<% &$rowtype %><% ($highlight eq 'site_id' ? ' sorted' : '') %>"><% $site %></dd>
% }
      <dt name="priority" class="<% &$rowtype %><% ($highlight eq 'priority' ? ' sorted' : '') %>"><% $lang->maketext('Priority') %>:</dt>
      <dd name="priority" class="<% &$rowtype %><% ($highlight eq 'priority' ? ' sorted' : '') %>"><% $lang->maketext($priors->{$obj->get_priority}) %></dd>
    </dl>
    
    <div class="actions">
        <p><% $elink %></p>
        
        <div class="mover">
% if ($can_edit && $desk_opts) {
          <label for="move<% $id %>"><% $lang->maketext($mover_label) %></label>
          <& '/widgets/profile/select.mc',
             name     => "$widget|next_desk",
             value    => $desk_val,
             options  => $desk_opts,
             useTable => 0,
             id       => "move$id" &>
% } else {
        &nbsp;
% }
        </div>
        
        <ul class="action">
          <li><a href="<% $link %>" title="<% $vlabel . " &#x201c;$name&#x201d;" %>"><% $vlabel %></a></li>
          <li><a href="<% $ppage . '/' . lc $vlabel %>_notes.html?id=<% $aid %>">Notes</a></li>
          <li><a href="<% $item_url %>"><% $lang->maketext($item_label) %></a></li>
          <li><a href="/workflow/events/<% $class %>/<% $aid %>"><% $lang->maketext('Log') %></a></li>
          <li><% $pub %></li>
        </ul>
    </div>
  </div>
</div>
<%once>;
my $priors = Bric::Biz::Asset->list_priorities;
</%once>
<%args>
$widget => 'desk_asset'
$obj
$highlight
$can_edit
$vlabel => 'View'
$desk_val
$desk_opts
$ppage
$disp
$oc     => ''
$type   => ''
$pub    => ''
$aid
$class  => 'story'
$did
$desk_type
$user => undef
$label => undef
$action => undef
</%args>
<%init>;
# Get the ID.
my $id = $obj->get_id;
my $user_id = $obj->get_user__id;

my ($name, $date, $date_label, $type_label, $uri, $uuid);
my $header_class = 'lightHeader';
my $alias = '';
my $site = Bric::Biz::Site->lookup({id => $obj->get_site_id})->get_name;
my $sites = $c->get('__SITES__') || Bric::Biz::Site->list({ active => 1 });
my $idv_class = 'idv';

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 = "$disp Type";
    my $co      = $vlabel eq 'Edit';
    $uuid       = $obj->get_uuid;
    $alias      = ' alias' if $obj->get_alias_id;

    if ($class eq 'media') {
        $uri = $m->comp(
            '/widgets/profile/preview_link.mc',
            type  => $class,
            doc   => $obj,
            value => $name,
        ) if $obj->get_file_name;
    } else {
        $uri = $m->comp(
            '/widgets/profile/preview_link.mc',
            type  => $class,
            doc   => $obj,
            value => $name,
        );
    }
}

my $classes = { $highlight => ' class="sorted"' };
my $rowspan = 5;

my $checked_out = defined $user_id && get_user_id() == $user_id;

my $mover_label = $desk_type ne 'workflow' ? 'Check in' : 'Move';

my $callback_widget = ($class eq 'template' ? 'tmpl' : $class) . '_prof';

my $link = $ppage . '/' . $aid;
my $item_label = 'Trail';
my $item_url = "/workflow/trail/$class/$aid";
if ($desk_type eq 'workflow') {
    $link .= '?return=' . $did;
    if ($vlabel eq 'Edit') {
        $link .= '&amp;checkout=1';
    }
} else {
    if ($vlabel eq 'Edit') {
        $link .= '?checkout=1';
    }
    if ($class eq 'story') {
        $item_label = 'Clone';
#        $item_url = $r->uri . "?$widget|clone_cb=$aid";
        $item_url = "/workflow/profile/workspace/clone/$aid";
    }
}

my $elink = $user ? $user : $label ? '<a href="' . $r->uri . "?"
  . join('&amp;', "$widget|$action=$aid", "$widget|asset_class=$class")
  . qq{">$label</a>} : '';

# 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;
};

</%init>
<%doc>
###############################################################################

=head1 NAME

/widgets/desk/desk_item.html - Desk Item Presentation.

=head1 VERSION

$LastChangedRevision$

=head1 DATE

$LastChangedDate: 2006-06-14 23:55:03 +0200 (Wed, 14 Jun 2006) $

=head1 DESCRIPTION

This element handles the display of individual assets on a desk or workspace.

</%doc>
