rails_admin_globalize_field 0.4.0 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 330004f96a0fb99c7dd6d7b0f77cb512e2f31fd1
4
- data.tar.gz: 1a5990869c087522f633ead99400a93145501cb8
2
+ SHA256:
3
+ metadata.gz: 10dd549fb4d3f7c1fb40606d74e72abde83d98bb2e69a8469a3e58b75fdb1fba
4
+ data.tar.gz: 3da2435d555a26eece56fde13ca63182e58dba3fb7c122f5e99aec7255bf9100
5
5
  SHA512:
6
- metadata.gz: 4a2ca1d49ba5aaa391e3364bae21d0f73eca49adc33512fe2ea4dd313158823dd580a0bccca68510375957ac23f3ff5da0caa09c505b1fa6423d3ae53f8f09dc
7
- data.tar.gz: b24d404ecc186e0c59c378910e0ae3dcb7a51964c44608d482a8355df01c91110f5c4cc324fffaff2f3cdae4affad4b6dd80a9d85b4fa80f804bbf52e36db08a
6
+ metadata.gz: 476f247b621e109a667b5ca32e3fc705267552a3772fde1430f835012855581b8ad31d247278c5fc1b09420701e13575c82f541363a47e5599a6c92406649cbd
7
+ data.tar.gz: c85334ec124d5a1ebf4de16f7a3b05a595f5eb812111a21363f95c1548b6760e70a00b531538217388f1e1f7b5934590cbc3edea529034ab9568c73d6ea680d0
data/.gitignore CHANGED
@@ -15,4 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- *.sqlite3
18
+ *.sqlite3
19
+ /vendor/bundle
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format doc
3
+ --exclude-pattern **/dummy/vendor/**/*_spec.rb
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in rails_admin_globalize_field.gemspec
data/README.md CHANGED
@@ -1,29 +1,28 @@
1
1
  # RailsAdminGlobalizeField
2
2
 
