Sha256: 932e333c824dd7386ae588a7bcdb0bd463b269c10e1dea13098446cacdc322a4

Contents?: true

Size: 1.45 KB

Versions: 8

Compression:

Stored size: 1.45 KB

Contents

include_set Abstract::AccountDropdown

assign_type :session

def ok_to_read
  true
end

def ok_to_update
  left_id == Auth.current_id
end

def ok_to_create
  left_id == Auth.current_id
end

def ensure_roles
  self.content = Auth.current_roles.to_pointer_content if content.blank?
end

event :validate_role_enabling, :validate, on: :save do
  illegal_roles = item_names - Auth.current_roles
  return if illegal_roles.empty?

  errors.add :content, "illegal roles: #{illegal_roles.to_sentence}" # LOCALIZE
end

event :clear_roles_cache, :prepare_to_store, before: :store_in_session do
  clear_roles
  Auth.update_always_cache nil
end

format :html do
  # permission change compared to super
  view :edit_inline, perms: :none, unknown: true, cache: :never, wrap: :slot do
    super()
  end

  def input_type
    :checkbox
  end

  def edit_success
    { reload: true }
  end

  def hidden_form_tags _action, opts
    "#{super} #{hidden_tags card: { type_id: SessionID }}"
  end

  def checkbox_input
    card.ensure_roles
    voo.show! :role_item_checkbox
    wrap_with :div, class: "pointer-checkbox-list" do
      account_dropdown
    end
  end

  def role_item_checkbox role_name
    haml :role_checkbox, id: "pointer-checkbox-#{role_name.to_name.key}",
                         checked: card.item_names.include?(role_name),
                         option_name: role_name
  end

  def account_dropdown_role_items
    Auth.current_roles.map { |role| role_item_checkbox role }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
card-mod-layout-0.16.0 set/right/enabled_roles.rb
card-mod-layout-0.15.6 set/right/enabled_roles.rb
card-mod-layout-0.15.5 set/right/enabled_roles.rb
card-mod-layout-0.15.4 set/right/enabled_roles.rb
card-mod-layout-0.15.3 set/right/enabled_roles.rb
card-mod-layout-0.15.2.pre1 set/right/enabled_roles.rb
card-mod-layout-0.15.1.1 set/right/enabled_roles.rb
card-mod-layout-0.15.1 set/right/enabled_roles.rb