active_admin_datetimepicker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 95942036891e999af2dd97323018fae6b4df523f
4
+ data.tar.gz: 2c3b5d594b17c4616e20503dc48154c2e5c19a07
5
+ SHA512:
6
+ metadata.gz: c70396c059789c4abc2a63527aaec2a38c0c33a6a79ddf006317a57878e82ebc105a2e5aad7d02e7f87e32f7f2ab530e4717f065b4b6107d52799d12471f1f9d
7
+ data.tar.gz: b65f6ca73e3e66d3e35b55cdfece5e09055cdee3430bcea0111401a7184eb02eb0455eb25e1a853b4abd4e6865cc9b71a347eb24f1c716bbe352a075803d0787
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in active_admin_datetimepicker.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Igor Fedoronchuk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # ActiveAdminDatetimepicker
2
+
3
+ Adds ability to use XDSoft's DateTime picker as the date_time_picker input for forms, and date_time_range for filters
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'active_admin_datetimepicker'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install active_admin_datetimepicker
20
+
21
+ ## Usage
22
+
23
+ Plugin offers the `date_time_picker` input and `date_time_range` filter , which use the [XDSoft DateTime Picker gem](https://github.com/shekibobo/xdan-datetimepicker-rails).
24
+ The `date_time_picker` input accepts many of the options available to the standard jQueryUI Datepicker. For example:
25
+
26
+ JS asset
27
+ ```//= require active_admin_datetimepicker```
28
+
29
+ CSS
30
+ ```@import "active_admin_datetimepicker";```
31
+
32
+
33
+ ```ruby
34
+ form do |f|
35
+ f.input :starts_at, as: :datepicker, datepicker_options: { min_date: "2013-10-8", max_date: "+3D" }
36
+ f.input :ends_at, as: :datepicker, datepicker_options: { min_date: 3.days.ago.to_date, max_date: "+1W +5D" }
37
+ end
38
+ ```
39
+
40
+ ```ruby
41
+ filter :created_at, as: :date_time_range
42
+ ```
43
+
44
+ See [the datetimepicker documentation for more details](http://xdsoft.net/jqplugins/datetimepicker/).
45
+
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it ( https://github.com/[my-github-username]/active_admin_datetimepicker/fork )
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,20 @@
1
+ #= require jquery.xdan.datetimepicker
2
+
3
+ @setupDateTimePicker = (container) ->
4
+ defaults = {
5
+ formatDate: 'y-m-d',
6
+ format: 'Y-m-d H:i',
7
+ allowBlank: true,
8
+ defaultSelect: false,
9
+ validateOnBlur: false
10
+ }
11
+
12
+ entries = $(container).find('input.date-time-picker')
13
+ entries.each (index, entry) ->
14
+ options = $(entry).data 'datepicker-options'
15
+ $(entry).datetimepicker $.extend(defaults, options)
16
+
17
+ $ ->
18
+ setupDateTimePicker $('body')
19
+ $(document).on 'has_many_add:after', '.has_many_container', (e, fieldset) ->
20
+ setupDateTimePicker fieldset
@@ -0,0 +1,47 @@
1
+ @import "jquery.xdan.datetimepicker";
2
+
3
+ form.filter_form {
4
+ .filter_form_field {
5
+ &.filter_date_time_range {
6
+ .seperator {
7
+ display: inline-block;
8
+ text-align: center;
9
+ width: $filter-field-seperator-width;
10
+ }
11
+
12
+ input[type=text] {
13
+ width: $side-by-side-filter-input-width - 2;
14
+ }
15
+ }
16
+ }
17
+ }
18
+
19
+
20
+ div.xdsoft_datetimepicker {
21
+ .xdsoft_label i:hover,
22
+ .xdsoft_today_button:hover,
23
+ .xdsoft_next:hover,
24
+ .xdsoft_prev:hover {
25
+ background-color: #666;
26
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAeCAYAAADaW7vzAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHht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A4pYkzenOxXUbvZcWz7E8ykRMnIHGX1XPl+1m2vPYpL+2qdb8CDAARlKFEz/ZVkAAAAABJRU5ErkJggg==);
27
+ }
28
+ .xdsoft_label i:hover {
29
+ background-position: -92px -19px;
30
+ }
31
+ .xdsoft_today_button:hover {
32
+ background-position: -70px 0;
33
+ }
34
+ .xdsoft_next:hover {
35
+ background-position: 0 0;
36
+ }
37
+ .xdsoft_prev:hover {
38
+ background-position: -20px 0;
39
+ }
40
+ .xdsoft_timepicker .xdsoft_next:hover {
41
+ background-position: -40px -15px;
42
+ }
43
+ .xdsoft_timepicker .xdsoft_prev:hover{
44
+ background-position: -40px 0;
45
+ }
46
+ }
47
+
@@ -0,0 +1,14 @@
1
+ require "activeadmin"
2
+ require "xdan-datetimepicker-rails"
3
+ require "active_admin_datetimepicker/version"
4
+ require "active_admin_datetimepicker/inputs/date_time_picker_input"
5
+ require "active_admin_datetimepicker/inputs/filters/date_time_range_input"
6
+
7
+ module ActiveAdminDatetimepicker
8
+ module Rails
9
+ class Engine < ::Rails::Engine
10
+
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,28 @@
1
+ module ActiveAdmin
2
+ module Inputs
3
+ class DateTimePickerInput < ::Formtastic::Inputs::StringInput
4
+ def input_html_options
5
+ super.tap do |options|
6
+ options[:class] = [options[:class], "date-time-picker"].compact.join(' ')
7
+ options[:data] ||= {}
8
+ options[:data].merge! datepicker_options
9
+ options[:value] ||= value
10
+ end
11
+ end
12
+
13
+ def value
14
+ val = object.send(method)
15
+ return DateTime.new(val.year, val.month, val.day, val.hour, val.min).strftime("%Y-%m-%d %H:%M") if val.is_a?(Time)
16
+ return val if val.nil?
17
+ val.to_s
18
+ end
19
+
20
+ private
21
+ def datepicker_options
22
+ options = self.options.fetch(:datepicker_options, {})
23
+ options = Hash[options.map{ |k, v| [k.to_s.camelcase(:lower), v] }]
24
+ { datepicker_options: options }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ module ActiveAdmin
2
+ module Inputs
3
+ module Filters
4
+ class DateTimeRangeInput < DateRangeInput
5
+ include Base
6
+
7
+ def html_class
8
+ "date-time-picker"
9
+ end
10
+
11
+ def format
12
+ "%Y-%m-%d %H:%M"
13
+ end
14
+
15
+ def input_html_options(input_name = gt_input_name)
16
+ current_value = @object.public_send input_name
17
+ { size: 12,
18
+ class: html_class,
19
+ max: 10,
20
+ value: current_value.respond_to?(:strftime) ? current_value.strftime(format) : "" }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveAdminDatetimepicker
2
+ VERSION = "0.1.0"
3
+ end
data/screen/screen.png ADDED
Binary file
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_admin_datetimepicker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Igor Fedoronchuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xdan-datetimepicker-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Integrate jQuery xdan datetimepicker plugin to ActiveAdmin
56
+ email:
57
+ - fedoronchuk@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CODE_OF_CONDUCT.md
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - app/assets/javascripts/active_admin_datetimepicker.js.coffee
68
+ - app/assets/stylesheets/active_admin_datetimepicker.scss
69
+ - lib/active_admin_datetimepicker.rb
70
+ - lib/active_admin_datetimepicker/inputs/date_time_picker_input.rb
71
+ - lib/active_admin_datetimepicker/inputs/filters/date_time_range_input.rb
72
+ - lib/active_admin_datetimepicker/version.rb
73
+ - screen/screen.png
74
+ homepage: https://github.com/activeadmin-plugins/activeadmin_datetimepicker
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.6
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: datetimepicker extension for ActiveAdmin
98
+ test_files: []
99
+ has_rdoc: