formtastic_extensions 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/krasivotokak/formtastic_extensions"
12
12
  gem.authors = ["Alexander Semyonov"]
13
13
  gem.add_development_dependency "thoughtbot-shoulda"
14
- gem.add_dependency('formtastic', '0.2.5')
14
+ gem.add_dependency('formtastic', '>= 0.9.1')
15
15
  gem.add_dependency('validation_reflection', '0.3.5')
16
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
17
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{formtastic_extensions}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexander Semyonov"]
12
- s.date = %q{2009-10-17}
12
+ s.date = %q{2009-11-06}
13
13
  s.description = %q{extension for formtastic, adding tag_list and others}
14
14
  s.email = %q{rotuka@tokak.ru}
15
15
  s.extra_rdoc_files = [
@@ -51,16 +51,17 @@ Gem::Specification.new do |s|
51
51
 
52
52
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
53
53
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
- s.add_runtime_dependency(%q<formtastic>, ["= 0.2.5"])
54
+ s.add_runtime_dependency(%q<formtastic>, [">= 0.9.1"])
55
55
  s.add_runtime_dependency(%q<validation_reflection>, ["= 0.3.5"])
56
56
  else
57
57
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
58
- s.add_dependency(%q<formtastic>, ["= 0.2.5"])
58
+ s.add_dependency(%q<formtastic>, [">= 0.9.1"])
59
59
  s.add_dependency(%q<validation_reflection>, ["= 0.3.5"])
60
60
  end
61
61
  else
62
62
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
63
- s.add_dependency(%q<formtastic>, ["= 0.2.5"])
63
+ s.add_dependency(%q<formtastic>, [">= 0.9.1"])
64
64
  s.add_dependency(%q<validation_reflection>, ["= 0.3.5"])
65
65
  end
66
66
  end
67
+
@@ -1,9 +1,16 @@
1
- require 'validation_reflection'
2
- require 'formtastic'
3
- require 'formtastic_extensions/semantic_form_builder'
4
-
5
1
  module FormtasticExtensions
6
2
  def self.locale_files
7
- Dir[File.join(File.dirname(__FILE__), 'milk', 'locales', '*')]
3
+ Dir[File.join(File.dirname(__FILE__), 'formtastic_extensions', 'locales', '*')]
4
+ end
5
+
6
+ def self.override_formtastic!
7
+ Formtastic::SemanticFormBuilder.all_fields_required_by_default = false
8
+ Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true
9
+ Formtastic::SemanticFormHelper.builder = FormtasticExtensions::SemanticFormBuilder
8
10
  end
9
11
  end
12
+
13
+
14
+ if defined?(:Rails)
15
+ I18n.load_path.unshift(*FormtasticExtensions.locale_files)
16
+ end
@@ -5,5 +5,5 @@ en:
5
5
  required: 'Required'
6
6
  buttons:
7
7
  create: 'Create'
8
- save: 'Save'
8
+ update: 'Save'
9
9
  submit: 'Submit'
@@ -5,5 +5,5 @@ ru:
5
5
  required: 'Обязательно'
6
6
  buttons:
7
7
  create: 'Добавить'
8
- save: 'Сохранить'
8
+ update: 'Сохранить'
9
9
  submit: 'Отправить'
@@ -1,11 +1,14 @@
1
+ require 'formtastic'
2
+
1
3
  module FormtasticExtensions
2
- class SemanticFormBuilder < ::Formtastic::SemanticFormBuilder
3
- @@all_fields_required_by_default = false
4
- @@i18n_lookups_by_default = true
4
+ class SemanticFormBuilder < Formtastic::SemanticFormBuilder
5
+ cattr_accessor :input_class, :inputs_class, :butons_class
6
+
7
+ self.all_fields_required_by_default = false
8
+ self.i18n_lookups_by_default = true
5
9
  @@input_class = 'b_field'
6
10
  @@inputs_class = 'b_fields_set'
7
11
  @@buttons_class = 'b_buttons_set'
8
- cattr_accessor :input_class, :inputs_class, :butons_class
9
12
 
10
13
  def input(method, options = {})
11
14
  options[:required] = method_required?(method) unless options.key?(:required)
@@ -13,14 +16,11 @@ module FormtasticExtensions
13
16
 
14
17
  html_class = [ options[:as], (options[:required] ? :required : :optional) ]
15
18
  html_class << 'error' if @object && @object.respond_to?(:errors) && !@object.errors[method.to_sym].blank?
19
+ html_class << method.to_s
16
20
 
17
21
  wrapper_html = options.delete(:wrapper_html) || {}
18
22
  wrapper_html[:id] ||= generate_html_id(method)
19
- wrapper_html[:class] = "#{@@input_class} #{(html_class << wrapper_html[:class]).flatten.compact.map{ |klass| "#{@@input_class}-#{klass}" }.join(' ')}"
20
-
21
- if [:boolean_select, :boolean_radio].include?(options[:as])
22
- ::ActiveSupport::Deprecation.warn(":as => :#{options[:as]} is deprecated, use :as => :#{options[:as].to_s[8..-1]} instead", caller[3..-1])
23
- end
23
+ wrapper_html[:class] = class_with_modifiers(@@input_class, html_class << wrapper_html[:class])
24
24
 
25
25
  if options[:input_html] && options[:input_html][:id]
26
26
  options[:label_html] ||= {}
@@ -49,7 +49,7 @@ module FormtasticExtensions
49
49
  if @object && args.empty?
50
50
  args = @object.class.reflections.map { |n,_| n if _.macro == :belongs_to }
51
51
  args += @object.class.content_columns.map(&:name)
52
- args -= %w[created_at updated_at created_on updated_on lock_version]
52
+ args -= %w[created_at updated_at created_on updated_on lock_version version]
53
53
  args.compact!
54
54
  end
55
55
  contents = args.map { |method| input(method.to_sym) }
@@ -71,21 +71,22 @@ module FormtasticExtensions
71
71
  end
72
72
  end
73
73
 
74
- def save_or_create_button_text(prefix = 'Submit')
75
- if @object
76
- prefix = @object.new_record? ? 'Create' : 'Save'
77
- object_name = @object.class.name.underscore
78
- else
79
- object_name = @object_name.to_s.underscore
80
- end
81
- i18n_prefix = prefix.downcase
74
+ def wysiwyg_input(method, options = {})
75
+ html_options = options.delete(:input_html) || {}
76
+ html_options[:class] ||= ''
77
+ html_options[:class] << ' mceEditor'
82
78
 
83
- i18n_prefix = prefix.downcase
84
- I18n.t("formtastic.buttons.#{object_name}.#{i18n_prefix}",
85
- :default => [
86
- :"formtastic.buttons.#{i18n_prefix}",
87
- prefix])
79
+ self.label(method, options_for_label(options)) +
80
+ self.text_area(method, html_options)
81
+ end
82
+
83
+ protected
84
+ def class_with_modifiers(main_klass, modifiers)
85
+ result = "#{main_klass} "
86
+ result << modifiers.flatten.compact.map do |klass|
87
+ "#{main_klass}-#{klass}"
88
+ end.join(' ')
89
+ result
88
90
  end
89
91
  end
90
92
  end
91
-
@@ -1,6 +1 @@
1
- require 'formtastic'
2
1
  require 'formtastic_extensions'
3
-
4
- ActionView::Base.send :include, Formtastic::SemanticFormHelper
5
- Formtastic::SemanticFormHelper.builder = FormtasticExtensions::SemanticFormBuilder
6
- I18n.load_path.unshift(*FormtasticExtensions.locale_files)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formtastic_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Semyonov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-17 00:00:00 +04:00
12
+ date: 2009-11-06 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -28,9 +28,9 @@ dependencies:
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "="
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.5
33
+ version: 0.9.1
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: validation_reflection