Class: ODDB::View::Admin::CompositionSelect

Inherits:
HtmlGrid::AbstractSelect
  • Object
show all
Defined in:
src/view/admin/package.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) selection(context)



21
22
23
24
25
26
27
28
29
30
31
32
# File 'src/view/admin/package.rb', line 21

def selection(context)
  lang = @session.language
  @selected ||= (comp = @model.composition) && shorten(comp)
  res = []
  @model.registration.compositions.each_with_index { |composition, idx|
    comp = shorten(composition)
    attribs = { "value" => idx }
    attribs.store("selected", 1) if(comp == selected)
    res << context.option(attribs) { comp }
  }
  res
end

- (Object) shorten(comp)



33
34
35
36
37
38
39
40
# File 'src/view/admin/package.rb', line 33

def shorten(comp)
  str = comp.to_s
  if(str.length > 60)
    str[0,57] << '...'
  else 
    str
  end
end