Skip to content
This repository was archived by the owner on Feb 20, 2018. It is now read-only.

Latest commit

 

History

History
154 lines (99 loc) · 2.48 KB

File metadata and controls

154 lines (99 loc) · 2.48 KB

Active Admin Extra

Description

Extra candies for your ActiveAdmin apps.

Installation

Add activeadmin-extra to your Gemfile:

   gem 'activeadmin-extra', github: 'stefanoverna/activeadmin-extra'

Replace active_admin stylesheets and javascripts with:

   @import "active_admin/extra/base"
   #= require active_admin/extra

Custom inputs usage

Spice up your admin forms with these brand new inputs:

Title

String field with a larger font.

   ActiveAdmin.register Page do

     form do |f|
       f.input :name, :as => :title
     end

   end

Chosen

The infamous jquery combobox. To use add to your Gemfile:

   gem 'chosen-rails', group: :assets

and then in your assets:

   #= require chosen-jquery
   @import "chosen"

Usage:

   ActiveAdmin.register Product do

     form do |f|
       f.input :material, as: :chosen, create_option: true
     end

   end

For the create_option alternative use koenpunt's fork.

Measure

Number with unit of measure symbol

   ActiveAdmin.register Product do

     form do |f|
       f.input :price, :as => :measure, :symbol => '€'
     end

   end

Numbers set

A row of numeric inputs side by side. Basic usage:

   ActiveAdmin.register Box do

     form do |f|
       f.input :height, :as => :numbers_set # default displays a height_min and a height_max field
     end

   end

Multiple options:

   ActiveAdmin.register Box do

     form do |f|
       f.input :height, :as => :numbers_set, :numbers_set => [:mm, :in, :ft]
     end

   end

Google Map Address

A simple way to find latitude and longitude values trhough a google map. Basic usage:

Requires the following in config/initializers/active_admin.rb

  ActiveAdmin.application.register_javascript "https://maps.googleapis.com/maps/api/js?sensor=false"

Add address (or any other name), latitude end longitude string column to your model via migration

  def change
    add_column :apartments, :address, :string
    add_column :apartments, :latitude, :string
    add_column :apartments, :longitude, :string
  end

Configure your active admin model file

  /app/admin/apartement.rb

  form do |f|
    f.inputs :logistic do
      f.input :address, as: :map_address
    end
  end

Copyright

Copyright (c) 2012 Stefano Verna, Cantiere Creativo See the file LICENSE.txt for details.