Class: ODDB::View::Drugs::ResultList

Inherits:
HtmlGrid::List show all
Includes:
AdditionalInformation, ODDB::View::DataFormat, LookandfeelComponents, ResultColors
Defined in:
src/view/drugs/resultlist.rb,
test/test_view/drugs/resultlist.rb

Direct Known Subclasses

RecentRegsList, RootResultList

Constant Summary

COMPONENTS =
{}
REVERSE_MAP =
{
  :company_name     => false,
  :most_precise_dose=> false,
  :dsp              => false,
  :galenic_form     => false,
  :ikscat           => false,
  :name_base        => false,
  :price_exfactory  => false,
  :price_public     => false,
  :registration_date=> true,
  :size             => false,
  :substances       => true,
}
CSS_MAP =
{}
CSS_KEYMAP =
{
  :active_agents      => 'list italic',
  :comarketing        =>  'list',
  :company_name       => 'list italic',
  :comparable_size    =>  'list right',
  :complementary_type =>  'list',
  :compositions       => 'list italic',
  :ddd_price          => 'list bold right',
  :deductible         =>  'list bold right',
  :fachinfo           => 'list',
  :feedback           => 'list right',
  :galenic_form       => 'list',
  :google_search      => 'list right',
  :ikscat             =>  'list italic',
  :limitation_text    =>  'list',
  :minifi             => 'list',
  :most_precise_dose  => 'list right',
  :name_base          => 'list big',
  :narcotic           => 'list',
  :notify             =>  'list right',
  :patent             =>  'list',
  :patinfo            =>  'list',
  :price_exfactory    =>  'list right',
  :price_public       => 'list pubprice',
  :registration_date  => 'list italic',
  :substances         =>  'list italic',
  :twitter_share      =>  'list right',
  'nbsp'              => 'list',
}
CSS_HEAD_KEYMAP =
{
  :active_agents      => 'th',
  :company_name       => 'th',
  :comparable_size    =>  'th right',
  :complementary_type =>  'th',
  :compositions       => 'th',
  :ddd_price          => 'th right',
  :deductible         =>  'th right',
  :fachinfo           => 'th',
  :feedback           => 'th right',
  :galenic_form       => 'th',
  :google_search      => 'th right',
  :ikscat             =>  'th',
  :limitation_text    =>  'th',
  :minifi             => 'th',
  :most_precise_dose  => 'th right',
  :name_base          => 'th',
  :narcotic           => 'th',
  :notify             =>  'th right',
  :patinfo            =>  'th',
  :price_exfactory    =>  'th right',
  :price_public       => 'th right',
  :registration_date  => 'th',
  :substances         =>  'th',
  :twitter_share      =>  'th',
  'nbsp'              => 'th',
}
CSS_HEAD_MAP =
{}
CSS_CLASS =
'composite'
DEFAULT_CLASS =
HtmlGrid::Value
SORT_DEFAULT =
nil
SUBHEADER =
View::Drugs::AtcHeader
SYMBOL_MAP =
{
  :galenic_form       => View::DescriptionValue,
  :ikskey             =>  View::PointerLink,
}
LOOKANDFEEL_MAP =
{
  :limitation_text  => :ltext,
}

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from LookandfeelComponents

#reorganize_components

Methods included from AdditionalInformation

#_fachinfo, #atc_ddd_link, #atc_description, #comarketing, #complementary_type, #compositions, #ddd_price, #deductible, #feedback, #google_search, #ikscat, #limitation_link, #limitation_text, #minifi, #narcotic, #notify, #patent, #patinfo, #qty_unit, #square, #twitter_share

Methods included from PartSize

#comparable_size, #part_size

Methods included from AtcDddLink

#atc_ddd_link

Methods included from ODDB::View::DataFormat

#breakline, #company_name, #most_precise_dose, #name_base, #price, #price_exfactory, #price_public

Methods included from ExternalLinks

#contact_link, #data_declaration, #external_link, #faq_link, #generic_definition, #help_link, #legal_note, #meddrugs_update, #wiki_link

Instance Attribute Details

- (Object) model (readonly)

Returns the value of attribute model



17
18
19
# File 'test/test_view/drugs/resultlist.rb', line 17

def model
  @model
end

Instance Method Details

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



193
194
195
196
197
198
199
200
201
202
203
# File 'src/view/drugs/resultlist.rb', line 193

def active_agents(model, session=@session)
  link = HtmlGrid::Link.new(:show, model, session, self)
  link.href = @lookandfeel._event_url(:show, {:pointer => model.pointer})
  if model.active_agents.size > 1
    link.set_attribute('title', model.active_agents.join(', '))
    link.value = @lookandfeel.lookup(:active_agents, model.active_agents.size)
  else
    link.value = model.active_agents.to_s
  end
  link
