Module: ODDB::View::DataFormat

Includes:
ExternalLinks
Included in:
Admin::PackageInnerComposite, Admin::SequencePackageList, Ajax::DDDPriceTable, Analysis::PositionInnerComposite, ODDB::View::Drugs::CompareList, ODDB::View::Drugs::DDDPriceTable, ODDB::View::Drugs::PackageInnerComposite, ODDB::View::Drugs::PriceHistoryList, ODDB::View::Drugs::ResultLimitList, ODDB::View::Drugs::ResultList, Migel::List, Migel::ProductInnerComposite
Defined in:
src/view/dataformat.rb

Instance Method Summary (collapse)

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) breakline(txt, length)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'src/view/dataformat.rb', line 10

def breakline(txt, length)
  name = ''
  line = ''
  last = ''
  txt.to_s.split(/(:?[\s-])/u).each { |part|
    if((line.length + last.length + part.length) > length \
      && part.length > 3)
      name << line << last << '<br>'
      line = ''
    else
      line << last
    end
    last = part
  }
  name << line << last
end

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



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'src/view/dataformat.rb', line 26

def company_name(model, session=@session)
  if(comp = model.company)
    link = nil
    if(@lookandfeel.enabled?(:powerlink, false) && comp.powerlink)
      link = HtmlGrid::PopupLink.new(:name, comp, session, self)
      link.href = @lookandfeel._event_url(:powerlink, {'pointer'=>comp.pointer})
      link.set_attribute("class", "powerlink")
    elsif(@lookandfeel.enabled?(:companylist) \
      && comp.listed?)
      link = View::PointerLink.new(:name, comp, session, self)
    else
      link = HtmlGrid::Value.new(:name, comp, session, self)
    end
    link.value = breakline(comp.name, 21)
    link
  end
end

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



43
44
45
46
47
48
49
50
51
# File 'src/view/dataformat.rb', line 43

def most_precise_dose(model, session=@session)
  if(model.respond_to?(:most_precise_dose))
    dose = model.most_precise_dose
    if dose.is_a?(Quanty)
      dose = (dose && (dose.qty > 0)) ? dose : nil
    end
    dose.to_s.gsub(/\s+/u, '&nbsp;')
  end
end

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



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
# File 'src/view/dataformat.rb', line 52

def name_base(model, session=@session)
  ## optimization: there is a new Instance of the including Component for
  ## each new query. Therefore it should be _much_ faster to have an 
  ## instance variable @query than to call @session.persistent_user_input
  ## for every line in a result
  @query ||= @session.persistent_user_input(:search_query)
  @type ||= @session.persistent_user_input(:search_type)
  link = HtmlGrid::Link.new(:compare, model, session, self)
  args = [
    :pointer, model.pointer, :search_type, @type, :search_query, @query,
  ]
  if (ean_code = model.barcode)
    link.href = @lookandfeel._event_url(:compare) + "ean13/" + ean_code
  else
    link.href = @lookandfeel._event_url(:compare, args)
  end
  link.value = breakline(model.name_base, 25)
  link_class = 'big' << resolve_suffix(model)
  link.css_class = link_class
  if(model.good_result?(@query) && !@lookandfeel.disabled?(:best_result))
     link.set_attribute('name', 'best_result')
  end
  indication = model.registration.indication
  descr = model.descr
  if(descr && descr.empty?)
    descr = nil
  end
  title = [
    descr,
    @lookandfeel.lookup(:ean_code, model.barcode),
    (indication.send(@session.language) unless(indication.nil?)),
  ].compact.join(', ')
  link.set_attribute('title', title)
  url = model.photo_link
  unless url.to_s.empty?
    photo = HtmlGrid::Link.new(:photo_link_short, model, @session, self)
    photo.href = url
    photo.set_attribute 'title', @lookandfeel.lookup(:photo_link_title)
    photo.css_class = 'square infos'
    [link, ' ‐ ', photo]
  else
    link
  end
end

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



96
97
98
# File 'src/view/dataformat.rb', line 96

def price(model, session=@session)
  formatted_price(:price, model)
end

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



99
100
101
# File 'src/view/dataformat.rb', line 99

def price_exfactory(model, session=@session)
  formatted_price(:price_exfactory, model)
end

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



102
103
104
# File 'src/view/dataformat.rb', line 102

def price_public(model, session=@session)
  formatted_price(:price_public, model)
end