<< | Index | >>
Goal/Estimate/Evaluation:
Next
Note
Experiment
Possible solution
Concept
Note
Idea
Experiment
def initialize(product, sortvalue = nil) if product and items = product.items @sortvalue = sortvalue ...
def sort_by # This is called at the first time when a search result is shown @list.sort_by do |record| if @sortvalue record.send(@sortvalue.to_sym).to_s else record.pharmacode end end
def migel_search if migel_code = @session.user_input(:migel_code) and product = @session.search_migel_products(migel_code).first #ODDB::State::Migel::Items.new(@session, ODDB::Migel::Items.new(product)) ODDB::State::Migel::Items.new(@session, ODDB::Migel::Items.new(product, @session.user_input(:sortvalue))) ...
Access
Note
Experiment
def sort_link(header_key, matrix, component) link = HtmlGrid::Link.new(header_key, @model, @session, self) link.href = @lookandfeel._event_url(:migel_search, [:migel_code, @model.first.migel_code, :sortvalue, component.to_s]) link end
Access
Result
Note
Next
Experiment
def migel_search if migel_code = @session.user_input(:migel_code) and product = @session.search_migel_products(migel_code).first sort_key = @session.user_input(:sortvalue) || @session.user_input(:reverse) reverse = @session.user_input(:reverse) ODDB::State::Migel::Items.new(@session, ODDB::Migel::Items.new(product, sort_key, reverse))
class Items attr_reader :price, :qty, :unit, :pointer_descr def initialize(product, sortvalue = nil, reverse = nil) if product and items = product.items @sortvalue = sortvalue @list = items.values @reverse = reverse ...
def sort_by # This is called at the first time when a search result is shown @list.sort_by do |record| if @sortvalue if @sortvalue == 'ppub' record.ppub.to_f else record.send(@sortvalue.to_sym).to_s end else record.pharmacode end end #reverse_sort! if @reverse if @reverse reverse_sort! end @list end
def sort_link(header_key, matrix, component) link = HtmlGrid::Link.new(header_key, @model, @session, self) sort = @session.user_input(:sortvalue) ? :reverse : :sortvalue link.href = @lookandfeel._event_url(:migel_search, [:migel_code, @model.first.migel_code.gsub('.',''), sort, component.to_s]) link end def reverse_sort! sort! do |a,b| a.send(@sortvalue.to_sym).to_s <=> b.send(@sortvalue.to_sym).to_s end end
Access
Result