globalize3-inputs-bootstrap 0.1

Sign up to get free protection for your applications and to get access to all the features.
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,53 @@
1
+ Esta pequena gem facilita a criação do formulário para integração com a globalização da gem [Globalize3](https://github.com/svenfuchs/globalize3/)
2
+
3
+ O Globalize Inpunts Bootstrap é uma alteração da gem [ActiveAdmin-Globalize3-inputs](https://github.com/corewebdesign/ActiveAdmin-Globalize3-inputs)
4
+
5
+ ## Instalação
6
+
7
+ Adicione a seguinte linha ao seu Gemfile:
8
+
9
+ gem 'globalize3-inputs-bootstrap'
10
+
11
+ E execute o comando:
12
+
13
+ $ bundle install
14
+
15
+ ## Exemplo de uso
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
+ Como você pode ver, não há nenhuma opção especial para as localidades. A lista é tirada de `I18n.available_locales`, então você provavelmente vai querer definir as localidades em que seu aplicativo funciona.
48
+
49
+ ## Contribua
50
+
51
+ 1. Faça um 'Fork'
52
+ 2. Melhore
53
+ 3. Faça um 'Pull Request'
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/./version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Gullit Miranda"]
6
+ gem.email = ["gullitmiranda@requestdev.com.br"]
7
+ gem.description = %q{Implementation of globalize_fields - has_many friendly Globalize3 helper for ActiveAdmin.}
8
+ gem.summary = %q{Globalize3 helper for ActiveAdmin.}
9
+ gem.homepage = "https://github.com/gullitmiranda/globalize3-inputs-bootstrap"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "globalize3-inputs-bootstrap"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = GlobalizeAAInputs::VERSION
17
+
18
+ gem.add_dependency "globalize3"
19
+ gem.add_dependency "activeadmin"
20
+ end
@@ -0,0 +1,35 @@
1
+ module ActiveAdmin
2
+ module Views
3
+ class GlobalizeAttributesTable < ActiveAdmin::Views::AttributesTable
4
+ builder_method :globalize_attributes_table_for
5
+
6
+ def row(attr, &block)
7
+ I18n.available_locales.each_with_index do |locale, index|
8
+ @table << tr do
9
+ if index == 0
10
+ th :rowspan => I18n.available_locales.length do
11
+ header_content_for(attr)
12
+ end
13
+ end
14
+ td do
15
+ I18n.with_locale locale do
16
+ content_for(block || attr)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ protected
24
+
25
+ def default_id_for_prefix
26
+ 'attributes_table'
27
+ end
28
+
29
+ def default_class_name
30
+ 'attributes_table'
31
+ end
32
+
33
+ end
34
+ end
35
+ 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,35 @@
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
+
8
+ ::I18n.available_locales.each do |locale|
9
+ active_class = ::I18n.locale == locale ? "in active" : ""
10
+ linker << self.template.content_tag(:li,
11
+ self.template.content_tag(:a,
12
+ ::I18n.t("translation.#{locale}"),
13
+ :href => "#lang-#{locale}",
14
+ :"data-toggle" => "tab"
15
+ ),
16
+ class: "#{active_class}",
17
+ )
18
+ fields << self.template.content_tag(:div,
19
+ self.semantic_fields_for(*(args.dup << self.object.translation_for(locale)), &proc),
20
+ :id => "lang-#{locale}",
21
+ class: "tab-pane fade #{active_class}"
22
+ )
23
+ end
24
+
25
+ linker = self.template.content_tag(:ul, linker, class: "nav nav-tabs language-selection")
26
+ fields = self.template.content_tag(:div, fields, class: "tab-content")
27
+
28
+ html = self.template.content_tag(:div,
29
+ linker + fields,
30
+ id: "language-tabs-#{index}",
31
+ class: "tabbable tabs-left"
32
+ )
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,4 @@
1
+ require 'formtastic/globalize_inputs'
2
+ require 'active_admin/globalize_inputs'
3
+ require 'active_admin/globalize_attributes_table'
4
+ require 'version'
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module GlobalizeAAInputs
2
+ VERSION = "0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: globalize3-inputs-bootstrap
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Gullit Miranda
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: globalize3
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: activeadmin
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Implementation of globalize_fields - has_many friendly Globalize3 helper
47
+ for ActiveAdmin.
48
+ email:
49
+ - gullitmiranda@requestdev.com.br
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - globalize3-inputs-bootstrap.gemspec
60
+ - lib/active_admin/globalize_attributes_table.rb
61
+ - lib/active_admin/globalize_inputs.rb
62
+ - lib/formtastic/globalize_inputs.rb
63
+ - lib/globalize3-inputs-bootstrap.rb
64
+ - lib/version.rb
65
+ homepage: https://github.com/gullitmiranda/globalize3-inputs-bootstrap
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.24
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Globalize3 helper for ActiveAdmin.
89
+ test_files: []