Class: ODDB::View::Interactions::ResultList

Inherits:
HtmlGrid::List show all
Defined in:
src/view/interactions/resultlist.rb

Constant Summary

COMPONENTS =
{
  [0,0] =>  :name,
  [1,0] =>  :search_oddb,
  [2,0] =>  :interaction_basket_status,
}
REVERSE_MAP =
{
  :name                       => false,
  :search_oddb                =>  false,
  :interaction_basket_status  => false,
}
CSS_MAP =
{
  [0,0] =>  'list big',
  [1,0] =>  'list',
  [2,0] =>  'list big',
}
COMPONENT_CSS_MAP =
{ }
CSS_CLASS =
'composite'
DEFAULT_CLASS =
HtmlGrid::Value
DEFAULT_HEAD_CLASS =
'th'
SORT_DEFAULT =
nil
STRIPED_BG =
true

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Instance Method Summary (collapse)

Instance Method Details

- (Object) interaction_basket_status(model, session)



41
42
43
44
45
46
47
48
49
50
# File 'src/view/interactions/resultlist.rb', line 41

def interaction_basket_status(model, session)
  if(session.interaction_basket.include?(model))
    link = HtmlGrid::Link.new(:interaction_basket, model, session, self)
    ids = @session.interaction_basket.collect { |sub| sub.oid }
    link.href = @session.interaction_basket_link
    link.value = @lookandfeel.lookup(:in_interaction_basket)
    link.set_attribute('font-weight', 'bold')
    link
  end
end

- (Object) name(model, session)



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'src/view/interactions/resultlist.rb', line 51

def name(model, session)
  name = model.send(@session.language)
  if(session.interaction_basket.include?(model))
    name
  else
    link = HtmlGrid::Link.new(:add_to_interaction_basket, model, session, self)
    #link.href = @lookandfeel._event_url(:add_to_interaction_basket, {'pointer'=>CGI.escape(model.pointer.to_s)})
    ids = @session.interaction_basket_ids << "+" << model.oid.to_s
    link.href = @lookandfeel._event_url(:interaction_basket, :substance_ids => ids)
    link.value = name
    link.set_attribute('class', 'list big')
    link
  end
end

- (Object) search_oddb(model, session)



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'src/view/interactions/resultlist.rb', line 65

def search_oddb(model, session)
  active_sequences = model.sequences.select { |seq| 
    seq.active_package_count > 0 
  }
  unless(active_sequences.empty?)
    link = HtmlGrid::Link.new(:substance_result, model, session, self)
    link.href = @lookandfeel._event_url(:search, 'search_query' => model.name, 
                                                 'zone' => :drugs)
    link.value = @lookandfeel.lookup(:search_oddb)
    link.css_class = 'small'
    link
  end
end