activeadmin-mongoid-localize 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,6 +20,11 @@ Or install it yourself as:
20
20
 
21
21
  Really simple:
22
22
 
23
+ # in model
24
+ field :title, type: String, localize: true
25
+ field :content, type: String, localize: true
26
+
27
+ # in admin
23
28
  f.inputs do
24
29
  f.localized_input :title
25
30
 
@@ -27,6 +32,16 @@ Really simple:
27
32
  f.localized_input :content, as: :ckeditor
28
33
  end
29
34
 
35
+ # displaying in show action
36
+ show do |f|
37
+ panel I18n.t('fields') do
38
+ localize_attributes_table_for f do
39
+ row :name
40
+ row :text
41
+ end
42
+ end
43
+ end
44
+
30
45
  CKEditor is tested & working with my fork: https://github.com/glebtv/ckeditor
31
46
  ActiveAdmin-mongoid is tested & working with my fork: https://github.com/rs-pro/activeadmin-mongoid
32
47
 
@@ -1,6 +1,6 @@
1
1
  require "activeadmin-mongoid-localize/version"
2
-
3
2
  require 'activeadmin-mongoid-localize/formtastic'
3
+ require 'activeadmin-mongoid-localize/attributes_table'
4
4
 
5
5
  module ActiveAdmin
6
6
  module Mongoid
@@ -0,0 +1,39 @@
1
+ module ActiveAdmin
2
+ module Views
3
+ class LocalizedAttributesTable < ActiveAdmin::Views::AttributesTable
4
+ builder_method :localize_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
+ (
17
+ image_tag("aml/flags/#{locale.to_s}.png", alt: locale.to_s, title: locale.to_s) +
18
+ ' ' +
19
+ content_for(block || attr)
20
+ ).html_safe
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ def default_id_for_prefix
30
+ 'attributes_table'
31
+ end
32
+
33
+ def default_class_name
34
+ 'attributes_table'
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -1,7 +1,7 @@
1
1
  module ActiveAdmin
2
2
  module Mongoid
3
3
  module Localize
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-mongoid-localize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -306,6 +306,7 @@ files:
306
306
  - app/assets/images/aml/flags/zm.png
307
307
  - app/assets/images/aml/flags/zw.png
308
308
  - lib/activeadmin-mongoid-localize.rb
309
+ - lib/activeadmin-mongoid-localize/attributes_table.rb
309
310
  - lib/activeadmin-mongoid-localize/field.rb
310
311
  - lib/activeadmin-mongoid-localize/formtastic.rb
311
312
  - lib/activeadmin-mongoid-localize/version.rb