activeadmin_addons 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d435121eb4c55a5255387dd87b0925f82893fa1
4
- data.tar.gz: 88921f3c132692be19b644bfe5d8b9cf9eb26289
3
+ metadata.gz: 299d75cbf47b959faf497c219e4f74a9694ebfa2
4
+ data.tar.gz: eaf84b9acba3ea0d7ee9fc659d1ea8574f4ecb42
5
5
  SHA512:
6
- metadata.gz: 43e3d2ada63e439b53a0e6b785e1d275a821ae8000362e6823a8a5f34b4f7728d244f20a113b13266a9ec8cebc84748c9b9bce4af0e27f523735c95aa3d6c752
7
- data.tar.gz: d15d77617e7c57f0037d8c3db605dfa5a2d689fcfaab749740a8904498f077b88cb245d62ff506e9999bb079a98ad94c99fc2215142777a7c4a185223007fca9
6
+ metadata.gz: b18c506b07048fd81a7bc09e9754d539ac64a06e7d7276491a94f250df030a1183aca13f43fcbd31fa2b5b63ddc4c570618c4401c73f6cb12e5c4b66ad053538
7
+ data.tar.gz: 47869f7caa523e2bb369b828d0443b205cec175dc9f4818751d7a21dddcad3e42af0c67b23017813f944c45af1be576b7a46941683564809aeeaab2bcfcfe225
@@ -1,2 +1,3 @@
1
1
  #= require ./select2
2
+ #= require ./date-time-picker
2
3
  #= require ./color-picker
@@ -0,0 +1,25 @@
1
+ //= require jquery.xdan.datetimepicker.full
2
+
3
+ $(function() {
4
+ setupDateTimePicker(document);
5
+
6
+ $(document).on('has_many_add:after', '.has_many_container', function(event, fieldset) {
7
+ return setupDateTimePicker(fieldset);
8
+ });
9
+
10
+ function setupDateTimePicker(container) {
11
+ var defaults, entries;
12
+ defaults = {
13
+ formatDate: 'y-m-d',
14
+ format: 'Y-m-d H:i',
15
+ allowBlank: true,
16
+ defaultSelect: false,
17
+ validateOnBlur: false
18
+ };
19
+ entries = $(container).find('input.date-time-picker');
20
+ return entries.each(function(index, entry) {
21
+ var options = $(entry).data('picker-options');
22
+ return $(entry).datetimepicker($.extend(defaults, options));
23
+ });
24
+ }
25
+ });
@@ -2,7 +2,6 @@
2
2
  //= require_self
3
3
 
