Class: ODDB::View::Interactions::CyP450List

Inherits:
HtmlGrid::Component show all
Defined in:
src/view/interactions/basket.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from HtmlGrid::Component

#additional_javascripts, #dynamic_html

Constructor Details

- (CyP450List) initialize(type, model, session, container)

A new instance of CyP450List



36
37
38
39
40
# File 'src/view/interactions/basket.rb', line 36

def initialize(type, model, session, container)
  @interaction_type = type
  @list_index = container.list_index
  super(model, session, container)
end

Instance Attribute Details

- (Object) base_substance

Returns the value of attribute base_substance



35
36
37
# File 'src/view/interactions/basket.rb', line 35

def base_substance
  @base_substance
end

Instance Method Details

- (Object) to_html(context)



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'src/view/interactions/basket.rb', line 41

def to_html(context)
  lang = @session.language
  other = @base_substance.en
  content = @model.collect { |substance, items| 
    next unless substance
    text = HtmlGrid::RichText.new(@model, @session, self)
    pub_med_search_link = HtmlGrid::Link.new(:pub_med_search_link, @model, @session, self)
    pub_med_search_link.href = \
      @lookandfeel.lookup(:pub_med_search_href, other, substance.en)
    items = items.sort_by { |item| 
      item.cyp_id
    }
    val = substance.send(lang) + " ("
    val << items.collect { |item|
      cid = item.cyp_id.to_s
      if((factor = item.auc_factor) && factor != "1")
        span = HtmlGrid::Span.new(@model, @session, self)
        factor = factor.gsub('.','')
        span.css_class = "auc-factor-#{factor}"
        span.css_id = "auc-factor-#{@list_index}-#{substance}-#{cid}"
        span.value = cid
        tooltip = HtmlGrid::Span.new(@model, @session, self)
        tooltip.value = @lookandfeel.lookup("explain_auc_factor_#{factor}")
        span.dojo_tooltip = tooltip
        cid = span.to_html(context)
      end
      cid
    }.join(',')
    val << ")"
    pub_med_search_link.value = val
    pub_med_search_link.target = "_blank"
    text << pub_med_search_link
    links = []
    items.each { |item|
      links.concat item.links
    }
    links.uniq!
    links.delete_if { |lnk| lnk.empty? }
    unless(links.empty?)
      text << '<br>'
      fspan = HtmlGrid::Span.new(@model, @session, self)
      fspan.value = @lookandfeel.lookup(:flockhart_link)
      fspan.css_class = 'italic'
      text << fspan
      links.each { |link|
        alink = HtmlGrid::Link.new(:abstract_link, @model, @session, self)
        alink.href = link.href
        alink.value = link.text
        text << "<br>"
        text << alink
        text << "<br>"
        text << link.info
      }
    end
    context.li { text.to_html(context) } 
  }.join
  context.ul { content } unless(content.empty?)
end