Module: FcrepoAdmin::Helpers::ObjectsHelperBehavior

Included in:
ObjectsHelper
Defined in:
lib/fcrepo_admin/helpers/objects_helper_behavior.rb

Instance Method Summary collapse

Instance Method Details

#custom_object_nav_item(item) ⇒ Object



115
116
117
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 115

def custom_object_nav_item(item)
  # Override this method with your custom item behavior
end


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 91

def link_to_object(view, condition=true)
  return nil unless condition
  label = t("fcrepo_admin.object.nav.items.#{view}")
  path = case view
         when :summary     
           fcrepo_admin.object_path(@object)
         when :datastreams 
           fcrepo_admin.object_datastreams_path(@object)
         when :permissions 
           fcrepo_admin.permissions_object_path(@object)
         when :associations
           fcrepo_admin.object_associations_path(@object)
         when :audit_trail 
           fcrepo_admin.audit_trail_object_path(@object)
         when :object_xml  
           fcrepo_admin.object_path(@object, :format => 'xml')
         when :solr        
           fcrepo_admin.solr_object_path(@object)
         when :catalog     
           catalog_path(@object)
         end
  link_to_unless_current label, path
end

#object_date(dt) ⇒ Object



29
30
31
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 29

def object_date(dt)
  Time.parse(dt).localtime
end

#object_navObject



50
51
52
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 50

def object_nav
  render :partial => 'fcrepo_admin/shared/context_nav', :locals => {:header => object_nav_header, :items => object_nav_items}
end

#object_nav_headerObject



54
55
56
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 54

def object_nav_header
	  t("fcrepo_admin.object.nav.header")
end

#object_nav_item(item) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 62

def object_nav_item(item)
  case item
  when :pid         
    render_object_pid_label
  when :summary     
    link_to_object item
  when :datastreams 
    link_to_object item
  when :permissions 
    link_to_object item, @object.has_permissions? && can?(:permissions, @object)
  when :associations
    link_to_object item
  when :audit_trail 
    link_to_object item, @object.auditable? && can?(:audit_trail, @object)
  when :object_xml  
    link_to_object item
  when :solr        
    link_to_object item
  when :catalog     
    link_to_object item
  else 
    custom_object_nav_item item
  end
end

#object_nav_itemsObject



58
59
60
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 58

def object_nav_items
  FcrepoAdmin.object_nav_items.collect { |item| object_nav_item(item) }.reject { |item| item.nil? }
end

#object_propertiesObject



12
13
14
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 12

def object_properties
  FcrepoAdmin.object_properties.inject(Hash.new) { |hash, prop| hash[prop] = object_property(prop); hash }
end

#object_property(prop) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 16

def object_property(prop)
  case prop
  when :state
    object_state
  when :create_date, :modified_date
    object_date(@object.send(prop))
  when :models
    @object.models.join("<br/>").html_safe
  else 
    @object.send(prop)
  end
end

#object_show_datastream_columnsObject



46
47
48
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 46

def object_show_datastream_columns
  FcrepoAdmin.object_show_datastream_columns
end

#object_stateObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 33

def object_state
  state = @object.state
  value = case state
          when 'A'
            "A (Active)"
          when 'I'
            "I (Inactive)"
          when 'D'
            "D (Deleted)"
          end
  value
end

#object_titleObject



4
5
6
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 4

def object_title
  "#{object_type} #{@object.pid}"
end

#object_typeObject



8
9
10
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 8

def object_type
  @object.class.to_s
end

#render_object_pid_labelObject



87
88
89
# File 'lib/fcrepo_admin/helpers/objects_helper_behavior.rb', line 87

def render_object_pid_label
   :strong, @object.pid
end