Class: ODDB::View::Drugs::AtcChooserList

Inherits:
HtmlGrid::List show all
Defined in:
src/view/drugs/atcchooser.rb

Constant Summary

COMPONENTS =
{
  [0,0] =>  :description,
  [1,0] =>  :atc_ddd_link,
}
CSS_MAP =
{
  [1,0] =>  "list right"
}
COMPONENT_CSS_MAP =
{}
CSS_CLASS =
"composite"
DEFAULT_CLASS =
HtmlGrid::Value
OMIT_HEADER =
true
SORT_DEFAULT =
false
SORT_REVERSE =
false

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Instance Method Summary (collapse)

Instance Method Details

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



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'src/view/drugs/atcchooser.rb', line 48

def compose_list(model=@model, offset=[0,0])
  code = @session.persistent_user_input(:code)
  model.each{ |mdl|
    if(mdl.has_sequence?)
      _compose(mdl, offset)
      #compose_components(mdl, offset)
      #compose_css(offset)
      offset = resolve_offset(offset, self::class::OFFSET_STEP)
      if(mdl.path_to?(code))
        open = AtcChooserList.new(mdl, @session, self)
        #open.attributes["class"] = "atcchooser#{mdl.level}"
        @grid.add(open, *offset)
        @grid.set_colspan(*offset)
        offset = resolve_offset(offset, self::class::OFFSET_STEP)
      end
    end
  }
  offset
end

- (Object) description(mdl, session)



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'src/view/drugs/atcchooser.rb', line 67

def description(mdl, session)
  link = HtmlGrid::Link.new(:atcchooser, mdl, @session, self)
  event, args, css = if(result_link?(mdl))
    [
      :search, 
      {'search_query'=>mdl.code}, 
      "atclink",
    ]
  else
    #@lookandfeel.event_url(:atc_chooser, {'code'=>mdl.code})
    [
      :atc_chooser,
      {'code'=>mdl.code}, 
      "atcchooser",
    ]
  end
  link.href = @lookandfeel._event_url(event, args)
  link.value = mdl.pointer_descr(@session.language)
  link.attributes["class"] = css + mdl.level.to_s
  link
end

- (Object) edit(model, session)



88
89
90
91
92
93
# File 'src/view/drugs/atcchooser.rb', line 88

def edit(model, session)
  link = View::PointerLink.new(:code, model, session, self)
  link.value = @lookandfeel.lookup :edit_atc_class
  link.attributes['class'] = 'small'
  link
end

- (Object) init



37
38
39
40
41
42
43
44
45
46
47
# File 'src/view/drugs/atcchooser.rb', line 37

def init
  css_map.store([0,0], "atcchooser#{@model.level.next}")
  @model = @model.children
  if(@session.user.allowed?('login', 'org.oddb.RootUser'))
    components.store([2,0], :edit)
    css_map.store([2,0], 'list small')
  end
  ## only call persistent_user_input once
  @atc = @session.persistent_user_input(:code)
  super
end

- (Boolean) result_link?(mdl)

Returns:

  • (Boolean)


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

def result_link?(mdl)
  mdl.code.length > 2 \
    && (mdl.path_to?(@atc) \
    || (!mdl.children.any?{ |child| 
      child.has_sequence? } \
    && !mdl.sequences.empty?))
end