dead_simple_cms 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dead_simple_cms/attribute/type/all.rb +1 -3
- data/lib/dead_simple_cms/attribute/type/base.rb +1 -1
- data/lib/dead_simple_cms/rails/action_view/form_builders/interface.rb +6 -5
- data/lib/dead_simple_cms/rails/action_view/form_builders/simple_form.rb +1 -2
- data/lib/dead_simple_cms/version.rb +1 -1
- data/spec/dead_simple_cms/attribute/type/all_spec.rb +1 -4
- metadata +2 -2
@@ -16,9 +16,7 @@ module DeadSimpleCMS
|
|
16
16
|
private :convert_value
|
17
17
|
end
|
18
18
|
class Boolean < Base
|
19
|
-
self.default_input_type = :
|
20
|
-
|
21
|
-
include CollectionSupport
|
19
|
+
self.default_input_type = :check_box
|
22
20
|
|
23
21
|
def initialize(identifier, options={})
|
24
22
|
options.update(:collection => [true, false], :default => false)
|
@@ -20,7 +20,7 @@ module DeadSimpleCMS
|
|
20
20
|
# Public: a Symbol representing the default input type required for forms
|
21
21
|
class_attribute :default_input_type, :instance_writer => false
|
22
22
|
|
23
|
-
VALID_INPUT_TYPES = [:string, :text, :select, :file, :radio, :datetime].freeze
|
23
|
+
VALID_INPUT_TYPES = [:string, :text, :select, :file, :radio, :datetime, :check_box].freeze
|
24
24
|
|
25
25
|
attr_reader :input_type, :group_hierarchy, :required
|
26
26
|
attr_accessor :section
|
@@ -25,11 +25,12 @@ module DeadSimpleCMS
|
|
25
25
|
def attribute(attribute)
|
26
26
|
label(attribute.identifier, attribute.label) +
|
27
27
|
case attribute.input_type
|
28
|
-
when :string
|
29
|
-
when :text
|
30
|
-
when :file
|
31
|
-
when :select
|
32
|
-
when :radio
|
28
|
+
when :string then text_field(attribute.identifier)
|
29
|
+
when :text then text_area(attribute.identifier)
|
30
|
+
when :file then file_field(attribute.identifier)
|
31
|
+
when :select then select(attribute.identifier, attribute.collection)
|
32
|
+
when :radio then radio_buttons(attribute.identifier, attribute.collection)
|
33
|
+
when :check_box then check_box(attribute.identifier)
|
33
34
|
else raise("Unknown type: #{attribute.identifier}")
|
34
35
|
end
|
35
36
|
end
|
@@ -9,7 +9,7 @@ module DeadSimpleCMS
|
|
9
9
|
include Interface
|
10
10
|
|
11
11
|
# Public: Translation of the Attribute::Type::Base#input_type to :as option for SimpleForm.
|
12
|
-
AS_LOOKUP = Hash.new { |h, k| k }.update(:radio => :radio_buttons)
|
12
|
+
AS_LOOKUP = Hash.new { |h, k| k }.update(:radio => :radio_buttons, :check_box => :boolean)
|
13
13
|
|
14
14
|
self.preview_options = {:target => "_blank"}
|
15
15
|
|
@@ -24,7 +24,6 @@ module DeadSimpleCMS
|
|
24
24
|
options = {:required => attribute.required, :hint => hint, :as => as, :label => attribute.label}
|
25
25
|
if attribute.is_a?(Attribute::Type::CollectionSupport) && (collection = attribute.collection)
|
26
26
|
options[:collection] = collection
|
27
|
-
options[:as] = as
|
28
27
|
options[:include_blank] = false if as==:select
|
29
28
|
end
|
30
29
|
|
@@ -74,10 +74,7 @@ describe DeadSimpleCMS::Attribute::Type::Boolean do
|
|
74
74
|
|
75
75
|
include_context "Attribute Setup"
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
its(:default_input_type) { should == :radio }
|
80
|
-
its(:collection) { should == [true, false] }
|
77
|
+
its(:default_input_type) { should == :check_box }
|
81
78
|
|
82
79
|
describe "#convert_value" do
|
83
80
|
it %{should convert "true" or "1" into TrueClass} do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dead_simple_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
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-
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|