Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit 2e48b1f

Browse files
committed
Merge branch 'feature/translation-tabs' into develop
2 parents 3b570f5 + 4e70073 commit 2e48b1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2071
-178
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
.bundle/
22
.bin
33

4+
# sqlite files
5+
*.sqlite3
6+
7+
# tmp files
8+
tmp/
9+
10+
# ignore Gemfile.lock and other lockfiles
11+
*.lock
12+
13+
# Dummy app ignored stuff
14+
spec/dummy/db/*.sqlite3
15+
spec/dummy/log/*.log
16+
spec/dummy/tmp/

.rspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--format progress

Gemfile

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
1-
source "https://rubygems.org"
1+
source 'https://rubygems.org'
22

3+
# Declare your gem's dependencies in activeadmin-globalize.gemspec.
4+
# Bundler will treat runtime dependencies like base dependencies, and
5+
# development dependencies will be added by default to the :development group.
36
gemspec
47

5-
gem 'activeadmin', github: 'gregbell/active_admin', branch: 'master'
8+
# Declare any dependencies that are still in development here instead of in
9+
# your gemspec. These might include edge Rails or gems from your path or
10+
# Git. Remember to move these dependencies to your gemspec before releasing
11+
# your gem to rubygems.org.
612

13+
# To use debugger
14+
# gem 'debugger'
15+
16+
# Gems used by the dummy application
17+
group :assets do
18+
gem 'sass-rails', '~> 3.2.3'
19+
gem 'coffee-rails', '~> 3.2.1'
20+
21+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
22+
gem 'therubyracer', platforms: :ruby
23+
24+
gem 'uglifier', '>= 1.0.3'
25+
end
26+
27+
# jquery-rails is
28+
gem 'jquery-rails'
29+
30+
group :test do
31+
gem 'sqlite3', '~> 1.3.5'
32+
gem 'rspec-rails', '~> 2.14.0'
33+
gem 'factory_girl_rails', '~> 4.2.1'
34+
gem 'database_cleaner', '~> 1.0.1'
35+
gem 'guard-rspec', require: false
36+
gem 'spring', require: false
37+
gem 'spring-commands-rspec', require: false
38+
gem 'capybara', '~> 2.1.0'
39+
gem 'capybara-screenshot'
40+
gem 'poltergeist'
41+
gem 'fuubar'
42+
# Useful to debug tests
43+
gem 'awesome_print'
44+
gem 'pry'
45+
end

Gemfile.lock

Lines changed: 0 additions & 162 deletions
This file was deleted.

Guardfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# A sample Guardfile
2+
# More info at https://github.com/guard/guard#readme
3+
4+
guard :rspec, cmd: 'spring rspec -f Fuubar' do
5+
watch(%r{^spec/.+_spec\.rb$})
6+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7+
watch('spec/spec_helper.rb') { "spec" }
8+
9+
# Rails example
10+
watch(%r{^dummy/app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11+
watch(%r{^dummy/app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12+
watch(%r{^dummy/app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14+
15+
end
16+

Rakefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env rake
2+
require 'bundler/gem_tasks'
3+
4+
begin
5+
require 'bundler/setup'
6+
rescue LoadError
7+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
8+
end
9+
10+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
11+
load 'rails/tasks/engine.rake'
12+
13+
Bundler::GemHelper.install_tasks
14+
15+
require 'rspec/core/rake_task'
16+
RSpec::Core::RakeTask.new(:spec)
17+
18+
task default: %w(app:test:prepare spec)

activeadmin-globalize.gemspec

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
$:.push File.expand_path("../lib", __FILE__)
1+
$:.push File.expand_path('../lib', __FILE__)
22

33
# Maintain your gem's version:
4-
require "active_admin/globalize/version"
4+
require 'active_admin/globalize/version'
55

66
# Describe your gem and declare its dependencies:
77
Gem::Specification.new do |s|
8-
s.name = "activeadmin-globalize"
8+
s.name = 'activeadmin-globalize'
99
s.version = ActiveAdmin::Globalize::VERSION
10-
s.authors = ["Stefano Verna"]
11-
s.email = ["stefano.verna@gmail.com"]
12-
s.homepage = "http://github.com/stefanoverna/activeadmin-globalize"
13-
s.summary = "Handles globalize translations"
14-
s.description = "Handles globalize translations"
10+
s.authors = ['Stefano Verna']
11+
s.email = ['stefano.verna@gmail.com']
12+
s.homepage = 'http://github.com/stefanoverna/activeadmin-globalize'
13+
s.summary = 'Handles globalize translations'
14+
s.description = 'Handles globalize translations'
1515

16-
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "README.md"]
16+
s.files = Dir['{app,config,db,lib}/**/*'] + %w(MIT-LICENSE README.md)
17+
18+
s.add_dependency 'activeadmin', '>= 0.6.3'
19+
s.add_dependency 'globalize', '>= 3.0.4'
20+
21+
# development dependencies
22+
s.add_development_dependency 'bundler', '~> 1.6.1'
23+
s.add_development_dependency 'rake'
24+
# Other development dependencies moved into Gemfile
1725

