Introduction¶ ↑
This is a simple gem for Active Admin that just adds support for Time picker.
It supports both ActiveRecord for relational databases and Mongoid for MongoDB schemaless database.
For Date/Time picker widget, see just-datetime-picker.
Usage¶ ↑
Code samples¶ ↑
Here comes a quick code sample. Sorry, currently no detailed docs.
That should create nice date/time picker for User#notify_at.
Associated column in the DB should can have type of :time. It has to be nullable.
To delete previously stored time just make all fields blank (hour and minute).
Migration (if you use ActiveRecord)¶ ↑
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.time :notify_at # You can also use :integer with :limit => 6 t.timestamps end end end
Model¶ ↑
ActiveRecord¶ ↑
class User < ActiveRecord::Base just_define_time_picker :notify_at, :add_to_attr_accessible => true validates :notify_at, :presence => true end
Mongoid¶ ↑
class User include Mongoid::Document field :notify_at, type: Time just_define_time_picker :notify_at, :add_to_attr_accessible => true end
You must place “mongoid” gem BEFORE “just-time-picker” gem in your Gemfile!
ActiveAdmin¶ ↑
ActiveAdmin.register User do form do |f| f.inputs do f.input :notify_at, :as => :just_time_picker end f.buttons end end
Installation¶ ↑
Code itself¶ ↑
Gems¶ ↑
The gems are hosted at Rubygems.org. Make sure you’re using the latest version of rubygems:
$ gem update --system
Then you can install the gem as follows:
$ gem install just-time-picker
Bundler¶ ↑
Add to your Gemfile:
gem "just-time-picker"
and then type:
bundle install
From the GitHub source¶ ↑
The source code is available at github.com/saepia/just-time-picker. You can either clone the git repository or download a tarball or zip file. Once you have the source, you can unpack it and use from wherever you downloaded.
Assets¶ ↑
CSS¶ ↑
If you use Rails >= 3.1 AND ActiveAdmin >= 0.5.0 just add this line to active_admin.css.scss
@import "just_time_picker/base";
Otherwise, just manually append the code from this file to your CSS stylesheet.
In ActiveAdmin 0.4.x you must strip body.active_admin from CSS declarations.
Additional info¶ ↑
Available locales¶ ↑
en, pl, zh-CN
Versions known to work¶ ↑
Code was tested with:
-
ActiveAdmin 0.4.4, 0.5.0 and 0.5.1,
-
formtastic 2.2.1,
-
Ruby on Rails 3.2.8, 3.2.11.
License¶ ↑
This code is licensed under GPLv3.
Authors¶ ↑
ChangeLog¶ ↑
0.0.2 (March 2, 2013)¶ ↑
-
Added xmlschema and iso8601 methods to Time class (Marcin Lewandowski)
0.0.1 (February 23, 2013)¶ ↑
-
Initial release based on just-datetime-picker 0.0.6 (Marcin Lewandowski)