activeadmin_addons 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 08298387fcd5e88323355d9e9d4d095354d3b01e
4
+ data.tar.gz: 82399ca1448a63107810b152b4224b8f1abebc61
5
+ SHA512:
6
+ metadata.gz: 762a3cc2c799e6e6dd8b0a7caed2f1d3aaf4459ff97d19eaff67ee31d15d0637904b7b6d7cb72fc6e91a538c6396ac6eacbc07b84702cfc5becf605d2eeb12f2
7
+ data.tar.gz: 0c5261186790af88e9ca686363d00cf58236c884a1823dc050e29ed3e9ae7acfaf7f4bf0bf0de833394414c4a54034006276e418f0fa8b2148a09369e701d927
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ActiveadminAddons'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ Bundler::GemHelper.install_tasks
18
+
@@ -0,0 +1 @@
1
+ #= require ./select2
@@ -0,0 +1,14 @@
1
+ #= require select2
2
+ #= require_self
3
+
4
+ $ ->
5
+ $('.select2-tags').each (i, el) ->
6
+ $(el).select2
7
+ width: '80%'
8
+ tags: $(el).data('collection')
9
+
10
+ $('select:not(.default-select)').each (i, el) ->
11
+ if $(el).closest('.filter_form').length > 0
12
+ $(el).select2(width: 'resolve')
13
+ else
14
+ $(el).select2(width: '80%')
@@ -0,0 +1 @@
1
+ @import "select2";
@@ -0,0 +1,8 @@
1
+ class TagsInput < Formtastic::Inputs::StringInput
2
+ def input_html_options
3
+ opts = {}
4
+ opts[:class] = "select2-tags"
5
+ opts["data-collection"] = (@options[:collection] || []).to_json
6
+ super.merge opts
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveadminAddons
2
+ end
3
+
4
+ require_relative './activeadmin_addons/engine'
@@ -0,0 +1,42 @@
1
+ module ActiveAdminAddons
2
+ DEFAULT_BOOLEAN_TRUE = '&#x2714;'
3
+ DEFAULT_BOOLEAN_FALSE = '&#x2717;'
4
+
5
+ module BoolValues
6
+ class << self
7
+ def bool_value(model, attribute)
8
+ if model[attribute]
9
+ i18n_lookup(model, attribute, 'true_value', DEFAULT_BOOLEAN_TRUE)
10
+ else
11
+ i18n_lookup(model, attribute, 'false_value', DEFAULT_BOOLEAN_FALSE)
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def i18n_lookup(model, attribute, key, last_default)
18
+ model_name = model.class.model_name.i18n_key
19
+
20
+ model_i18n = "activeadmin.addons.boolean.models.#{model_name}.#{key}"
21
+ default_i18n = "activeadmin.addons.boolean.default.#{key}"
22
+
23
+ I18n.t(model_i18n, default: I18n.t(default_i18n, default: last_default)).html_safe
24
+ end
25
+ end
26
+ end
27
+
28
+ module ::ActiveAdmin
29
+ module Views
30
+ class TableFor
31
+ def bool_column(attribute)
32
+ column(attribute) { |model| BoolValues.bool_value(model, attribute) }
33
+ end
34
+ end
35
+ class AttributesTable
36
+ def bool_row(attribute)
37
+ row(attribute) { |model| BoolValues.bool_value(model, attribute) }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,27 @@
1
+ module ActiveAdminAddons
2
+ module PaperclipImage
3
+ class << self
4
+ def image(context, model, attribute, options)
5
+ img = model.send(attribute)
6
+ raise 'you need to pass a paperclip image attribute' unless img.respond_to?(:url)
7
+ style = options.fetch(:style, :original)
8
+ context.image_tag(img.url(style)) if img.exists?
9
+ end
10
+ end
11
+ end
12
+
13
+ module ::ActiveAdmin
14
+ module Views
15
+ class TableFor
16
+ def image_column(attribute, options = {})
17
+ column(attribute) { |model| PaperclipImage.image(self, model, attribute, options) }
18
+ end
19
+ end
20
+ class AttributesTable
21
+ def image_row(attribute, options = {})
22
+ row(attribute) { |model| PaperclipImage.image(self, model, attribute, options) }
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ module ActiveAdminAddons
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ require 'select2-rails'
5
+ initializer "set boolean values addon" do |app|
6
+ require_relative './set_datepicker'
7
+ require_relative './addons/bool_values'
8
+ require_relative './addons/paperclip_image'
9
+ app.config.assets.precompile += %w(select.scss)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module ::Formtastic
2
+ module Helpers
3
+ module InputHelper
4
+
5
+ alias_method :original_default_input_type, :default_input_type
6
+
7
+ def default_input_type(method, options = {})
8
+ input_type = original_default_input_type(method, options)
9
+ input_type = :datepicker if input_type == :date_select
10
+ input_type
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveadminAddons
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :activeadmin_addons do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activeadmin_addons
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Platanus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: select2-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Set of addons to help with the activeadmin ui
98
+ email:
99
+ - contact@platan.us
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - app/assets/javascripts/activeadmin_addons/all.js.coffee
105
+ - app/assets/javascripts/activeadmin_addons/select2.js.coffee
106
+ - app/assets/stylesheets/activeadmin_addons/all.css.scss
107
+ - app/inputs/tags_input.rb
108
+ - lib/activeadmin_addons/addons/bool_values.rb
109
+ - lib/activeadmin_addons/addons/paperclip_image.rb
110
+ - lib/activeadmin_addons/engine.rb
111
+ - lib/activeadmin_addons/set_datepicker.rb
112
+ - lib/activeadmin_addons/version.rb
113
+ - lib/activeadmin_addons.rb
114
+ - lib/tasks/activeadmin_addons_tasks.rake
115
+ - MIT-LICENSE
116
+ - Rakefile
117
+ homepage: https://github.com/platanus/activeadmin_addons
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.0.14
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Set of addons to help with the activeadmin ui
141
+ test_files: []