Module: ActiveScaffold::Bridges::Bitfields::BitfieldsBridge
- Defined in:
- lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb
Instance Method Summary collapse
Instance Method Details
#_setup_bitfields ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb', line 18 def _setup_bitfields return unless model.respond_to?(:bitfields) && model.bitfields.present? model.bitfields.each do |column_name, | columns = .keys.sort_by { |column| self.columns[column].weight } %i[create update show subform].each do |action| next unless actions.include? action if send(action).columns.include? column_name send(action).columns.exclude column_name send(action).columns.add_subgroup(column_name) { |group| group.add(*columns) } else send(action).columns.exclude(*columns) end end end end |
#initialize(model_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb', line 5 def initialize(model_id) super return unless model.respond_to?(:bitfields) && model.bitfields.present? model.bitfields.each_value do || columns << .keys .each_key.with_index(1) do |column, i| columns[column].form_ui = :checkbox columns[column].weight = 1000 + i end end end |