Class: YDIM::Html::View::InvoiceComposite

Inherits:
HtmlGrid::DivComposite
  • Object
show all
Includes:
HtmlGrid::FormMethods
Defined in:
lib/ydim/html/view/invoice.rb

Direct Known Subclasses

AutoInvoiceComposite

Constant Summary collapse

FORM_ID =
'invoice'
COMPONENTS =
{
  [0,0]  => InvoiceInnerComposite,
  [0,1]  => :items,
  [0,2]  => InvoiceTotalComposite,
  [0,3]  => :submit,
  [1,3]  => :pdf,
  [2,3]  => :send_invoice,
}
CSS_MAP =
{
  3  => 'padded'
}
EVENT =
:update

Instance Method Summary collapse

Instance Method Details

#button(key, model) ⇒ Object



201
202
203
204
205
206
207
# File 'lib/ydim/html/view/invoice.rb', line 201

def button(key, model)
  button = HtmlGrid::Button.new(key, model, @session, self)
  url = @lookandfeel._event_url(key, {:unique_id => model.unique_id})
  button.set_attribute('onClick', 
     "this.form.event.value='#{key}'; this.form.submit()")
  button
end

#hidden_fields(context) ⇒ Object



186
187
188
# File 'lib/ydim/html/view/invoice.rb', line 186

def hidden_fields(context)
  super << context.hidden('unique_id', @model.unique_id)
end

#initObject



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/ydim/html/view/invoice.rb', line 169

def init
  if(@model.unique_id.nil?)
    @components = {
      [0,0]  => components[[0,0]],
      [0,1]  => :submit,
    }
    @css_map = { 1 => 'padded' }
  elsif(@model.items.empty?)
    @components = {
      [0,0]  => components[[0,0]],
      [0,1]  => :items,
      [0,2]  => :submit,
    }
    @css_map = { 2 => 'padded' }
  end
  super
end

#items(model) ⇒ Object



189
190
191
# File 'lib/ydim/html/view/invoice.rb', line 189

def items(model)
  ItemList.new(model.items, @session, self)
end

#pdf(model) ⇒ Object



192
193
194
195
196
197
# File 'lib/ydim/html/view/invoice.rb', line 192

def pdf(model)
  button = HtmlGrid::Button.new(:pdf, model, @session, self)
  url = @lookandfeel._event_url(:pdf, {:unique_id => model.unique_id})
  button.set_attribute('onClick', "document.location.href='#{url}'")
  button
end

#send_invoice(model) ⇒ Object



198
199
200
# File 'lib/ydim/html/view/invoice.rb', line 198

def send_invoice(model)
  button(:send_invoice, model)
end