au_state_select 1.3 → 1.4
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.
- checksums.yaml +4 -4
- data/lib/au_state_select/form_tag_helper.rb +30 -0
- data/lib/au_state_select/instance_tag.rb +0 -1
- data/lib/au_state_select/version.rb +1 -1
- data/lib/au_state_select.rb +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3c76f2217d6874c015863f812a761352cd169575
|
|
4
|
+
data.tar.gz: a068375163474a7f7775c9a4924affeb6687247d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0fc8dd42e967adc8fbf5426b2f4dabb2e45892ce9f9c047ed96d0ec32fdbc916f16c9fdde00280ed341a73512763bd7b094744dfc33b04a9f934537c64fc2be2
|
|
7
|
+
data.tar.gz: b15e61bb9f5ea7f9a41b30ab304b83ea95cee43e581f0947a9864ed7a2d4cb2547b901ff2eabfaff2392e1096af0e861820546715943ae235bdeb078e904c756
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module AUStateSelect
|
|
2
|
+
module FormTagHelper
|
|
3
|
+
def state_select_tag(name, priority_countries = nil, options = {}, html_options = {})
|
|
4
|
+
|
|
5
|
+
states = ""
|
|
6
|
+
|
|
7
|
+
if options.present? and (options[:include_blank] or (options[:prompt]))
|
|
8
|
+
if options[:include_blank].present?
|
|
9
|
+
option = options[:include_blank] == true ? "" : options[:include_blank]
|
|
10
|
+
elsif options[:prompt].present?
|
|
11
|
+
option = options[:prompt] == true ? "Please Select" : options[:prompt]
|
|
12
|
+
end
|
|
13
|
+
states += "<option>#{option}</option>\n"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
select_options = if options.key?(:short_name) and options[:short_name]
|
|
17
|
+
['ACT', 'NSW', 'NT', 'QLD', 'SA', 'TAS', 'VIC', 'WA']
|
|
18
|
+
else
|
|
19
|
+
[['Australian Capital Territory', 'ACT'],['New South Wales', 'NSW'],['Northern Territory', 'NT'],['Queensland', 'QLD'],['South Australia', 'SA'],['Tasmania', 'TAS'],['Victoria', 'VIC'],['Western Australia', 'WA']]
|
|
20
|
+
end
|
|
21
|
+
states = states + options_for_select(select_options)
|
|
22
|
+
|
|
23
|
+
html_options = html_options.stringify_keys
|
|
24
|
+
|
|
25
|
+
attribute_id = options[:id] || name
|
|
26
|
+
|
|
27
|
+
content_tag(:select, states.html_safe, { "name" => name, "id" => sanitize_to_id(attribute_id) }.update(html_options.stringify_keys))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -9,7 +9,6 @@ module AUStateSelect
|
|
|
9
9
|
state_select(priority_states, options, html_options)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
# Adapted from Rails country_select. Just uses country codes instead of full names.
|
|
13
12
|
def state_select(priority_states, options, html_options)
|
|
14
13
|
selected = object.send(@method_name) if object.respond_to?(@method_name)
|
|
15
14
|
|
data/lib/au_state_select.rb
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
require "au_state_select/version"
|
|
2
2
|
require "au_state_select/form_helpers"
|
|
3
|
+
require "au_state_select/form_tag_helper"
|
|
3
4
|
require "au_state_select/instance_tag"
|
|
4
5
|
require "au_state_select/form_builder"
|
|
5
6
|
|
|
6
7
|
ActionView::Base.send(:include, AUStateSelect::FormHelpers)
|
|
8
|
+
ActionView::Base.send(:include, AUStateSelect::FormTagHelper)
|
|
9
|
+
|
|
7
10
|
if Rails::VERSION::MAJOR >= 4
|
|
8
11
|
ActionView::Helpers::ActiveModelInstanceTag.send(:include, AUStateSelect::InstanceTag)
|
|
9
12
|
else
|
|
@@ -11,5 +14,4 @@ else
|
|
|
11
14
|
end
|
|
12
15
|
ActionView::Helpers::FormBuilder.send(:include, AUStateSelect::FormBuilder)
|
|
13
16
|
|
|
14
|
-
|
|
15
17
|
require 'au_state_select/railtie' if defined?(Rails) and defined?(SimpleForm)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: au_state_select
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '1.
|
|
4
|
+
version: '1.4'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Zhang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-08-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -54,6 +54,7 @@ files:
|
|
|
54
54
|
- lib/au_state_select.rb
|
|
55
55
|
- lib/au_state_select/form_builder.rb
|
|
56
56
|
- lib/au_state_select/form_helpers.rb
|
|
57
|
+
- lib/au_state_select/form_tag_helper.rb
|
|
57
58
|
- lib/au_state_select/instance_tag.rb
|
|
58
59
|
- lib/au_state_select/railtie.rb
|
|
59
60
|
- lib/au_state_select/version.rb
|