polyblock 0.8.8 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbefa64847a7363aaca2d2b19172cadf459a9e08
4
- data.tar.gz: 6e540f64345f94bf2e423ee70c0de8ae06b6af18
3
+ metadata.gz: b4306edc72fcb000b6f3c3f9a5f532f785da47a7
4
+ data.tar.gz: c9f530612d2cc20d0955241318563a82439398e4
5
5
  SHA512:
6
- metadata.gz: d2777dcb2e6a3bc97275b0c1d6a44124d402cd37c7b3c0745508718b36a580e23ee1cb1f5c8b75c5f0de3eead51a27556789a4c38070b9edfd3db0e287237c08
7
- data.tar.gz: 44aa66f75e3f2e693d88ab4723f997103a6a8faec432466986cd156a8f1adfcb6d51d79805e2013a7bf419a0c8335b09116bbea6b1a3aac1aa9747a287130536
6
+ metadata.gz: 61d36b682dec3c1e0ea9dfbe0b8ce891f11058da0d8b33bae36a762b735500c74f3d494ae8de0aa54b33d804053801896d2ecaf582e68eb3df4f32faef66b97c
7
+ data.tar.gz: 2f13c165a11cd6bbeb90f3023351805a14aa46f853800fe608cdbdf7089ee7b517370a85c3e54642c65a5a6943c5935c1dac1f554acf2cfcc735c801fe4b5ba1
@@ -1,6 +1,11 @@
1
1
  = f.simple_fields_for name do |ff|
2
+ - if f.object.errors[name.to_sym].any?
3
+ - f.object.errors.full_messages_for(name.to_sym).each do |e|
4
+ .alert.alert-danger= e
2
5
  = ff.input_field :name, :as => :hidden, :value => name.to_s
3
- - if !options[:label]
4
- = ff.input_field :content, options[:input_html].merge({:as => :ckeditor})
6
+ - if options[:use_input_field] == false
7
+ = ff.input :content, options[:field]
5
8
  - else
6
- = ff.input :content, :as => :ckeditor, :label => options[:label].is_a?(String) ? options[:label] : name.to_s.titleize, :input_html => pb.content.present? ? options[:input_html].merge({:value => pb.content}) : options[:input_html]
9
+ = ff.input_field :content, options[:field][:input_html]
10
+ -# = ff.input :content, :as => :ckeditor, :label => options[:label].is_a?(String) ? options[:label] : name.to_s.titleize,
11
+ -# :input_html => pb.content.present? ? options[:input_html].merge({:value => pb.content}) : options[:input_html]
@@ -0,0 +1,15 @@
1
+ module Polyblock
2
+ module CapybaraHelpers
3
+ def fill_in_polyblock(locator, params = {})
4
+ # Find out ckeditor id at runtime using its label
5
+ locator = find('label', text: locator)[:for] if page.has_css?('label', text: locator)
6
+ # Fill the editor content
7
+ page.execute_script <<-SCRIPT
8
+ var ckeditor = CKEDITOR.instances.#{locator}
9
+ ckeditor.setData('#{params[:with]}')
10
+ ckeditor.focus()
11
+ ckeditor.updateElement()
12
+ SCRIPT
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,4 @@
1
+ require 'polyblock/capybara_helpers'
1
2
  require 'polyblock/view_helpers'
2
3
  require 'polyblock/glue'
3
4
 
@@ -10,9 +11,13 @@ module Polyblock
10
11
  Polyblock::Railtie.insert
11
12
  end
12
13
  end
14
+
13
15
  initializer "polyblock.view_helpers" do
14
16
  ActionView::Base.send :include, ViewHelpers
15
17
  end
18
+ # initializer "polyblock.capybara_helpers" do
19
+ # RSpec.send :include, CapybaraHelpers
20
+ # end
16
21
  end
17
22
 
18
23
  class Railtie
@@ -22,4 +27,4 @@ module Polyblock
22
27
  end
23
28
  end
24
29
  end
25
- end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module Polyblock
2
- VERSION = "0.8.8"
3
- end
2
+ VERSION = "0.9.2"
3
+ end
@@ -45,7 +45,7 @@ module Polyblock
45
45
 
46
46
  # Truncation
47
47
  if options[:condensed]
48
- tag_options[:class] += " polyblock-condensed"
48
+ tag_options[:class] += ' polyblock-condensed'
49
49
  truncate(Block.strip_html(content), :length => options[:length], :omission => options[:omission])
50
50
  else
51
51
  content_tag(options[:tag], content, tag_options, false)
@@ -58,13 +58,22 @@ module Polyblock
58
58
  render :partial => 'polyblock/fields_for', :locals => {:f => f, :pb => pb, :name => name, :options => options}
59
59
  end
60
60
 
61
- def simple_fields_for_polyblock(name, f, options={})
62
- options = {
63
- :label => true,
64
- :input_html => {}
65
- }.merge(options)
61
+ def simple_fields_for_polyblock(name, f, settings={})
66
62
  pb = pb_from_name(name, f)
67
- render :partial => 'polyblock/simple_fields_for', :locals => {:f => f, :pb => pb, :name => name, :options => options}
63
+ options = {
64
+ :field => {
65
+ :as => :ckeditor,
66
+ :label => name.to_s.titleize,
67
+ :input_html => {
68
+ :value => pb.present? ? pb.content : nil
69
+ }
70
+ },
71
+ :use_input_field => false
72
+ }.merge(settings)
73
+ # Merge in legacy fields
74
+ [:label, :input_html].each{|o| options[:field][o] = options[o] if options[o].present? }
75
+ render :partial => 'polyblock/simple_fields_for',
76
+ :locals => {:f => f, :pb => pb, :name => name, :options => options}
68
77
  end
69
78
 
70
79
  def simple_form_for_polyblocks(options={})
@@ -80,7 +89,8 @@ module Polyblock
80
89
 
81
90
  private
82
91
  def pb_from_name(name, f)
83
- if name.is_a?(String)
92
+ if name.is_a?(Polyblock::Block) then name
93
+ elsif name.is_a?(String)
84
94
  Block.fetch_or_initialize(name)
85
95
  elsif name.is_a?(Symbol)
86
96
  if f.object.is_a? Block
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyblock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MacKinley Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-07 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -186,6 +186,7 @@ files:
186
186
  - lib/generators/polyblock/install/templates/ckeditor_migration.rb
187
187
  - lib/generators/polyblock/install/templates/polyblock_migration.rb
188
188
  - lib/polyblock.rb
189
+ - lib/polyblock/capybara_helpers.rb
189
190
  - lib/polyblock/engine.rb
190
191
  - lib/polyblock/glue.rb
191
192
  - lib/polyblock/has_polyblock.rb