Sha256: 545ce6ae4ec0fec2c37e72fbb891a5713c151b15d636414dc8c1ca015b81424b
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
module ActiveAdminAddons class BoolBuilder < CustomBuilder DEFAULT_BOOLEAN_TRUE = '✔' DEFAULT_BOOLEAN_FALSE = '✗' def render if data i18n_lookup('true_value', DEFAULT_BOOLEAN_TRUE) else i18n_lookup('false_value', DEFAULT_BOOLEAN_FALSE) end end private def i18n_lookup(key, last_default) model_name = model.class.model_name.i18n_key model_i18n = "activeadmin.addons.boolean.models.#{model_name}.#{key}" default_i18n = "activeadmin.addons.boolean.default.#{key}" I18n.t(model_i18n, default: I18n.t(default_i18n, default: last_default)).html_safe end end module BoolValues module ::ActiveAdmin module Views class TableFor def bool_column(*args, &block) column(*args) { |model| BoolBuilder.render(self, model, *args, &block) } end end class AttributesTable def bool_row(*args, &block) row(*args) { |model| BoolBuilder.render(self, model, *args, &block) } end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems