activeadmin_globalize_inputs 0.0.2

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: f3d2024b0f083e5ea1a940ec6fd3a7ff7d5a2091
4
+ data.tar.gz: e483d8a19b361af97140888816ca72394c95213d
5
+ SHA512:
6
+ metadata.gz: e857ff25d1cef05cade4531981b1291b44bf071742679b370815c3a757845425af82f562590f1988e7a5ab6c8983f85e31f53dd5163d212ce1b39bb82afe90a6
7
+ data.tar.gz: bbeb7818204b2ecf2586305c8e56b77d63687e5652e798c10eaaadaeb23c56822cef6d9e77dd4b589d86c4491f6cda2750081ab22f398bfc882cd5c2e8fd2715
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ..gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Slotos
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ This small hack implements has_many friendly Globalize3 helper for ActiveAdmin.
2
+
3
+ Admittedly it generates structure that [jQueryUI tabs()](http://jqueryui.com/demos/tabs/) expect. However the whole idea is pretty simple and you should be able to change it to suit your needs.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ActiveAdmin-Globalize3-inputs'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage by example
16
+
17
+ ```ruby
18
+ ActiveAdmin.register Gallery do
19
+ form do |f|
20
+ f.globalize_inputs :translations do |lf|
21
+ lf.inputs do
22
+ lf.input :title
23
+ lf.input :description
24
+
25
+ lf.input :locale, :as => :hidden
26
+ end
27
+ end
28
+
29
+ f.has_many :photos do |photo|
30
+ photo.inputs do
31
+ photo.input :image, :as => :file
32
+ end
33
+
34
+ photo.globalize_inputs :translations do |lp|
35
+ lp.inputs do
36
+ lp.input :description
37
+
38
+ lp.input :locale, :as => :hidden
39
+ end
40
+ end
41
+ end
42
+
43
+ f.buttons
44
+ end
45
+ end
46
+ ```
47
+
48
+ As you can see, there's no special option for locales. The list is taken from `I18n.available_locales`, so you'd probably want to define the locales your application works with somewhere.
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork
53
+ 2. Invent better name
54
+ 3. Improve
55
+ 4. Enjoy
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |gem|
3
+ gem.authors = ["Slotos", "Lumos Labs"]
4
+ gem.email = ["info@lumoslabs.com"]
5
+ gem.description = %q{Implementation of globalize_fields - ActiveRecord-friendly globalize helper for ActiveAdmin.}
6
+ gem.summary = %q{globalize helper for ActiveAdmin.}
7
+ gem.homepage = "https://github.com/lumoslabs/activeadmin_globalize_inputs"
8
+
9
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
10
+ gem.files = `git ls-files`.split("\n")
11
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
12
+ gem.name = "activeadmin_globalize_inputs"
13
+ gem.require_paths = ["lib"]
14
+ gem.version = '0.0.2'
15
+
16
+ gem.add_dependency "globalize"
17
+ gem.add_dependency "activeadmin"
18
+ end
@@ -0,0 +1,8 @@
1
+ module ActiveAdmin
2
+ class FormBuilder
3
+ def globalize_inputs(*args, &proc)
4
+ content = with_new_form_buffer { super }
5
+ form_buffers.last << content.html_safe
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,2 @@
1
+ require 'formtastic/globalize_inputs'
2
+ require 'active_admin/globalize_inputs'
@@ -0,0 +1,26 @@
1
+ module Formtastic
2
+ class FormBuilder
3
+ def globalize_inputs(*args, &proc)
4
+ index = options[:child_index] || "#{self.object.class.to_s}-#{self.object.object_id}"
5
+ linker = ActiveSupport::SafeBuffer.new
6
+ fields = ActiveSupport::SafeBuffer.new
7
+ ::I18n.available_locales.each do |locale|
8
+ linker << self.template.content_tag(:li,
9
+ self.template.content_tag(:a,
10
+ ::I18n.t("translation.#{locale}"),
11
+ :href => "#lang-#{locale}-#{index}"
12
+ )
13
+ )
14
+ fields << self.template.content_tag(:div,
15
+ self.semantic_fields_for(*(args.dup << self.object.translation_for(locale)), &proc),
16
+ :id => "lang-#{locale}-#{index}"
17
+ )
18
+ end
19
+
20
+ linker = self.template.content_tag(:ul, linker, :class => "language-selection")
21
+
22
+ html = self.template.content_tag(:div, linker + fields, :class => "language-tabs-#{index}")
23
+ html << self.template.javascript_tag("$('.language-tabs-#{index}').tabs();")
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activeadmin_globalize_inputs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Slotos
8
+ - Lumos Labs
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-06-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: globalize
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: activeadmin
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: Implementation of globalize_fields - ActiveRecord-friendly globalize
43
+ helper for ActiveAdmin.
44
+ email:
45
+ - info@lumoslabs.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - Gemfile
52
+ - LICENSE
53
+ - README.md
54
+ - Rakefile
55
+ - activeadmin_globalize_inputs.gemspec
56
+ - lib/active_admin/globalize_inputs.rb
57
+ - lib/activeadmin_globalize_inputs.rb
58
+ - lib/formtastic/globalize_inputs.rb
59
+ homepage: https://github.com/lumoslabs/activeadmin_globalize_inputs
60
+ licenses: []
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.3
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: globalize helper for ActiveAdmin.
82
+ test_files: []