module FcrepoAdmin::Helpers::DatastreamsHelperBehavior

Public Instance Methods

custom_datastream_nav_item(item) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 83
def custom_datastream_nav_item(item)
  # Override this method with your custom item behavior
end
datastream_alert(alert) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 110
def datastream_alert(alert)
  case alert
  when :system_managed
    if ["DC", "RELS-EXT", "rightsMetadata", "defaultRights"].include?(@datastream.dsid)
      render_datastream_alert(alert, :caution => true)
    end
  when :not_versionable        
    render_datastream_alert(alert, :caution => true) unless @datastream.versionable
  when :inactive
    render_datastream_alert(alert) if @datastream.inactive?
  when :deleted
    render_datastream_alert(alert, :css_class => "alert alert-error") if @datastream.deleted?
  end
end
datastream_alerts(*alerts) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 101
def datastream_alerts(*alerts)
  rendered = ""
  alerts.each do |alert|
    content = datastream_alert(alert)
    rendered << content unless content.nil?
  end
  rendered.html_safe
end
datastream_history_columns() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 28
def datastream_history_columns
  FcrepoAdmin.datastream_history_columns
end
datastream_index_columns() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 24
def datastream_index_columns
  FcrepoAdmin.datastream_index_columns
end
datastream_nav() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 12
def datastream_nav
  render :partial => 'fcrepo_admin/shared/context_nav', :locals => {:header => datastream_nav_header, :items => datastream_nav_items}      
end
datastream_nav_header() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 16
def datastream_nav_header
  t("fcrepo_admin.datastream.nav.header")
end
datastream_nav_item(item) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 36
def datastream_nav_item(item)
  case item
  when :dsid
    render_datastream_dsid_label
  when :version
    render_datastream_version unless @datastream.current_version?
  when :current_version 
    link_to_datastream item, !@datastream.current_version?, false
  when :summary 
    link_to_datastream item
  when :content
    link_to_datastream item, @datastream.content_is_text?
  when :download
    link_to_datastream item, @datastream.content_is_downloadable?, false
  when :edit
    link_to_datastream item, @datastream.content_is_editable? && can?(:edit, @object)
  when :upload
    link_to_datastream item, @datastream.content_is_uploadable? && can?(:upload, @object)
  when :history
    link_to_datastream item, !@datastream.new?
  else 
    custom_datastream_nav_item item
  end
end
datastream_nav_items() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 20
def datastream_nav_items
  FcrepoAdmin.datastream_nav_items.collect { |item| datastream_nav_item(item) }.reject { |item| item.nil? }
end
datastream_params() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 32
def datastream_params
  params.has_key?(:asOfDateTime) ? {:asOfDateTime => params[:asOfDateTime]} : {}
end
datastream_show_profile_keys() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 8
def datastream_show_profile_keys
  FcrepoAdmin.datastream_show_profile_keys
end
datastream_title() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 4
def datastream_title
  "#{t('fcrepo_admin.datastream.title')}: #{@datastream.dsid}"
end
ds_css_class(ds) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 195
def ds_css_class(ds)
  [ds_list_css_class(ds), ds.dsid].join("-")
end
ds_list_css_class(object_or_ds) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 191
def ds_list_css_class(object_or_ds)
  [object_or_ds.safe_pid, "datastreams"].join("-")
end
ds_profile_css_class(ds, attr) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 199
def ds_profile_css_class(ds, attr)
  [ds_css_class(ds), attr].join("-")
end
format_datastream_control_group(ds) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 142
def format_datastream_control_group(ds)
  control_group = ds.controlGroup
  formatted = case control_group
              when 'M'
                "M (Managed)"
              when 'X'
                "X (Inline XML)"
              when 'E'
                "E (External Referenced)"
              when 'R'
                "R (Redirect)"
              end
  formatted
end
format_datastream_label(ds) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 163
def format_datastream_label(ds)
  if ds.dsLabel.blank?
    content_tag(:em, I18n.t('fcrepo_admin.datastream.profile.no_label'))
  else
    ds.dsLabel
  end
end
format_datastream_profile_value(ds, key) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 171
def format_datastream_profile_value(ds, key)
  case key
  when "dsSize"
    number_to_human_size(ds.dsSize)
  when "dsCreateDate"
    ds.dsCreateDate.localtime
  when "dsLabel"
    format_datastream_label(ds)
  when "dsLocation" && ds.content_is_url?
    link_to(ds.dsLocation, ds.dsLocation)
  when "dsState"
    format_datastream_state(ds)
  when "dsControlGroup"
    format_datastream_control_group(ds)
  when "dsVersionID"
    format_datastream_version_id(ds)
  else ds.profile[key]
  end
end
format_datastream_state(ds) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 129
def format_datastream_state(ds)
  state = ds.dsState
  formatted = case state
              when 'A'
                "A (Active)"
              when 'I'
                "I (Inactive)"
              when 'D'
                "D (Deleted)"
              end
  formatted
end
format_datastream_version_id(ds) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 157
def format_datastream_version_id(ds)
  version_id = ds.dsVersionID
  version_id += " (#{t('fcrepo_admin.datastream.current_version')})" if ds.current_version?
  version_id
end
render_datastream_alert(alert, opts={}) click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 125
def render_datastream_alert(alert, opts={})
  render :partial => 'alert', :locals => {:alert => alert, :caution => opts.fetch(:caution, false), :css_class => opts.fetch(:css_class, "alert")}
end
render_datastream_dsid_label() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 97
def render_datastream_dsid_label
  content_tag :strong, @datastream.dsid
end
render_datastream_version() click to toggle source
# File lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb, line 93
def render_datastream_version
  render :partial => 'version', :locals => {:datastream => @datastream}
end