@@ -91,7 +91,9 @@ def self.format_cols(view, row, controller, options)
9191 "prov_type" => :service_template_format ,
9292 } ,
9393 }
94+ # all tables get a first column for icons.
9495 cols . push ( format_icon_column ( view , row , controller , options [ :clickable ] ) ) if VIEW_WITH_CUSTOM_ICON . include? ( view . db )
96+ # row is a ruport object, so we use listicon_item to look up the original record for the row.
9597 record = controller . listicon_item ( view , row [ 'id' ] )
9698 view . col_order . each_with_index do |col , col_idx |
9799 next if view . column_is_hidden? ( col , controller )
@@ -104,7 +106,12 @@ def self.format_cols(view, row, controller, options)
104106 celltext , span = send ( special_cases [ view . extras [ :filename ] ] [ view . col_order [ col_idx ] ] , row [ col ] )
105107 elsif COLUMN_WITH_IMAGE . key? ( col )
106108 # Generate html for the list icon
107- icon , icon2 , image = send ( COLUMN_WITH_IMAGE [ col ] , record )
109+ # NOTE: COLUMN_WITH_IMAGE basically whitelists these associations
110+ associations = col . split ( '.' ) [ 0 ..-2 ] # drop the last value - the column name
111+ # follow associations so we can pass the approperiate record to be decorated / displayed
112+ col_record = associations . inject ( record ) { |r , association_name | r . send ( association_name ) }
113+ # NOTE: currently this only calls fonticon_or_fileicon
114+ icon , icon2 , image = send ( COLUMN_WITH_IMAGE [ col ] , col_record )
108115 text = format_col_for_display ( view , row , col )
109116 item = { :title => text ,
110117 :image => ActionController ::Base . helpers . image_path ( image . to_s ) ,
@@ -162,6 +169,8 @@ def self.textual_power_state_whitelisted(state)
162169 quad_icon [ :background ]
163170 end
164171
172+ # NOTE: this is for the icon column
173+ # so unlike the others, there is no text here
165174 def self . format_icon_column ( view , row , controller , clickable )
166175 item = controller . listicon_item ( view , row [ 'id' ] )
167176 icon , icon2 , image = fonticon_or_fileicon ( item )
0 commit comments