Class: ODDB::Html::View::Drugs::Admin::ActiveAgents
- Inherits:
-
List
- Object
- HtmlGrid::List
- List
- ODDB::Html::View::Drugs::Admin::ActiveAgents
show all
- Defined in:
- lib/oddb/html/view/drugs/admin/sequence.rb
Constant Summary
collapse
- COMPONENTS =
{
[0,0] => :delete,
[1,0] => :substance,
[2,0,0] => :dose,
[2,0,1] => :unsaved,
}
- COMPONENT_CSS_MAP =
{ [2,0] => 'short right' }
- DEFAULT_CLASS =
HtmlGrid::InputText
- EMPTY_LIST =
true
- STRIPED_BG =
false
Constants inherited
from List
List::BACKGROUND_ROW, List::BACKGROUND_SUFFIX, List::LEGACY_INTERFACE, List::SORT_DEFAULT
Instance Method Summary
collapse
Methods inherited from List
#query_args, #query_key, #sort_link
Instance Method Details
#add(model) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 28
def add(model)
link = HtmlGrid::Link.new(:plus, model, @session, self)
link.set_attribute('title', @lookandfeel.lookup(:create_active_agent))
link.css_class = 'create square'
args = [ :uid, @session.state.model.uid, :composition, composition ]
url = @session.lookandfeel.event_url(:ajax_create_active_agent, args)
link.onclick = "replace_element('#{css_id}', '#{url}');"
link
end
|
37
38
39
40
41
42
43
44
45
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 37
def (offset)
if(@model.empty? || @model.last)
@grid.add add(@model), *offset
offset[0] += 1
@grid.add delete_composition(@model), *offset
@grid.add_style 'right', *offset
@grid.set_colspan offset.at(0), offset.at(1)
end
end
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 46
def (offset)
comp = if act = @model.first
act.composition
end
input = galenic_form(comp)
label = HtmlGrid::SimpleLabel.new(:galenic_form, input, @session, self)
pos = *offset.dup
pos[0] += 1
@grid.add [label, input], *pos
pos.push 2
@grid.set_colspan *pos
offset[1] += 1
offset
end
|
#composition ⇒ Object
60
61
62
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 60
def composition
@container ? @container.list_index : @session.user_input(:composition)
end
|
#css_id ⇒ Object
63
64
65
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 63
def css_id
@css_id ||= "active-agents-#{composition}"
end
|
#delete(model) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 66
def delete(model)
unless(@model.first.nil?)
link = HtmlGrid::Link.new(:minus, model, @session, self)
link.set_attribute('title', @lookandfeel.lookup(:delete))
link.css_class = 'delete square'
args = [ :uid, @session.state.model.uid, :composition, composition,
:active_agent, @list_index ]
url = @session.lookandfeel.event_url(:ajax_delete_active_agent, args)
link.onclick = "replace_element('#{css_id}', '#{url}');"
link
end
end
|
#delete_composition(model) ⇒ Object
78
79
80
81
82
83
84
85
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 78
def delete_composition(model)
link = HtmlGrid::Link.new(:delete_composition, model, @session, self)
link.css_class = 'ajax'
args = [ :uid, @session.state.model.uid, :composition, composition ]
url = @session.lookandfeel.event_url(:ajax_delete_composition, args)
link.onclick = "replace_element('composition-list', '#{url}');"
link
end
|
#dose(model) ⇒ Object
86
87
88
89
90
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 86
def dose(model)
input = HtmlGrid::InputText.new(name("dose"), model, @session, self)
input.value = model.dose.to_s if model
input
end
|
91
92
93
94
95
96
97
98
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 91
def galenic_form(model)
input = HtmlGrid::InputText.new("galenic_form[#{composition}]",
model, @session, self)
if model && gf = model.galenic_form
input.value = gf.description.send @session.language
end
input
end
|
#name(part) ⇒ Object
99
100
101
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 99
def name(part)
"#{part}[#{composition}][#@list_index]"
end
|
#substance(model) ⇒ Object
102
103
104
105
106
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 102
def substance(model)
input = HtmlGrid::InputText.new(name("substance"), model, @session, self)
input.value = model.substance.name.send(@session.language) if model
input
end
|
#unsaved(model) ⇒ Object
107
108
109
|
# File 'lib/oddb/html/view/drugs/admin/sequence.rb', line 107
def unsaved(model)
@lookandfeel.lookup(:unsaved) if model.nil?
end
|