Class: ODDB::View::Drugs::CompareList

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

Constant Summary

COMPONENTS =
{}
CSS_CLASS =
'composite'
CSS_KEYMAP =
{
  :active_agents     => 'list italic',
  :company_name      => 'list italic',
  :comparable_size   => 'list',
  :compositions      => 'list italic',
  :ddd_price         => 'list right',
  :deductible        => 'list right',
  :ikscat            => 'list italic',
  :most_precise_dose => 'list right',
  :name_base         => 'list big',
  :price_difference  => 'list bold right',
  :price_public      => 'list pubprice',
}
CSS_HEAD_KEYMAP =
{
  :active_agents     => 'th',
  :company_name      => 'th',
  :comparable_size   => 'th',
  :compositions      => 'th',
  :ddd_price         => 'th right',
  :deductible        => 'th right',
  :ikscat            => 'th',
  :most_precise_dose => 'th right',
  :name_base         => 'th',
  :price_difference  => 'th right',
  :price_public      => 'th right',
}
CSS_HEAD_MAP =
{}
CSS_MAP =
{}
DEFAULT_CLASS =
HtmlGrid::Value
SORT_DEFAULT =
nil
SORT_HEADER =
false
SORT_REVERSE =
false
SYMBOL_MAP =
{
  :registration_date  => HtmlGrid::DateValue,
}

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Instance Method Summary (collapse)

Methods included from AdditionalInformation

#_fachinfo, #atc_ddd_link, #atc_description, #comarketing, #complementary_type, #compositions, #ddd_price, #deductible, #fachinfo, #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 Method Details

- (Object) active_agents(model, session)



72
73
74
# File 'src/view/drugs/compare.rb', line 72

def active_agents(model, session)
  model.active_agents.join(',<br>')
end

- (Object) compose_empty_list(offset)



75
76
77
78
79
80
81
82
# File 'src/view/drugs/compare.rb', line 75

def compose_empty_list(offset)
  package_line(offset)
  text = @lookandfeel.lookup(:no_comparables)
  offset = resolve_offset(offset, self::class::OFFSET_STEP)
  @grid.add(text, *offset)
  @grid.add_style('list', *offset)
  @grid.set_colspan(*offset)
end

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



83
84
85
86
87
# File 'src/view/drugs/compare.rb', line 83

def compose_list(model=@model, offset=[0,0])
  package_line(offset)
  offset = resolve_offset(offset, self::class::OFFSET_STEP)
  super(model.comparables, offset)
end

- (Object) init



57
58
59
60
# File 'src/view/drugs/compare.rb', line 57

def init
  reorganize_components
  super
end

- (Object) package_line(offset)



88
89
90
# File 'src/view/drugs/compare.rb', line 88

def package_line(offset)
  _compose(@model.package, offset) if(@model.respond_to? :package)
end

- (Object) price_difference(model, session)



91
92
93
94
95
# File 'src/view/drugs/compare.rb', line 91

def price_difference(model, session)
  if(diff = model.price_difference)
    sprintf('%+d%', diff*100.0)
  end
end

- (Object) reorganize_components



61
62
63
64
65
66
67
68
69
70
71
# File 'src/view/drugs/compare.rb', line 61

def reorganize_components
  @components = @lookandfeel.compare_list_components
  @css_map = {}
  @css_head_map = {}
  @components.each { |key, val|
    if(klass = self::class::CSS_KEYMAP[val])
      @css_map.store(key, klass)
      @css_head_map.store(key, self::class::CSS_HEAD_KEYMAP[val] || 'th')
    end
  }
end

- (Object) sort_model



96
97
98
99
100
# File 'src/view/drugs/compare.rb', line 96

def sort_model
  if((@session.event != :sort) && (block = @lookandfeel.comparison_sorter))
    @model.sort_by!(&block)
  end
end