Class: ODDB::View::Admin::RootActiveAgents

Inherits:
ActiveAgents show all
Defined in:
src/view/admin/sequence.rb

Constant Summary

COMPONENTS =
{
  [0,0] => :delete,
  [1,0] => :substance,
  [2,0,0] => :dose,
  [2,0,1] => :unsaved,
}
COMPONENT_CSS_MAP =
{ [2,0] => 'short right' }
CSS_HEAD_MAP =
{
  [2,0] => 'right',
}
CSS_MAP =
{ }
DEFAULT_CLASS =
HtmlGrid::InputText
HTTP_HEADERS =
{
  "Content-Type"  => "text/html; charset=UTF-8",
  "Cache-Control" =>  "private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
  "Pragma"        =>  "no-cache",
  "Expires"       => Time.now.rfc1123,
}

Constants inherited from ActiveAgents

COMPONENTS, CSS_HEAD_MAP, CSS_MAP, DEFAULT_CLASS, EMPTY_LIST, LABELS, LEGACY_INTERFACE, OMIT_HEADER, SORT_DEFAULT, SORT_HEADER, STRIPED_BG

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Instance Method Summary (collapse)

Methods inherited from ActiveAgents

#_compose_footer

Instance Method Details

- (Object) add(model)



96
97
98
99
100
101
102
103
104
# File 'src/view/admin/sequence.rb', line 96

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 = [ :pointer, @session.state.model.pointer, :composition, composition ]
  url = @session.lookandfeel.event_url(:ajax_create_active_agent, args)
  link.onclick = "replace_element('#{css_id}', '#{url}');"
  link
end


105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'src/view/admin/sequence.rb', line 105

def compose_footer(offset)
  if(@model.empty? || @model.last)
    @grid.add add(@model), *offset
    offset[1] += 1
    _compose_footer [offset[0].next, offset[1]]
    offset[1] += 1
    @grid.add delete_composition(@model), *offset
    @grid.add_style 'right', *offset
    @grid.set_colspan offset.at(0), offset.at(1)
    offset[1] += 1
  else
    _compose_footer [offset[0].next, offset[1]]
  end
end

- (Object) composition



119
120
121
# File 'src/view/admin/sequence.rb', line 119

def composition
  @container ? @container.list_index : @session.user_input(:composition)
end

- (Object) css_id



122
123
124
# File 'src/view/admin/sequence.rb', line 122

def css_id
  @css_id ||= "active-agents-#{composition}"
end

- (Object) delete(model)



125
126
127
128
129
130
131
132
133
134
135
136
# File 'src/view/admin/sequence.rb', line 125

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 = [ :pointer, @session.state.model.pointer, :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

- (Object) delete_composition(model)



137
138
139
140
141
142
143
144
# File 'src/view/admin/sequence.rb', line 137

def delete_composition(model)
  link = HtmlGrid::Link.new(:delete_composition, model, @session, self)
  link.css_class = 'ajax'
  args = [ :pointer, @session.state.model.pointer, :composition, composition ]
  url = @session.lookandfeel.event_url(:ajax_delete_composition, args)
  link.onclick = "replace_element('composition-list', '#{url}');"
  link
end

- (Object) dose(model)



145
146
147
148
149
# File 'src/view/admin/sequence.rb', line 145

def dose(model)
  input = HtmlGrid::InputText.new(name("dose"), model, @session, self)
  input.value = super
  input
end

- (Object) galenic_form(model)



150
151
152
153
154
155
156
157
158
# File 'src/view/admin/sequence.rb', line 150

def galenic_form(model)
  input = HtmlGrid::InputText.new("galenic_form[#{composition}]", 
                                  model, @session, self)
  input.label = true
  if model && gf = model.galenic_form
    input.value = gf.send @session.language
  end
  input
end

- (Object) name(part)



159
160
161
# File 'src/view/admin/sequence.rb', line 159

def name(part)
  "#{part}[#{composition}][#@list_index]"
end

- (Object) substance(model)



162
163
164
165
166
# File 'src/view/admin/sequence.rb', line 162

def substance(model)
  input = HtmlGrid::InputText.new(name("substance"), model, @session, self)
  input.value = super
  input
end

- (Object) unsaved(model)



167
168
169
# File 'src/view/admin/sequence.rb', line 167

def unsaved(model)
  @lookandfeel.lookup(:unsaved) if model.nil?
end