3
- RailsAdminGlobalizeField adds tabbed interface to [rails_admin](https://github.com/sferik/rails_admin) for multilingual models (using [globalize](https://github.com/globalize/globalize) gem)
3
+ RailsAdminGlobalizeField adds tabbed interface to [rails_admin](https://github.com/sferik/rails_admin) for multilingual models (using [globalize](https://github.com/globalize/globalize) gem)
4
4
 
5
- It adds custom field type that you can use for globalize translations association.
6
-
7
- This gem uses Translation models generated by globalize, so you don't need to add any additional model to your app (as some older globalize3 gists suggested).
5
+ It adds custom field type that you can use for globalize's translations association.
8
6
 
9
7
 
10
8
  ## Installation
11
9
 
12
- Add and configure globalize gem first.
10
+ Add and configure globalize first.
13
11
 
14
12
  ``` ruby
15
- gem 'globalize', '~> 4.0'
13
+ gem 'globalize', '~> 5.0'
16
14
  ```
17
15
 
18
- Then add this gem and run `bundle`
16
+ Add this gem and run `bundle`.
17
+
19
18
  ``` ruby
20
- gem 'rails_admin_globalize_field'
19
+ gem 'rails_admin_globalize_field', '~> 1.0'
21
20
  ```
22
21
 
23
22
 
24
23
  ## Usage
25
24
 
26
- > Don't forget to set I18n.available_locale config, because it uses that to determine what tabs to show
25
+ > Don't forget to set I18n.available_locale, because it uses that to determine what tabs to show
27
26
 
28
27
  Add **translation** models to `config.included_models` in `initializers/rails_admin.rb`:
29
28
  ``` ruby
@@ -54,27 +53,11 @@ Add configuration to your **translated** model and associated **translation** mo
54
53
  end
55
54
  ```
56
55
 
57
-
58
- Add this stylesheet into app/assets/stylesheets/rails_admin/theming.scss:
59
- ``` css
60
- /*
61
- *= require rails_admin/ra.globalize_tabs
62
- */
63
- ```
64
-
65
-
66
56
  If you need to add validation to the translation class, you can add it on `translation_class` inside **translated** model:
67
57
  ```ruby
68
58
  translation_class.validates :title, presence: true
69
59
  ```
70
60
 
71
-
72
- ## Known issues
73
-
74
- If you need to use `null: false` options on any column in translations table, you'll have to use [this globalize fork](https://github.com/scarfacedeb/globalize/tree/before_callbacks) for now.
75
- See: https://github.com/globalize/globalize/issues/325
76
-
77
-
78
61
  ## Screenshot
79
62
 
80
63
  ![Screenshot](https://raw.github.com/scarfaceDeb/rails_admin_globalize_field/screenshots/screenshots/shot1.png)
data/Rakefile CHANGED
@@ -1 +1,3 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
@@ -1,19 +1,11 @@
1
- - field.translations(true) # fetch translations and memoize them
2
- - key = field.abstract_model.model_name.parameterize
3
-
4
1
  .controls
5
- .globalize-errors
6
- = form.errors_for(field)
7
2
  %ul.nav.nav-tabs{ :style => 'margin-top:5px' }
8
- - field.available_locales.each do |locale|
9
- - klass = "localized-pane-#{locale}-#{key}-#{form.object.id}"
10
- %li{ class: ( 'active' if locale == field.current_locale ) }
11
- %a{ href: "#", data: { toggle: "tab", target: ".#{klass}:first"} }= locale
3
+ - field.tabs.each do |tab|
4
+ %li{ class: ('active' if tab.active?) }
5
+ = link_to tab.locale, "#", data: { toggle: "tab", target: "##{tab.id}" }, class: ('text-danger' unless tab.valid?)
6
+
12
7
  .tab-content
13
- - field.available_locales.each do |locale|
14
- - klass = "localized-pane-#{locale}-#{key}-#{form.object.id}"
15
- = form.fields_for field.name, field.translations[locale], wrapper: false do |nested_form|
16
- .fields.tab-pane{ class: "#{klass} #{'active' if locale == field.current_locale}" }
17
- = nested_form.generate({:action => :nested, :model_config => field.associated_model_config, :nested_in => field.name })
18
- .globalize-help
19
- = form.help_for(field)
8
+ - field.tabs.each do |tab|
9
+ = form.fields_for field.name, tab.translation, wrapper: false do |f|
10
+ .fields.tab-pane{ id: tab.id, class: ('active' if tab.active?) }
11
+ = f.generate(action: :nested, model_config: field.associated_model_config, nested_in: field)
@@ -1,61 +1,8 @@
1
- require 'rails_admin_globalize_field/engine'
2
- require 'rails_admin'
3
- require 'rails_admin/config/fields/association'
4
-
5
- module RailsAdmin
6
- module Config
7
- module Fields
8
- module Types
9
- class GlobalizeTabs < RailsAdmin::Config::Fields::Association
10
- RailsAdmin::Config::Fields::Types::register(:globalize_tabs, self)
11
-
12
- # A workaround for https://github.com/sferik/rails_admin/pull/1726
13
- def initialize(parent, name, properties)
14
- properties = parent.abstract_model.associations.detect { |p| name == p.name }
15
- super
16
- end
17
-
18
- register_instance_option :partial do
19
- :form_globalize_tabs
20
- end
21
-
22
- def method_name
23
- "#{super}_attributes".to_sym
24
- end
25
-
26
- def generic_help
27
- "" # false is ignored by I18n.translate
28
- end
1
+ # frozen_string_literal: true
29
2
 
30
- # Reader for validation errors of the bound object
31
- def errors
32
- bindings[:object].errors[name]
33
- end
34
-
35
- def available_locales
36
- I18n.available_locales
37
- end
38
- def current_locale
39
- I18n.locale
40
- end
41
-
42
- # Returns array of Translation objects.
43
- # It gets existing or creates new empty translation for every locale.
44
- # Call the first time with reset_cache == true to update memoized translations.
45
- def translations reset_cache=false
46
- return @translations if @translations && !reset_cache
47
-
48
- translations = @bindings[:object].translations_by_locale
49
- new_locales = available_locales - translations.keys.map(&:to_sym)
50
-
51
- new_locales.map do |locale|
52
- translations[locale] = @bindings[:object].translations.new({ locale: locale })
53
- end
3
+ require 'rails_admin'
4
+ require 'rails_admin_globalize_field/engine'
5
+ require 'rails_admin_globalize_field/globalize_tabs'
54
6
 
55
- @translations = translations
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end
7
+ module RailsAdminGlobalizeField
8
+ end
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsAdminGlobalizeField
2
4
  class Engine < ::Rails::Engine
3
5
  end
4
- end
6
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_admin/config/fields/association'
4
+ require 'rails_admin_globalize_field/tab'
5
+
6
+ # Custom rails_admin field to add tabs for globalize translations
7
+ module RailsAdminGlobalizeField
8
+ class GlobalizeTabs < RailsAdmin::Config::Fields::Association
9
+ RailsAdmin::Config::Fields::Types.register(:globalize_tabs, self)
10
+
11
+ register_instance_option :partial do
12
+ :form_globalize_tabs
13
+ end
14
+
15
+ register_instance_option :build_if_missing do
16
+ true
17
+ end
18
+
19
+ def method_name
20
+ "#{super}_attributes".to_sym
21
+ end
22
+
23
+ def available_locales
24
+ I18n.available_locales
25
+ end
26
+
27
+ def tabs
28
+ tabs =
29
+ available_locales.map do |locale|
30
+ translation = bindings[:object].translation_for(locale, build_if_missing)
31
+ RailsAdminGlobalizeField::Tab.new(locale, translation, validate: submit_action?) if translation
32
+ end.compact
33
+
34
+ activate_tab(tabs)
35
+ tabs
36
+ end
37
+
38
+ # Hack to distinguish between REST new/edit and create/update actions.
39
+ # Taken from rails_admin/configs/new.rb
40
+ def submit_action?
41
+ !bindings[:controller].request.get?
42
+ end
43
+
44
+ def activate_tab(tabs)
45
+ opened = tabs.find(&:invalid?) || tabs.first
46
+ opened&.active!
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsAdminGlobalizeField
4
+ class Tab
5
+ attr_reader :locale, :translation
6
+
7
+ def initialize(locale, translation, validate: true)
8
+ @locale = locale
9
+ @translation = translation
10
+ @validate = validate
11
+ end
12
+
13
+ def id
14
+ ['pane', translation.model_name.param_key, locale].join('-')
15
+ end
16
+
17
+ def active!
18
+ @active = true
19
+ end
20
+
21
+ def active?
22
+ @active
23
+ end
24
+
25
+ def valid?
26
+ !@validate || translation.valid?
27
+ end
28
+
29
+ def invalid?
30
+ !valid?
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsAdminGlobalizeField
2
- VERSION = "0.4.0"
4
+ VERSION = '1.0.0'
3
5
  end
@@ -1,34 +1,33 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'rails_admin_globalize_field/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "rails_admin_globalize_field"
8
+ spec.name = 'rails_admin_globalize_field'
8
9
  spec.version = RailsAdminGlobalizeField::VERSION
9
- spec.authors = ["Andrew Volozhanin"]
10
- spec.email = ["scarfacedeb@gmail.com"]
11
- spec.description = %q{Adds tabbed interface and custom field type for globalize translations to Rails_admin}
12
- spec.summary = %q{Tabbed interface and custom field type for globalize translations for Rails_admin}
13
- spec.homepage = ""
14
- spec.license = "MIT"
10
+ spec.authors = ['Andrew Volozhanin']
11
+ spec.email = ['scarfacedeb@gmail.com']
12
+ spec.description = 'Adds tabbed interface and custom field type for globalize translations to Rails_admin'
13
+ spec.summary = 'Tabbed interface and custom field type for globalize translations for Rails_admin'
14
+ spec.homepage = ''
15
+ spec.license = 'MIT'
15
16
 
16
- spec.files = `git ls-files`.split($/)
17
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
20
21
 
21
- spec.add_dependency "rails", ">= 4.2"
22
- spec.add_dependency 'rails_admin', '>= 0.6.2'
22
+ spec.add_dependency 'rails', '>= 5.0'
23
+ spec.add_dependency 'rails_admin', '>= 2.0'
23
24
 
24
25
  spec.add_dependency 'globalize', '>= 5.0'
25
26
 
26
- spec.add_development_dependency "bundler", "~> 1.3"
27
- spec.add_development_dependency "rake"
27
+ spec.add_development_dependency 'capybara', '~> 3.29'
28
28
  spec.add_development_dependency 'pry'
29
29
  spec.add_development_dependency 'pry-byebug'
30
+ spec.add_development_dependency 'rake'
31
+ spec.add_development_dependency 'rspec-rails', '~> 3.8'
30
32
  spec.add_development_dependency 'sqlite3'
31
- spec.add_development_dependency 'rspec-rails', '~> 3.0'
32
- spec.add_development_dependency 'capybara', '~> 2.4'
33
- spec.add_development_dependency 'poltergeist', '~> 1.5'
34
33
  end
@@ -0,0 +1 @@
1
+ /vendor/bundle
data/spec/dummy/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', "~> 4.2"
3
+ gem 'rails', '~> 6.0'
4
4
  gem 'sqlite3'
5
5
 
6
- gem 'globalize', "~> 5.0"
7
- gem 'rails_admin', '~> 0.6'
6
+ gem 'globalize', '~> 5.0'
7
+ gem 'rails_admin', '~> 2.0'
8
8
 
9
9
  gem 'rails_admin_globalize_field', path: '../../'
@@ -9,6 +9,7 @@ require "sprockets/railtie"
9
9
  # require "rails/test_unit/railtie"
10
10
 
11
11
  Bundler.require(*Rails.groups)
12
+ require "globalize"
12
13
  require "rails_admin_globalize_field"
13
14
 
14
15
  module Dummy
@@ -48,16 +48,18 @@ RailsAdmin.config do |config|
48
48
  end
49
49
 
50
50
  config.model 'Admin::Note' do
51
- configure :translations, :globalize_tabs do
52
- active true # open by default
53
- end
51
+ configure :translations, :globalize_tabs
54
52
 
55
53
  edit do
56
- include_fields :translations, :image
54
+ include_fields :translations
57
55
  end
58
56
  end
59
57
 
60
58
  config.model 'Admin::Note::Translation' do
59
+ visible false
60
+ configure :locale, :hidden do
61
+ help ''
62
+ end
61
63
  field :title do
62
64
  label 'Custom note title'
63
65
  end
@@ -1,29 +1,46 @@
1
- ActiveRecord::Schema.define do
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
2
13
 
3
- create_table :pages, force: true do |t|
4
- t.string :slug
5
- t.string :image
6
- t.timestamps null: false
7
- end
14
+ ActiveRecord::Schema.define(version: 0) do
8
15
 
9
- create_table :page_translations, force: true do |t|
10
- t.integer :page_id, null: false
11
- t.string :locale, null: false
12
- t.string :title, null: false
13
- t.text :content
14
- t.timestamps null: false
16
+ create_table "page_translations", force: :cascade do |t|
17
+ t.integer "page_id", null: false
18
+ t.string "locale", null: false
19
+ t.string "title", null: false
20
+ t.text "content"
21
+ t.datetime "created_at", null: false
22
+ t.datetime "updated_at", null: false
15
23
  end
16
24
 
17
- create_table :admin_notes, force: true do |t|
18
- t.string :image
19
- t.timestamps null: false
25
+ create_table "pages", force: :cascade do |t|
26
+ t.string "slug"
27
+ t.string "image"
28
+ t.datetime "created_at", null: false
29
+ t.datetime "updated_at", null: false
20
30
  end
21
31
 
22
- create_table :admin_note_translations, force: true do |t|
23
- t.integer :admin_note_id, null: false
24
- t.string :locale, null: false
25
- t.string :title, null: false
26
- t.timestamps null: false
32
+
33
+ create_table "admin_note_translations", force: :cascade do |t|
34
+ t.integer "admin_note_id", null: false
35
+ t.string "locale", null: false
36
+ t.string "title", null: false
37
+ t.text "content"
38
+ t.datetime "created_at", null: false
39
+ t.datetime "updated_at", null: false
27
40
  end
28
41
 
42
+ create_table "admin_notes", force: :cascade do |t|
43
+ t.datetime "created_at", null: false
44
+ t.datetime "updated_at", null: false
45
+ end
29
46
  end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'pry'
5
+
6
+ module RailsAdminGlobalizeField
7
+ RSpec.describe GlobalizeTabs do
8
+ let(:translated_page) do
9
+ Page.create!(
10
+ slug: '2001',
11
+ image: 'poster.png',
12
+ title: '2001: Space odyssey',
13
+ content: '<p>Visionary</p>'
14
+ )
15
+ end
16
+ let(:note) { Admin::Note.create!(title: 'Fix bug with namespaces') }
17
+
18
+ it 'renders all available locales as tabs' do
19
+ visit '/page/new'
20
+ expect(find('.globalize_tabs_type .nav-tabs')).to have_content('en cz ru')
21
+ end
22
+
23
+ describe 'localized data in correct tab' do
24
+ it 'renders the default locale' do
25
+ visit "/page/#{translated_page.id}/edit"
26
+ within('#pane-page_translation-en') do
27
+ expect(find_field('Title').value).to eq('2001: Space odyssey')
28
+ expect(find_field('Content')).to have_content('<p>Visionary</p>')
29
+ end
30
+ end
31
+
32
+ it 'renders cz locale' do
33
+ Globalize.with_locale(:cz) do
34
+ translated_page.title = '2001: Vesmírná odysea'
35
+ translated_page.content = '<p>Vizionář</p>'
36
+ translated_page.save!
37
+ end
38
+
39
+ visit "/page/#{translated_page.id}/edit"
40
+
41
+ within('#pane-page_translation-cz') do
42
+ expect(find_field('Title').value).to eq('2001: Vesmírná odysea')
43
+ expect(find_field('Content')).to have_content('<p>Vizionář</p>')
44
+ end
45
+ end
46
+ end
47
+
48
+ it 'works correctly with namespaced models' do
49
+ visit "/admin~note/#{note.id}/edit"
50
+ expect(page).to have_css('#pane-admin_note_translation-en')
51
+ end
52
+
53
+ it 'allows to set custom label name for translated attribute' do
54
+ visit "/admin~note/#{note.id}/edit"
55
+ within('#pane-admin_note_translation-en') do
56
+ expect(find('#admin_note_translations_attributes_0_title_field')).to have_content('Custom note title')
57
+ end
58
+ end
59
+ end
60
+ end
data/spec/spec_helper.rb CHANGED
@@ -5,9 +5,7 @@ require 'globalize'
5
5
  require 'rails_admin_globalize_field'
6
6
 
7
7
  require 'rspec/rails'
8
- require 'capybara/poltergeist'
9
-
10
- Capybara.javascript_driver = :poltergeist
8
+ require 'capybara'
11
9
 
12
10
  RSpec.configure do |config|
13
11
  config.disable_monkey_patching!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_globalize_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Volozhanin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-12 00:00:00.000000000 Z
11
+ date: 2019-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.2'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails_admin
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.2
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.6.2
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: globalize
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,33 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: bundler
56
+ name: capybara
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.3'
61
+ version: '3.29'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.3'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
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'
68
+ version: '3.29'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: pry
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +95,7 @@ dependencies:
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
- name: sqlite3
98
+ name: rake
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
@@ -128,42 +114,28 @@ dependencies:
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: '3.0'
117
+ version: '3.8'
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: '3.0'
124
+ version: '3.8'
139
125
  - !ruby/object:Gem::Dependency
140
- name: capybara
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '2.4'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '2.4'
153
- - !ruby/object:Gem::Dependency
154
- name: poltergeist
126
+ name: sqlite3
155
127
  requirement: !ruby/object:Gem::Requirement
156
128
  requirements:
157
- - - "~>"
129
+ - - ">="
158
130
  - !ruby/object:Gem::Version
159
- version: '1.5'
131
+ version: '0'
160
132
  type: :development
161
133
  prerelease: false
162
134
  version_requirements: !ruby/object:Gem::Requirement
163
135
  requirements:
164
- - - "~>"
136
+ - - ">="
165
137
  - !ruby/object:Gem::Version
166
- version: '1.5'
138
+ version: '0'
167
139
  description: Adds tabbed interface and custom field type for globalize translations
168
140
  to Rails_admin
169
141
  email:
@@ -173,17 +145,20 @@ extensions: []
173
145
  extra_rdoc_files: []
174
146
  files:
175
147
  - ".gitignore"
148
+ - ".rspec"
176
149
  - Gemfile
177
150
  - LICENSE.txt
178
151
  - README.md
179
152
  - Rakefile
180
- - app/assets/stylesheets/rails_admin/ra.globalize_tabs.scss
181
153
  - app/views/.gitkeep
182
154
  - app/views/rails_admin/main/_form_globalize_tabs.html.haml
183
155
  - lib/rails_admin_globalize_field.rb
184
156
  - lib/rails_admin_globalize_field/engine.rb
157
+ - lib/rails_admin_globalize_field/globalize_tabs.rb
158
+ - lib/rails_admin_globalize_field/tab.rb
185
159
  - lib/rails_admin_globalize_field/version.rb
186
160
  - rails_admin_globalize_field.gemspec
161
+ - spec/dummy/.gitignore
187
162
  - spec/dummy/Gemfile
188
163
  - spec/dummy/README.rdoc
189
164
  - spec/dummy/Rakefile
@@ -230,7 +205,7 @@ files:
230
205
  - spec/dummy/public/422.html
231
206
  - spec/dummy/public/500.html
232
207
  - spec/dummy/public/favicon.ico
233
- - spec/field_spec.rb
208
+ - spec/globalize_tabs_spec.rb
234
209
  - spec/spec_helper.rb
235
210
  homepage: ''
236
211
  licenses:
@@ -251,12 +226,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
226
  - !ruby/object:Gem::Version
252
227
  version: '0'
253
228
  requirements: []
254
- rubyforge_project:
255
- rubygems_version: 2.4.5
229
+ rubygems_version: 3.0.4
256
230
  signing_key:
257
231
  specification_version: 4
258
232
  summary: Tabbed interface and custom field type for globalize translations for Rails_admin
259
233
  test_files:
234
+ - spec/dummy/.gitignore
260
235
  - spec/dummy/Gemfile
261
236
  - spec/dummy/README.rdoc
262
237
  - spec/dummy/Rakefile
@@ -303,6 +278,5 @@ test_files:
303
278
  - spec/dummy/public/422.html
304
279
  - spec/dummy/public/500.html
305
280
  - spec/dummy/public/favicon.ico
306
- - spec/field_spec.rb
281
+ - spec/globalize_tabs_spec.rb
307
282
  - spec/spec_helper.rb
308
- has_rdoc:
@@ -1,17 +0,0 @@
1
-
2
- // scope all selectors (it's awful, but it's safer)
3
- .globalize_tabs_type {
4
-
5
- // Generic adjustments
6
-
7
- .globalize-errors {
8
- float: right;
9
- margin-left: 15px;
10
- line-height: 36px; // tabs height
11
- }
12
- .globalize-help {
13
- margin-top: 10px;
14
- margin-left: 180px; // == .form-horizontal .controls indent
15
- }
16
-
17
- }
data/spec/field_spec.rb DELETED
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
- require 'pry'
3
-
4
- RSpec.describe RailsAdmin::Config::Fields::Types::GlobalizeTabs do
5
- let(:translated_page) {
6
- Page.create!(
7
- slug: '2001',
8
- image: 'poster.png',
9
- title: '2001: Space odyssey',
10
- content: '<p>Visionary</p>'
11
- )
12
- }
13
- let(:note) { Admin::Note.create(title: 'Fix bug with namespaces', image: 'urgent.png') }
14
-
15
- it 'renders all available locales as tabs' do
16
- visit '/page/new'
17
- expect(find('.globalize_tabs_type').find('.nav-tabs')).to have_content 'en cz ru'
18
- end
19
-
20
- describe 'localized data in correct tab' do
21
- it 'renders the default locale' do
22
- visit "/page/#{translated_page.id}/edit"
23
- within(".localized-pane-en-page-#{translated_page.id}") do
24
- expect(find_field('Title').value).to eq('2001: Space odyssey')
25
- expect(find_field('Content')).to have_content('<p>Visionary</p>')
26
- end
27
- end
28
-
29
- it 'renders cz locale' do
30
- Globalize.with_locale(:cz) do
31
- translated_page.title = '2001: Vesmírná odysea'
32
- translated_page.content = '<p>Vizionář</p>'
33
- translated_page.save!
34
- end
35
-
36
- visit "/page/#{translated_page.id}/edit"
37
-
38
- within(".localized-pane-cz-page-#{translated_page.id}") do
39
- expect(find_field('Title').value).to eq('2001: Vesmírná odysea')
40
- expect(find_field('Content')).to have_content('<p>Vizionář</p>')
41
- end
42
- end
43
- end
44
-
45
- it 'works correctly with namespaced models' do
46
- visit "/admin~note/#{note.id}/edit"
47
- expect(page).to have_css(".localized-pane-en-admin-note-#{note.id}")
48
- end
49
-
50
- it 'allows to set custom label name for translated attribute' do
51
- visit "/admin~note/#{note.id}/edit"
52
- within(".localized-pane-en-admin-note-#{note.id}") do
53
- expect(find('#admin_note_translations_attributes_0_title_field')).to have_content('Custom note title')
54
- end
55
- end
56
- end