au_state_select 1.3 → 1.4

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: 44f06a0865c97fb79c535b1d1e4f369722c832c1
4
- data.tar.gz: 6c9dfe7dd0909b0ffebf54fc76421db4089abb3c
3
+ metadata.gz: 3c76f2217d6874c015863f812a761352cd169575
4
+ data.tar.gz: a068375163474a7f7775c9a4924affeb6687247d
5
5
  SHA512:
6
- metadata.gz: da8a0899bcae10e91d80c090c380d30ac7f7833f270e5ff8fb2e5fda7777115246b74f90d8b4621e0c2bfe77bce2d1e398d49f8f0ca19172ec69030429abeca0
7
- data.tar.gz: 0bf5a3213d7639a7015d0acbc98213110508bf7e405e855c09aacfda6edb5e6460ce4017cb32ca13d870364d66cd64988a6bb7ad27fb673b4191a0f166a33635
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
 
@@ -1,3 +1,3 @@
1
1
  module AuStateSelect
2
- VERSION = "1.3"
2
+ VERSION = "1.4"
3
3
  end
@@ -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.3'
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-07-25 00:00:00.000000000 Z
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