Class: ODDB::View::Admin::YusGroups

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

Constant Summary

COMPONENTS =
{
  [0,0] => :checkbox,
  [1,0] => :privileged_until, 
}
LEGACY_INTERFACE =
false
LABEL =
true
OMIT_HEADER =
true

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Instance Method Summary (collapse)

Instance Method Details

- (Object) checkbox(model)



56
57
58
59
60
61
62
63
64
65
# File 'src/view/admin/entity.rb', line 56

def checkbox(model)
  name = model.name
  affs = @container.model.affiliations || []
  box = HtmlGrid::InputCheckbox.new("yus_groups[#{name}]", model, 
                                    @session, self)
  if(affs.any? { |aff| aff.name == name })
    box.set_attribute('checked', true)
  end
  [box, name]
end

- (Object) init



52
53
54
55
# File 'src/view/admin/entity.rb', line 52

def init
  @model = @session.user.groups.reject { |group| group.name == @model.name }
  super
end

- (Object) privileged_until(model)



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'src/view/admin/entity.rb', line 66

def privileged_until(model)
  if(model.name == 'PowerUser')
    input = HtmlGrid::Input.new(:valid_until, model, @session, self)
    entity = @container.model
    time = entity.privileged_until('view', 'org.oddb') rescue nil
    if(time)
      input.value = time.strftime('%d.%m.%Y')
    else
      txt = @lookandfeel.lookup(:expiration_date)
      input.set_attribute("onfocus", 
                          "if(this.value == '#{txt}') this.value='';")
      input.set_attribute("onblur", 
                          "if(this.value == '') this.value='#{txt}';")
      self.onsubmit = "if(this.valid_until.value == '#{txt}') this.valid_until.value = ''; true;"
      input.value = txt
    end 
    input
  end
end