end

- (Object) compose_list(model = @model, offset = [0,0])



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'src/view/drugs/resultlist.rb', line 204

def compose_list(model=@model, offset=[0,0])
  if(model.respond_to?(:overflow?) && model.overflow?)
    x, y, = offset
    half = full_colspan / 2
    @grid.add(explain_atc(model), x, y)
    @grid.add_style("list migel-group", x, y)
    @grid.set_colspan(x, y, half)
    @grid.add(resultview_switch(model), half, y)
    @grid.add_style("list migel-group right", half, y)
    @grid.set_colspan(half, y, full_colspan - half)
    offset = resolve_offset(offset, self::class::OFFSET_STEP)
  end
  code = @session.persistent_user_input(:code)
  model.each { |atc|
    compose_subheader(atc, offset)
    offset = resolve_offset(offset, self::class::OFFSET_STEP)
    if(show_packages? || code == atc.code)
      packages = atc.packages
      super(packages, offset)
      offset[1] += packages.size
    end
  }
end

- (Object) compose_subheader(atc, offset)



227
228
229
230
231
# File 'src/view/drugs/resultlist.rb', line 227

def compose_subheader(atc, offset)
  subheader = self::class::SUBHEADER.new(atc, @session, self)
  @grid.add(subheader, *offset)
  @grid.set_colspan(offset.at(0), offset.at(1), full_colspan)
end

- (Object) explain_atc(model)



232
233
234
235
236
237
# File 'src/view/drugs/resultlist.rb', line 232

def explain_atc(model)
  link = HtmlGrid::Link.new(:explain_atc, model, @session, self)
  link.href = @lookandfeel.lookup(:explain_atc_url)
  link.css_class = 'list bold'
  link
end

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



242
243
244
# File 'src/view/drugs/resultlist.rb', line 242

def fachinfo(model, session=@session)
  super(model, session, 'square important infos')
end

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



238
239
240
241
# File 'src/view/drugs/resultlist.rb', line 238

def galenic_form(model, session=@session)
  lang = @session.language
  model.galenic_forms.collect { |gf| gf.send lang }.compact.join(' / ')
end

- (Object) init



189
190
191
192
# File 'src/view/drugs/resultlist.rb', line 189

def init
  reorganize_components(:result_list_components)
  super
end

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



245
246
247
248
249
250
251
252
253
254
# File 'src/view/drugs/resultlist.rb', line 245

def registration_date(model, session=@session)
  span = HtmlGrid::Span.new(model, @session, self)
  span.value = HtmlGrid::DateValue.new(:registration_date, 
                                       model, @session, self)
  if(exp = (model.inactive_date || model.expiration_date))
    span.set_attribute('title', 
                       @lookandfeel.lookup(:valid_until, @lookandfeel.format_date(exp)))
  end
  span
end

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



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'src/view/drugs/resultlist.rb', line 255

def resultview_switch(model, session=@session)
  current = @session.cookie_set_or_get(:resultview)
  switched = (current == 'pages' ? 'atc' : 'pages')
  args = {
    :search_query => @session.persistent_user_input(:search_query).gsub('/', '%2F'),
    :search_type => @session.persistent_user_input(:search_type), 
    :resultview  => switched,
  }
  link = HtmlGrid::Link.new("rv_#{switched}", model, @session, self)
  if @lookandfeel.disabled?(:best_result)
    link.href = @lookandfeel._event_url(:search, args)
  else
    link.href = @lookandfeel._event_url(:search, args, "best_result")
  end
  link.css_class = "list bold"
  link
end

- (Boolean) show_packages?

Returns:

  • (Boolean)


272
273
274
275
# File 'src/view/drugs/resultlist.rb', line 272

def show_packages?
  !(@model.respond_to?(:overflow?) && @model.overflow?) \
    || @session.cookie_set_or_get(:resultview) == "pages"
end

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



276
277
278
279
280
281
282
283
284
285
286
287
# File 'src/view/drugs/resultlist.rb', line 276

def substances(model, session=@session)
  link = HtmlGrid::Link.new(:show, model, session, self)
  link.href = @lookandfeel._event_url(:show, {:pointer => model.pointer})
  if (model.active_agents.size > 1)
    #txt = HtmlGrid::Component.new(model, session, self)
    link.set_attribute('title', model.active_agents.join(', '))
    link.value = @lookandfeel.lookup(:active_agents, model.active_agents.size)
  else
    link.value = model.substances.first.to_s
  end
  link
end