Class: ODDB::View::Admin::Parts

Inherits:
HtmlGrid::List show all
Defined in:
src/view/admin/package.rb

Constant Summary

COMPONENTS =
{
  [0,0] => :delete,
  [1,0] => :multi,
  [2,0] => "x",
  [3,0] => :count,
  [4,0] => :commercial_form,
  [5,0] => "à",
  [6,0] => :measure,
  [7,0] => :composition,
  [8,0] => :unsaved,
}
COMPONENT_CSS_MAP =
{ 
  [1,0,3] => "small right",
  [6,0]   => "small right",
}
CSS_HEAD_MAP =
{
  [0,0] => 'list',
  [1,0] => 'list right',
  [3,0] => 'list right',
  [4,0] => 'list',
  [6,0] => 'list right',
}
CSS_ID =
'parts'
DEFAULT_CLASS =
HtmlGrid::InputText
EMPTY_LIST =
true
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,
}
OMIT_HEADER =
false
OMIT_HEAD_TAG =
true
LEGACY_INTERFACE =
false
LOOKANDFEEL_MAP =
{ :delete => :example }
DEFAULT_HEAD_CLASS =
nil
SORT_DEFAULT =
nil
SORT_HEADER =
false

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) input_text(*keys)



44
45
46
47
48
49
50
51
52
# File 'src/view/admin/package.rb', line 44

def input_text(*keys)
  keys.each { |key|
    define_method(key) { |model| 
      input = HtmlGrid::Input.new(name(key), model, @session, self)
      input.value = model.send(key) if model
      input
    }
  }
end

Instance Method Details

- (Object) add(model)



93
94
95
96
97
98
99
100
101
# File 'src/view/admin/package.rb', line 93

def add(model)
  link = HtmlGrid::Link.new(:plus, model, @session, self)
  link.set_attribute('title', @lookandfeel.lookup(:create_part))
  link.css_class = 'create square'
  args = [ :pointer, @session.state.model.pointer ]
  url = @session.lookandfeel.event_url(:ajax_create_part, args)
  link.onclick = "replace_element('#{css_id}', '#{url}');"
  link
end


102
103
104
105
106
# File 'src/view/admin/package.rb', line 102

def compose_footer(offset)
  if(@model.empty? || !@model.last.is_a?(Persistence::CreateItem))
    @grid.add add(@model), *offset
  end
end

- (Object) composition(model)



107
108
109
# File 'src/view/admin/package.rb', line 107

def composition(model)
  CompositionSelect.new(name("composition"), model, @session, self)
end

- (Object) delete(model)



110
111
112
113
114
115
116
117
118
119
120
# File 'src/view/admin/package.rb', line 110

def delete(model)
  if(@model.size > 1)
    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, :part, @list_index ]
    url = @session.lookandfeel.event_url(:ajax_delete_part, args)
    link.onclick = "replace_element('#{css_id}', '#{url}');"
    link
  end
end

- (Object) name(part)



121
122
123
# File 'src/view/admin/package.rb', line 121

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

- (Object) unsaved(model)



124
125
126
# File 'src/view/admin/package.rb', line 124

def unsaved(model)
  @lookandfeel.lookup(:unsaved) if model.is_a?(Persistence::CreateItem)
end