conjoin 0.0.17 → 0.0.18

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: 197761960ad7e57de9136dd8b7a90f57afca8dc6
4
- data.tar.gz: f07bf31b11057f3775c73c10157c15b9baef2e3e
3
+ metadata.gz: 5cc0d0a83c0d27db16e3f86a206e475be6ca121a
4
+ data.tar.gz: 8b07d5de0b60e050dc50a6cc309dc3a833f9bbe4
5
5
  SHA512:
6
- metadata.gz: 18638d895149acf5f8c63b31f9118d1fdb2ef6151b310baa311844d858ea99844b3bc9c3fa229e2316b03087dce281784c8289f78f97fd067535dbbf5fbd0eb9
7
- data.tar.gz: e49f5d89ccf1550d9cdf3826c9a0dda1c6584bb1eb0ef6855d5c4e630fbed5a202a7aa98a530a00e87d1797affcebcf3ea8304aa1cced02400ab86194e87cbb2
6
+ metadata.gz: 4366ee9f8bdc0996862e7a2a85c14cd548a7ebe2323a62f23d5f8bc80b977bfa282e437492bcdb40484372c63f06b4896f9588f6552622639ab62ccfdd8f8182
7
+ data.tar.gz: 89fd0081fed32841af612c46c539cae374ffc0706075c4428014557d645a09136322de7e5e9a1a0be93e8e76712155e720727ee41fe2f33bec32cb9f199975f4
@@ -91,7 +91,7 @@ module Conjoin
91
91
  end
92
92
 
93
93
  def input_field field_name, options = {}
94
- options[:wrapper] = false
94
+ options[:label] = false
95
95
  input field_name, options
96
96
  end
97
97
 
@@ -115,6 +115,8 @@ module Conjoin
115
115
  and mini_column = record_class.mini_record_columns[field_name] \
116
116
  and input_as = mini_column[:input_as]
117
117
  record_type = input_as.to_s.classify
118
+ elsif record_class.respond_to?(field_name) && record_class.send(field_name).is_a?(Enumerize::Attribute)
119
+ record_type = 'Select'
118
120
  else
119
121
  record_type = record_class.columns_hash[field_name.to_s].type.to_s.classify
120
122
  end
@@ -131,14 +133,20 @@ module Conjoin
131
133
  value: record.send(field_name),
132
134
  options: options,
133
135
  errors: record.errors.messages[field_name],
134
- names: names
136
+ names: names,
137
+ field_name: field_name,
138
+ record_class: record_class
135
139
  })
136
140
 
137
141
  new_input = input_class.new data, app, record
138
142
 
139
143
  if record_type != 'Hidden' \
140
144
  and not options.key(:wrapper) and options[:wrapper] != false
141
- wrapper field_name.to_s, nested_name, new_input, options
145
+ if !options.key(:label) and options[:label] != false
146
+ wrapper field_name.to_s, nested_name, new_input, options
147
+ else
148
+ new_input.render
149
+ end
142
150
  else
143
151
  new_input.render
144
152
  end
@@ -1,6 +1,17 @@
1
1
  module Conjoin
2
2
  module FormBuilder
3
3
  class SelectInput < Input
4
+ def select_options
5
+ values_select = {}
6
+ values = data.record_class.send(data.field_name).values
7
+
8
+ values.each do |value|
9
+ values_select[value] = value
10
+ end
11
+
12
+ values_select
13
+ end
14
+
4
15
  def display
5
16
  append_button = options.delete :append_button
6
17
  if options[:multiple]
data/lib/conjoin/nav.rb CHANGED
@@ -26,33 +26,44 @@ module Conjoin
26
26
  self.instance_eval(&block)
27
27
  end
28
28
 
29
- def add_menu name, links
29
+ def nav name, links
30
30
  config.navs[name] ||= []
31
31
  config.navs[name].concat links
32
32
  end
33
33
 
34
34
  def load_nav name
35
35
  if links = config.navs[name]
36
- loaded_links = []
36
+ loaded_links = load_links links
37
+ else
38
+ raise "There isn't a nav called: #{name}"
39
+ end
40
+
41
+ block.call loaded_links
42
+ end
37
43
 
38
- links.each do |link|
39
- link = OpenStruct.new(link)
44
+ def load_links links
45
+ loaded_links = []
40
46
 
41
- if !link.if or app.instance_exec(&link.if)
42
- link.icon = config.icon_class + '-' + link.icon if link.icon
43
- link.active = app.req.env['REQUEST_PATH'][link.path]
44
- link.active_class = link.active ? config.active_class : false
47
+ links.each do |link|
48
+ link = OpenStruct.new(link)
45
49
 
46
- if link.active_class or !link.hidden
47
- loaded_links << link
48
- end
50
+ if !link.if or app.instance_exec(&link.if)
51
+ link.icon = config.icon_class + '-' + link.icon if link.icon
52
+ link.active = app.req.env['REQUEST_PATH'][link.path]
53
+ link.active_class = link.active ? config.active_class : false
54
+ link.id = "nav-#{link.text.underscore}"
55
+
56
+ if link.subs
57
+ link.subs = load_links link.subs
58
+ end
59
+
60
+ if link.active_class or !link.hidden
61
+ loaded_links << link
49
62
  end
50
63
  end
51
- else
52
- raise "There isn't a nav called: #{name}"
53
64
  end
54
65
 
55
- block.call loaded_links
66
+ loaded_links
56
67
  end
57
68
 
58
69
  def config
@@ -1,3 +1,3 @@
1
1
  module Conjoin
2
- VERSION = "0.0.17"
2
+ VERSION = "0.0.18"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjoin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-21 00:00:00.000000000 Z
11
+ date: 2014-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cuba