Skip to content

Commit 56f41e3

Browse files
author
Gena Maly
committed
Readme fix
1 parent 0ba64f9 commit 56f41e3

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

README.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,66 @@ Use it as example and modify for your needs.
77

88
This is how it looks like
99

10-
![Step 1](/step_1.jpg)
10+
![Step 1](/screen/step_1.jpg)
1111

12-
![Step 2](/step_2.jpg)
12+
![Step 2](/screen/step_2.jpg)
13+
14+
15+
## Installation
16+
17+
Add this line to your application's Gemfile:
18+
19+
```ruby
20+
gem 'active_admin_date_range_preset', github: 'workgena/active_admin_date_range_preset'
21+
```
22+
23+
And then execute:
24+
25+
$ bundle install
26+
27+
Or install it yourself as:
28+
29+
$ gem install active_admin_date_range_preset
30+
31+
Include assests:
32+
33+
JS asset
34+
```//= require active_admin_date_range_preset```
35+
36+
CSS
37+
```@import "active_admin_date_range_preset";```
38+
39+
Your sidebar filters should now have link "Set Range"
40+
41+
## Usage
42+
43+
in New/Edit formtastic forms:
44+
45+
```ruby
46+
f.input :date_from, as: :date_time_picker, wrapper_html: { class: 'datetime_preset_pair', data: { show_time: 'true' } }
47+
f.input :date_to, as: :date_time_picker
48+
```
49+
50+
Input can be "as :string" or any other type compatible with <input type="text" />
51+
Main point is to set for ferst input-pair wrapper-class
52+
53+
```wrapper_html: { class: 'datetime_preset_pair' }```
54+
55+
input name('date_from' and 'date_to') can be named whatever your need
56+
57+
By default inputs fills with only date("2015-06-12"). If you need time add
58+
59+
```data: { show_time: 'true' }```
60+
61+
62+
You can set global defaults in your active_admin.js like this:
63+
64+
# End date will be full-day, not next.
65+
# Today true : 2015-06-12 - 2015-06-12
66+
# Today false: 2015-06-12 - 2015-06-13
67+
$.fn.date_range_ext_preset.defaults.date_to_human_readable = true
68+
69+
# Displa time
70+
# Today: 2015-06-12 00:00:00 - 2015-06-13 00:00:00
71+
# Today with human_readable=true: 2015-06-12 00:00:00 - 2015-16-12 23:59:59
72+
$.fn.date_range_ext_preset.defaults.show_time = true

vendor/assets/javascripts/active_admin_date_range_preset.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
return this.each (i, el) ->
4444
$this = $(el)
4545

46-
if $this.data('show-time').toString() == 'true'
46+
if typeof $this.data('show-time') != 'undefined' && $this.data('show-time').toString() == 'true'
4747
console.log $this.data('show-time')
4848
opts.show_time = true
4949

0 commit comments

Comments
 (0)