18-
s.add_dependency "activeadmin"
19-
s.add_dependency "globalize", '>= 3.0.4'
2026
end
2127

app/assets/javascripts/active_admin/active_admin_globalize.js.coffee

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ $ ->
2323

2424
$(".activeadmin-translations > ul").each ->
2525
$dom = $(this)
26+
# true when tabs are used in show action, false in form
27+
showAction = $dom.hasClass('locale-selector')
28+
2629
if !$dom.data("ready")
2730
$dom.data("ready", true)
2831
$tabs = $("li > a", this)
29-
$contents = $(this).siblings("fieldset")
32+
# content to toggle is different according to current action
33+
$contents = if showAction then $(this).siblings("div.field-translation") else $(this).siblings("fieldset")
3034

3135
$tabs.click (e) ->
3236
$tab = $(this)
@@ -38,6 +42,9 @@ $ ->
3842

3943
$tabs.eq(0).click()
4044

45+
# Add button and other behavior is not needed in show action
46+
return if showAction
47+
4148
# Collect tha available locales.
4249
availableLocales = []
4350
$tabs.not('.default').each ->
@@ -135,5 +142,13 @@ $ ->
135142
50
136143
)
137144

145+
# Used to toggle translations values for inline fields
146+
$('a.ui-translation-trigger').click (e) ->
147+
$locale = $(this).data('locale')
148+
$td = $(this).closest('td')
149+
$('.field-translation', $td).hide()
150+
$(".locale-#{$locale}", $td).show()
151+
e.preventDefault()
152+
138153
translations()
139154

app/assets/stylesheets/active_admin/active_admin_globalize_flags.css.sass

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
.flag
66
width: 16px
77
height: 11px
8+
vertical-align: middle
89
background: url(active_admin_image_path('flags.png')) no-repeat
910
&.flag-ar // originally flag-ae
1011
background-position: -16px 0
1112
&.flag-br
1213
background-position: -32px 0
14+
&.flag-pt-BR
15+
background-position: -32px 0
1316
&.flag-de
1417
background-position: -48px 0
1518
&.flag-es
@@ -24,7 +27,26 @@
2427
background-position: 0 -22px
2528
&.flag-pt
2629
background-position: -16px -22px
30+
&.flag-pt-PT
31+
background-position: -16px -22px
2732
&.flag-tr
2833
background-position: -32px -22px
2934
&.flag-en // originally flag-us
30-
background-position: -48px -22px
35+
background-position: -48px -22px
36+
37+
// Used to distantiate inline locale selector
38+
span.inline-locale-selector
39+
margin-right: 10px
40+
41+
.field-translation.hidden
42+
display: none
43+
44+
ul.locale-selector
45+
margin-bottom: 0 !important
46+
47+
div.field-translation
48+
padding: 10px 10px
49+
+inset-shadow(0, -40px, 40px, #ddd)
50+
+border-top-radius(4px)
51+
+border-bottom-radius(6px)
52+
min-height: 80px

config/spring.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Tell spring where the app is
2+
Spring.application_root = './spec/dummy'

0 commit comments

Comments
 (0)