Changeset 856

Show
Ignore:
Timestamp:
03/21/08 18:06:18 (5 months ago)
Author:
matthew
Message:

fixed enumeration editing bugs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • edge/streamlined/CHANGELOG

    r854 r856  
    33         - added CSS IDs to each item table row on the list view (MJB) 
    44         - now outputting flash notices on the list view (MJB) 
     5         - fixed enumeration editing bugs (MJB) 
    56 
    671.0RC02 -- 02/22/08 
  • edge/streamlined/lib/streamlined/column/active_record.rb

    r847 r856  
    3535  end 
    3636   
     37  def show_view 
     38    Streamlined::View::ShowViews.create_summary(:enumeration) 
     39  end 
     40   
    3741  def render_td_show(view, item) 
    3842    if enumeration 
    3943      content = item.send(self.name) 
    4044      if enumeration.first.is_a?(Array) 
    41         key_value_pair = enumeration.detect { |e| e.last == content } 
     45        key_value_pair = enumeration_key_for(content) 
    4246        content = key_value_pair.first if key_value_pair 
    4347      end 
     
    5458  end 
    5559   
     60  def enumeration_key_for(value) 
     61    enumeration.detect { |e| e.last == value }  
     62  end 
     63   
    5664  def render_td_list(view, item) 
    5765    id = relationship_div_id(name, item) 
     
    5967    div = div_wrapper(id) { div } if enumeration 
    6068    div += view.link_to_function("Edit", "Streamlined.Enumerations." << 
    61       "open_enumeration('#{id}', this, '/#{view.controller_name}')") if enumeration && editable 
     69      "open_enumeration('#{id}', this, '/#{view.controller_path}')") if enumeration && editable 
    6270    div 
    6371  end 
  • edge/streamlined/lib/streamlined/view/show_views.rb

    r688 r856  
    3838  end 
    3939   
     40  # Renders the enumeration value. 
     41  class Enumeration < Streamlined::View::Base 
     42     
     43  end 
     44   
    4045  class Graph < Streamlined::View::Base 
    4146    def must_have_sparklines! 
  • edge/streamlined/test/unit/streamlined/column/active_record_test.rb

    r847 r856  
    257257   
    258258  def setup_mocks(item_attrs={}) 
    259     @view = flexmock(:controller_name => 'controller_name', :link_to_function => 'link') 
     259    @view = flexmock(:controller_path => 'controller_path', :link_to_function => 'link') 
    260260    @item = flexmock(item_attrs.reverse_merge(:id => 123, :column => 'render')) 
    261261  end