activeadmin-mongoid-localize 0.2.2 → 0.3.1

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.
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Easily edit mongoid localized fields in ActiveAdmin (all locales on one page)
4
4
 
5
+ ## Screenshot
6
+
7
+ ![AML](http://rscx.ru/aml.jpg)
8
+
5
9
  ## Installation
6
10
 
7
11
  Add this line to your application's Gemfile:
@@ -43,6 +47,7 @@ Really simple:
43
47
  end
44
48
 
45
49
  CKEditor is tested & working with my fork: https://github.com/glebtv/ckeditor
50
+
46
51
  ActiveAdmin-mongoid is tested & working with my fork: https://github.com/rs-pro/activeadmin-mongoid
47
52
 
48
53
  ## Contributing
@@ -1,5 +1,8 @@
1
1
  require "activeadmin-mongoid-localize/version"
2
+
2
3
  require 'activeadmin-mongoid-localize/formtastic'
4
+
5
+ require 'activeadmin-mongoid-localize/active_admin'
3
6
  require 'activeadmin-mongoid-localize/attributes_table'
4
7
 
5
8
  module ActiveAdmin
@@ -0,0 +1,8 @@
1
+ module ActiveAdmin
2
+ class FormBuilder
3
+ def localized_input(name, args = {})
4
+ form_buffers.last << super(name, args)
5
+ self.form_buffers.last
6
+ end
7
+ end
8
+ end
@@ -1,30 +1,29 @@
1
1
  module Formtastic
2
2
  class FormBuilder
3
3
  def localized_input(name, args = {})
4
-
5
4
  t = self.object.send("#{name}_translations")
6
5
  field = ActiveAdmin::Mongoid::Localize::Field.new(self.object, name)
7
6
 
7
+ ret = ''
8
8
  self.semantic_fields_for "#{name}_translations", field do |lf|
9
9
  ::I18n.available_locales.each do |locale|
10
10
  args[:value] = (t.nil? || t[locale.to_s].nil?) ? '' : t[locale.to_s]
11
11
 
12
12
  label = CGI.escapeHTML(self.object.class.human_attribute_name(name)) + " #{template.image_tag "aml/flags/#{locale.to_s}.png", alt: locale.to_s, title: locale.to_s}"
13
13
  if args[:as] == :ckeditor
14
- form_buffers.last << "<h3 style='margin: 10px 0px 0px 10px;'>#{label}</h3>#{'<abbr>*</abbr>' if field.required?}".html_safe
14
+ prepend = "<h3 style='margin: 10px 0px 0px 10px;'>#{label}</h3>#{'<abbr>*</abbr>' if field.required?}".html_safe
15
15
  args[:label] = false
16
16
  else
17
+ prepend = ''.html_safe
17
18
  args[:label] = label.html_safe
18
19
  end
19
20
  args[:required] = field.required?
20
21
 
21
- form_buffers.last << lf.input(locale, args)
22
- form_buffers.last
22
+ ret << prepend + lf.input(locale, args)
23
23
  end
24
24
  end
25
25
 
26
- # return in case our input is last
27
- self.form_buffers.last
26
+ ret.html_safe
28
27
  end
29
28
  end
30
29
  end
@@ -1,7 +1,7 @@
1
1
  module ActiveAdmin
2
2
  module Mongoid
3
3
  module Localize
4
- VERSION = "0.2.2"
4
+ VERSION = "0.3.1"
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.2
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-13 00:00:00.000000000 Z
12
+ date: 2013-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -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/active_admin.rb
309
310
  - lib/activeadmin-mongoid-localize/attributes_table.rb
310
311
  - lib/activeadmin-mongoid-localize/field.rb
311
312
  - lib/activeadmin-mongoid-localize/formtastic.rb