Class: ODDB::View::Drugs::ResultComposite

Inherits:
HtmlGrid::Composite show all
Includes:
ResultFootBuilder
Defined in:
src/view/drugs/result.rb

Direct Known Subclasses

RecentRegsComposite

Constant Summary

COLSPAN_MAP =
{}
COMPONENTS =
{
  [0,0,0] =>  :title_found,
  [0,0,1] =>  :dsp_sort,
  [0,1]   => 'price_compare',
}
CSS_CLASS =
'composite'
EVENT =
:search
FORM_METHOD =
'GET'
DEFAULT_LISTCLASS =
View::Drugs::ResultList
ROOT_LISTCLASS =
View::Drugs::RootResultList
SYMBOL_MAP =
{ }
CSS_MAP =
{
  [0,0] =>  'result-found',
  [1,0] =>  'right',
  [0,1] =>  'list bold price-compare',
  [1,1] =>  'right',
}

Constants included from ResultFootBuilder

EXPLAIN_RESULT

Instance Method Summary (collapse)

Methods included from ResultFootBuilder

#result_foot

Methods inherited from HtmlGrid::Composite

event_link, #hash_insert_col, #hash_insert_row

Instance Method Details



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'src/view/drugs/result.rb', line 118

def breadcrumbs(model, session=@session)
  breadcrumbs = []
  level = 2
  if @lookandfeel.enabled?(:home)
    dv = HtmlGrid::Span.new(model, @session, self)
    dv.css_class = "breadcrumb"
    dv.value = "<"
    span1 = HtmlGrid::Span.new(model, @session, self)
    span1.css_class = "breadcrumb-#{level} bold"
    level -= 1
    link1 = HtmlGrid::Link.new(:back_to_home, model, @session, self)
    link1.href = @lookandfeel._event_url(:home)
    link1.css_class = "list"
    span1.value = link1
    breadcrumbs.push span1, dv
  end
  span2 = HtmlGrid::Span.new(model, @session, self)
  span2.css_class = "breadcrumb-#{level}"
  query = @session.persistent_user_input(:search_query).gsub('/', '%2F')
  span2.value = @lookandfeel.lookup(:list_for, query, model.package_count)
  span3 = HtmlGrid::Span.new(model, @session, self)
  span3.css_class = "breadcrumb"
  span3.value = '–'
  breadcrumbs.push span2, span3
end

- (Object) dsp_sort(model, session)



143
144
145
146
147
148
# File 'src/view/drugs/result.rb', line 143

def dsp_sort(model, session)
  url = @lookandfeel.event_url(:sort, {:sortvalue => :dsp})
  link = HtmlGrid::Link.new(:dsp_sort, model, @session, self)
  link.href = url
  link
end

- (Object) explain_colors(model, session = @session)



149
150
151
152
153
154
155
156
# File 'src/view/drugs/result.rb', line 149

def explain_colors(model, session=@session)
  comps = {
    [0,0] =>  :explain_original,
    [0,1] =>  :explain_generic,
    [0,2] =>  'explain_unknown',
  }
  ExplainResult.new(model, @session, self, comps)
end

- (Object) export_csv(model, session = @session)



157
158
159
160
161
# File 'src/view/drugs/result.rb', line 157

def export_csv(model, session=@session)
  if(@lookandfeel.enabled?(:export_csv))
    View::Drugs::DivExportCSV.new(model, @session, self)
  end
end

- (Object) init



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'src/view/drugs/result.rb', line 77

def init
  if(@lookandfeel.enabled?(:breadcrumbs))
    components.store([0,0,0], :breadcrumbs)
    css_map.store([0,0], 'breadcrumbs')
  end
  if @lookandfeel.disabled?(:search)
    colspan_map.store [0,1], 2
  else
    components.store [1,1], SelectSearchForm
  end
  y = 2
  if(@lookandfeel.enabled?(:explain_sort, false))
    components.store([0,y], "explain_sort")
    css_map.store([0,y], "navigation")
    colspan_map.store([0,y], 2)
    y += 1
  end
  if @lookandfeel.enabled?(:oekk_structure, false)
    components.store([0,y], :explain_colors)
    css_map.store([0,y], "explain")
    colspan_map.store([0,y], 2)
    y += 1
  end
  colspan_map.store([0,y], 2)
  components.store([0,y], (@session.allowed?('edit', 'org.oddb.drugs')) \
                          ? self::class::ROOT_LISTCLASS \
                          : self::class::DEFAULT_LISTCLASS)
  if(@lookandfeel.enabled?(:export_csv))
    components.store([1,0], :export_csv)
  else
    colspan_map.store([0,0], 2)
  end
  code = @session.persistent_user_input(:code)
  unless(@model.respond_to?(:overflow?) && @model.overflow? \
         && (code.nil? || !@model.any? { |atc| atc.code == code }))
    y += 1
    components.store([0,y], :result_foot)
    colspan_map.store([0,y], 2)
  end
  super
end

- (Object) title_found(model, session = @session)



162
163
164
165
# File 'src/view/drugs/result.rb', line 162

def title_found(model, session=@session)
  query = @session.persistent_user_input(:search_query)
  @lookandfeel.lookup(:title_found, query, model.package_count)
end