- include_stylesheet 'admin/concurrent_draft'
- include_javascript 'admin/concurrent_draft'
- resource = "#{@controller.model.display_name}  #{@controller.model_class.to_s.downcase}"

- unless @controller.model.id == nil  ## resource has not been saved.
  #draft-controls-container
    #draft-controls
      .status
        - if @controller.model.has_draft_promotion_scheduled?
          = t('concurrent_draft.scheduled') + ' ' + @controller.model.draft_promotion_scheduled_at.strftime('%m/%d/%y %I:%M%p')
        - elsif @controller.model.publishable? && ! @controller.model.published?
          %em= t('concurrent_draft.unpublished')
        - else
          %em= t('concurrent_draft.draft_promotion_unscheduled')
      %ul.dropdown{:id => "draft_options"}
        - if @controller.authorized_user?
          %li.schedule_draft= link_to t('concurrent_draft.schedule_promotion'), '#schedule-draft-popup', :class => 'popup'
          %li.publish
            - form_for @controller.model, :url => {:action => 'schedule_draft_promotion', :commit => @controller.model_class.promote_now_text}, :html => {:method => :post} do |f|
              = link_to_function t('concurrent_draft.promote_now'), "$(this).up('form').submit();showStatus('" + t('concurrent_draft.promoting', :resource => resource) + "', true)"
          - if @controller.model.has_draft_promotion_scheduled?
            %li.cancel
              - form_for @controller.model, :url => {:action => 'schedule_draft_promotion', :commit => @controller.model_class.cancel_promotion_text}, :html => {:method => :post} do |f|
                = link_to_function t('concurrent_draft.cancel_promotion'), "$(this).up('form').submit();showStatus('" + t('concurrent_draft.canceling', :resource => resource) + "', true)"
          - if @controller.model.publishable? && @controller.model.published?
            %li.unpublish
              - form_for @controller.model, :url => {:action => 'unpublish', :method => :post} do |f|
                = link_to_function t('concurrent_draft.unpublish'), "$(this).up('form').submit();showStatus('" + t('concurrent_draft.unpublishing', :resource => resource) + "', true)"
          - if @controller.model.has_draft_promoted?
            %li.revert= link_to t('concurrent_draft.revert_draft'), '#revert-draft-popup', :class => 'popup'

- content_for :popups do
  - if @controller.authorized_user?
    .popup#schedule-draft-popup{:style => 'display:none'}
      .popup_title
        = image('clock')
        = t('concurrent_draft.schedule_promotion')
      - form_for @controller.model, :url => {:action => 'schedule_draft_promotion'}, :html => {:method => :post, 'data-onsubmit_status' => t('concurrent_draft.scheduling', :resource => resource)} do |f|
        %div
          = f.datetime_select :draft_promotion_scheduled_at, :start_year => Date.today.year, :minute_step => 15, :twelve_hour => true
          = hidden_field_tag :commit, @controller.model_class.schedule_promotion_text
        %p{:style => 'text-align: right'}
          %button{:type => 'submit'}= t('concurrent_draft.schedule')
          = t('or')
          = link_to_function t('cancel'), "$(this).closePopup();"

  .popup#revert-draft-popup{:style => 'display:none'}
    %p.revert
      = image('page_refresh')
      = t('concurrent_draft.revert_draft_message')
      %br/
      %br/
      %em= t('concurrent_draft.revert_draft_save_message')
      %span{:style => 'padding-left:8px'}= link_to_function 'OK', "$(this).closePopup();"