Sha256: 4259484328020e0ba8118a996a23b524c8a44e206620cc19c28da7c950ef53c2
Contents?: true
Size: 1.14 KB
Versions: 7
Compression:
Stored size: 1.14 KB
Contents
module EgovUtils module GridHelper def type_for_grid(type) case type when 'integer', 'float' 'Number' when 'string', 'list' 'String' when 'date', 'datetime' 'Date' when 'boolean' 'Boolean' else raise "Undefined grid type for type #{type}" end end def field_for_grid(attribute) s = "\'" s << attribute.name s << '\': {path: "' s << attribute.path s << '", type: ' s << type_for_grid(attribute.type) s << '}' s end def column_for_grid(grid, attribute) s = "{" s << "field: '#{attribute.name}'" s << ", title: '#{I18n.t('model_attributes.'+grid.model_i18n_key.to_s+'.'+attribute.name)}'" s << ", columnTemplate: '<a href=\"#{polymorphic_path(grid.schema.model)}/{id}\">{#{attribute.name}}</div>'" if attribute.name == grid.schema.main_attribute_name if attribute.type == 'list' s << ", format: ( (value) -> I18n.t(value, {scope: 'activerecord.attributes.#{attribute.model.model_name.i18n_key}.#{attribute.name.to_s.pluralize}'}) ) " end s << "}" end end end
Version data entries
7 entries across 7 versions & 1 rubygems