4
4
  $(function() {
5
-
6
5
  setupSelect2(document);
7
6
 
8
7
  $(document).on('has_many_add:after', function(event, container){
@@ -31,7 +30,6 @@ $(function() {
31
30
  }
32
31
  });
33
32
 
34
-
35
33
  $('.select2-ajax', container).each(function(i, el) {
36
34
  var url = $(el).data('url');
37
35
  var fields = $(el).data('fields');
@@ -1,4 +1,5 @@
1
1
  @import "select2";
2
+ @import "jquery.xdan.datetimepicker";
2
3
  @import "../palette-color-picker";
3
4
 
4
5
  .filter_range_select {
@@ -26,3 +27,9 @@
26
27
  .palette-color-picker-bubble {
27
28
  z-index: 10;
28
29
  }
30
+
31
+ input[type=text] {
32
+ &.date-time-picker {
33
+ width: 110px;
34
+ }
35
+ }
@@ -0,0 +1,72 @@
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.
22
+
23
+ class DateTimePickerInput < Formtastic::Inputs::StringInput
24
+ mattr_accessor :default_datetime_picker_options do
25
+ {}
26
+ end
27
+
28
+ mattr_accessor :format do
29
+ '%Y-%m-%d %H:%M'
30
+ end
31
+
32
+ def input_html_options(input_name = nil)
33
+ opts = {}
34
+ opts[:class] = [options[:class], 'date-time-picker'].compact.join(' ')
35
+ opts[:data] ||= {}
36
+ opts[:data].merge!(picker_options: datetime_picker_options)
37
+ opts[:value] ||= input_value(input_name)
38
+ opts[:maxlength] = 19
39
+ opts
40
+ end
41
+
42
+ def input_value(input_name = nil)
43
+ v = object.public_send(input_name || method)
44
+
45
+ if v.is_a?(Time)
46
+ return DateTime.new(v.year, v.month, v.day, v.hour, v.min, v.sec).strftime(format)
47
+ end
48
+
49
+ v.to_s
50
+ end
51
+
52
+ def datetime_picker_options
53
+ @datetime_picker_options ||= begin
54
+ opts = options.fetch(:picker_options, {})
55
+ opts = Hash[opts.map { |k, v| [k.to_s.camelcase(:lower), v] }]
56
+ default_picker_options.merge(opts)
57
+ end
58
+ end
59
+
60
+ protected
61
+
62
+ def default_picker_options
63
+ res = default_datetime_picker_options.map do |k, v|
64
+ if v.respond_to?(:call) || v.is_a?(Proc)
65
+ [k, v.call]
66
+ else
67
+ [k, v]
68
+ end
69
+ end
70
+ Hash[res]
71
+ end
72
+ end
@@ -22,17 +22,10 @@ module ActiveAdminAddons
22
22
  value = I18n.t("default.#{key}", default: last_default, scope: scope) if value.empty?
23
23
 
24
24
  value.html_safe
25
-
26
- #
27
- # model_i18n = "activeadmin.addons.boolean.models.#{model_name}.#{key}"
28
- # default_i18n = "activeadmin.addons.boolean.default.#{key}"
29
- #
30
- # I18n.t(model_i18n, default: I18n.t(default_i18n, default: last_default)).html_safe
31
25
  end
32
26
  end
33
27
 
34
28
  module BoolValues
35
-
36
29
  module ::ActiveAdmin
37
30
  module Views
38
31
  class TableFor
@@ -1,6 +1,5 @@
1
1
  module ActiveAdminAddons
2
2
  class EnumBuilder < CustomBuilder
3
-
4
3
  def render
5
4
  @is_enum = false
6
5
  @is_enum = :enumerize if data.is_a?('Enumerize::Value'.constantize)
@@ -14,7 +13,6 @@ module ActiveAdminAddons
14
13
  def display_data
15
14
  @is_enum == :enumerize ? data.text : data
16
15
  end
17
-
18
16
  end
19
17
 
20
18
  module ::ActiveAdmin
@@ -2,7 +2,9 @@ module ActiveAdminAddons
2
2
  module Rails
3
3
  class Engine < ::Rails::Engine
4
4
  require 'select2-rails'
5
- initializer "set boolean values addon" do |app|
5
+ require 'xdan-datetimepicker-rails'
6
+
7
+ initializer "initialize addons" do |app|
6
8
  require_relative './support/custom_builder'
7
9
  require_relative './addons/bool_values'
8
10
  require_relative './addons/paperclip_image'
@@ -13,7 +15,7 @@ module ActiveAdminAddons
13
15
  require_relative './addons/list'
14
16
  require_relative './support/enumerize_formtastic_support'
15
17
  require_relative './support/set_datepicker'
16
- app.config.assets.precompile += %w(select.scss)
18
+ app.config.assets.precompile += %w(select.scss)
17
19
  end
18
20
  end
19
21
  end
@@ -6,7 +6,7 @@ module ActiveAdminAddons
6
6
  alias_method_chain :input, :ransack
7
7
  end
8
8
 
9
- def input_with_ransack(method, options={})
9
+ def input_with_ransack(method, options = {})
10
10
  if object.is_a?(::Ransack::Search)
11
11
  klass = object.klass
12
12
 
@@ -1,3 +1,3 @@
1
1
  module ActiveadminAddons
2
- VERSION = "0.6.4"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_addons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platanus
8
+ - Julio García
9
+ - Emilio Blanco
10
+ - Leandro Segovia
8
11
  autorequire:
9
12
  bindir: bin
10
13
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
14
+ date: 2016-03-07 00:00:00.000000000 Z
12
15
  dependencies:
13
16
  - !ruby/object:Gem::Dependency
14
17
  name: railties
@@ -38,6 +41,20 @@ dependencies:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
43
  version: 3.5.9
44
+ - !ruby/object:Gem::Dependency
45
+ name: xdan-datetimepicker-rails
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: 2.5.1
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: 2.5.1
41
58
  - !ruby/object:Gem::Dependency
42
59
  name: rails
43
60
  requirement: !ruby/object:Gem::Requirement
@@ -236,7 +253,10 @@ dependencies:
236
253
  version: '0'
237
254
  description: Set of addons to help with the activeadmin ui
238
255
  email:
239
- - contact@platan.us
256
+ - rubygems@platan.us
257
+ - julioggonz@gmail.com
258
+ - emilioeduardob@gmail.com
259
+ - ldlsegovia@gmail.com
240
260
  executables: []
241
261
  extensions: []
242
262
  extra_rdoc_files: []
@@ -349,11 +369,13 @@ files:
349
369
  - app/assets/images/fileicons/file_extension_zip.png
350
370
  - app/assets/javascripts/activeadmin_addons/all.js.coffee
351
371
  - app/assets/javascripts/activeadmin_addons/color-picker.js
372
+ - app/assets/javascripts/activeadmin_addons/date-time-picker.js
352
373
  - app/assets/javascripts/activeadmin_addons/select2.js
353
374
  - app/assets/javascripts/palette-color-picker.js
354
375
  - app/assets/stylesheets/activeadmin_addons/all.scss
355
376
  - app/assets/stylesheets/palette-color-picker.scss
356
377
  - app/inputs/color_picker_input.rb
378
+ - app/inputs/date_time_picker_input.rb
357
379
  - app/inputs/nested_select_input.rb
358
380
  - app/inputs/range_select_input.rb
359
381
  - app/inputs/search_select_input.rb