Module: ActiveLeonardo::Leosca::Activeadmin
- Included in:
- Rails::Generators::LeoscaControllerGenerator
- Defined in:
- lib/generators/active_leonardo.rb
Constant Summary collapse
- ACTIVEADMIN_INDENT_SPACES =
25
Instance Method Summary collapse
- #attributes_to_aa_csv(attributes) ⇒ Object
- #attributes_to_aa_filter(attributes) ⇒ Object
- #attributes_to_aa_form(attributes) ⇒ Object
- #attributes_to_aa_index(attributes) ⇒ Object
- #attributes_to_aa_permit_params(attributes) ⇒ Object
- #attributes_to_aa_show(attributes) ⇒ Object
Instance Method Details
#attributes_to_aa_csv(attributes) ⇒ Object
215 216 217 |
# File 'lib/generators/active_leonardo.rb', line 215 def attributes_to_aa_csv(attributes) attributes.map{|attr| " # column(:#{attr.name})#{' ' * (ACTIVEADMIN_INDENT_SPACES-attr.name.size).abs}{|#{singular_table_name}| #{singular_table_name}.#{attr.name}}"}.join("\n") end |
#attributes_to_aa_filter(attributes) ⇒ Object
204 205 206 |
# File 'lib/generators/active_leonardo.rb', line 204 def attributes_to_aa_filter(attributes) attributes.map{|attr| " #filter :#{attr.name}"}.join("\n") end |
#attributes_to_aa_form(attributes) ⇒ Object
207 208 209 210 211 212 213 214 |
# File 'lib/generators/active_leonardo.rb', line 207 def attributes_to_aa_form(attributes) attributes.map do |attr| case attr.type when :date then " # f.input :#{attr.name}, as: :datepicker, input_html: { class: 'calendar' }" else " # f.input :#{attr.name}" end end.join("\n") end |
#attributes_to_aa_index(attributes) ⇒ Object
186 187 188 189 190 191 192 193 194 |
# File 'lib/generators/active_leonardo.rb', line 186 def attributes_to_aa_index(attributes) attributes.map do |attr| case attr.type when :references, :belongs_to then " # column(:#{attr.name})" when :boolean then " # column(:#{attr.name})#{' ' * (ACTIVEADMIN_INDENT_SPACES-attr.name.size).abs}{|#{singular_table_name}| status_tag #{singular_table_name}.#{attr.name}}" else " # column(:#{attr.name})#{' ' * (ACTIVEADMIN_INDENT_SPACES-attr.name.size).abs}{|#{singular_table_name}| #{singular_table_name}.#{attr.name}}" end end.join("\n") end |
#attributes_to_aa_permit_params(attributes) ⇒ Object
178 179 180 181 182 183 184 185 |
# File 'lib/generators/active_leonardo.rb', line 178 def attributes_to_aa_permit_params(attributes) attributes.map do |attr| case attr.type when :references, :belongs_to then ":#{attr.name}_id" else ":#{attr.name}" end end.join(', ') end |
#attributes_to_aa_show(attributes) ⇒ Object
195 196 197 198 199 200 201 202 203 |
# File 'lib/generators/active_leonardo.rb', line 195 def attributes_to_aa_show(attributes) attributes.map do |attr| case attr.type when :references, :belongs_to then " # row(:#{attr.name})" when :boolean then " # row(:#{attr.name})#{' ' * (ACTIVEADMIN_INDENT_SPACES-attr.name.size).abs}{|#{singular_table_name}| status_tag #{singular_table_name}.#{attr.name}}" else " # row(:#{attr.name})#{' ' * (ACTIVEADMIN_INDENT_SPACES-attr.name.size).abs}{|#{singular_table_name}| #{singular_table_name}.#{attr.name}}" end end.join("\n") end |