Sha256: 05c6b784a91c2ec8641da0efb27645a8ababc6f7600f79224c03d4d284d19522
Contents?: true
Size: 1.21 KB
Versions: 9
Compression:
Stored size: 1.21 KB
Contents
module ActiveScaffold module Bridges class Bitfields module BitfieldsBridge def initialize(model_id) super return unless model.respond_to?(:bitfields) && model.bitfields.present? model.bitfields.each_value do |options| columns << options.keys options.each_key.with_index(1) do |column, i| columns[column].form_ui = :checkbox columns[column].weight = 1000 + i end end end def _setup_bitfields return unless model.respond_to?(:bitfields) && model.bitfields.present? model.bitfields.each do |column_name, options| columns = options.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 end end end end
Version data entries
9 entries across 9 versions & 1 rubygems