dynaspan 0.1.2 → 0.1.3.beta1

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: 7d4b55cf6c429bb1ac873e0a70acd51a16645c83
4
- data.tar.gz: 13e3925cdca42feca1289d938f571d6b9075a5ae
3
+ metadata.gz: f80e4bd299517b42e0fde2effce96b24c2ab859f
4
+ data.tar.gz: 96769dc4258951d0c4e47b5579ae3303566e6ea7
5
5
  SHA512:
6
- metadata.gz: ef2603ad09170b034138d392edc6a66cb2c3af26be3de24a7a44768c8595871928c82d55c5730160bd6df5eb35fe234448509d48a38729e3f05f95ad369a442f
7
- data.tar.gz: f7b67edadbd7efac14e3e75a498424ed36a5a9bba8bbab52be30ee41266647eda7aa535f5b4ef760886a47ea0cea41515278341e02936d7f2ce6b8fee8a43897
6
+ metadata.gz: e65fae87fdec33a773698f90fbb72ecee98a061d91700cd17ff8553b0d266c057cd81c1e1549de4759805750d741ebd26e8438ac44a14238b6e9e2f97413c740
7
+ data.tar.gz: a07cda41584ba51b3bc445ff61762e527dc0388d0bbcbedf96c079ca51187bf1f2c7bb5fa73b914bd111ee288e6f548fcc59d9fc23416a8f1a24c53392fdb0f1
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
+ *.swp
2
3
  *.rbc
3
4
  .idea
4
5
  .bundle
@@ -9,13 +9,18 @@ module Dynaspan
9
9
  dynaspan_text('area', master_ds_object, parameters)
10
10
  end
11
11
 
12
+ def dynaspan_select(master_ds_object,*parameters, &block)
13
+ dynaspan_text('select', master_ds_object, parameters, &block)
14
+ end
15
+
12
16
  private
17
+ module_function
13
18
 
14
- def dynaspan_counter
15
- @count_for_viewspace = @count_for_viewspace.to_i + 1
19
+ def to_id(obj)
20
+ !!obj ? "#{obj.class.name}#{obj.try(:id)}" : ""
16
21
  end
17
22
 
18
- def dynaspan_text(kind, master_ds_object,*parameters)
23
+ def dynaspan_text(kind, master_ds_object,*parameters, &block)
19
24
  parameters.flatten!
20
25
  if parameters.first.is_a? Symbol
21
26
  attr_object = nil
@@ -36,18 +41,25 @@ module Dynaspan
36
41
  remote: true,
37
42
  authenticity_token: true
38
43
  )
44
+ options[:html_options] = ActiveSupport::HashWithIndifferentAccess.new(options[:html_options])
45
+ options[:html_options][:class] = "dyna-span form-control dyna-span-input #{options[:html_options][:class]}"
46
+ options[:html_options].delete_if {|k,v| [:id, :onblur, :onfocus].include? k}
39
47
  render(
40
48
  partial: "dynaspan/dynaspan_text_#{kind}",
41
49
  locals: {
42
50
  master_ds_object: master_ds_object,
43
51
  attr_object: attr_object,
44
52
  attrib: attrib,
45
- unique_ref_id: options.fetch(:unique_id) { dynaspan_counter },
53
+ unique_ref_id: options.fetch(:unique_id) { [to_id(master_ds_object), to_id(attr_object), attrib].join },
46
54
  dyna_span_edit_text: edit_text,
47
55
  hidden_fields: options[:hidden_fields],
48
56
  ds_callback_on_update: options[:callback_on_update],
49
57
  ds_callback_with_values: options[:callback_with_values],
50
- form_for_options: options[:form_for]
58
+ form_for_options: options[:form_for],
59
+ schoices: options[:choices], # For form 'select' field
60
+ soptions: options.fetch(:options) { Hash.new }, # For form 'select' field
61
+ html_options: options[:html_options],
62
+ block: block
51
63
  }
52
64
  )
53
65
  end
@@ -9,10 +9,10 @@
9
9
  <% hidden_fields.each do |hkey, hval| %>
10
10
  <%= a.hidden_field hkey.to_sym, value: hval %>
11
11
  <% end if hidden_fields %>
12
- <%= a.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
12
+ <%= a.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');", **html_options.symbolize_keys %>
13
13
  <% end %>
14
14
  <% else %>
15
- <%= f.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
15
+ <%= f.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');", **html_options.symbolize_keys %>
16
16
  <% hidden_fields.each do |hkey, hval| %>
17
17
  <%= f.hidden_field hkey.to_sym, value: hval %>
18
18
  <% end if hidden_fields %>
@@ -9,10 +9,10 @@
9
9
  <% hidden_fields.each do |hkey, hval| %>
10
10
  <%= a.hidden_field hkey.to_sym, value: hval %>
11
11
  <% end if hidden_fields %>
12
- <%= a.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
12
+ <%= a.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');", **html_options.symbolize_keys %>
13
13
  <% end %>
14
14
  <% else %>
15
- <%= f.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
15
+ <%= f.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');", **html_options.symbolize_keys %>
16
16
  <% hidden_fields.each do |hkey, hval| %>
17
17
  <%= f.hidden_field hkey.to_sym, value: hval %>
18
18
  <% end if hidden_fields %>
@@ -0,0 +1,24 @@
1
+ <%# This is used through the helper method dynaspan_text_field %>
2
+ <div id="dyna_span_block<%= unique_ref_id %>" <%= "data-ds-callback-on-update=\"#{ds_callback_on_update}\" " if ds_callback_on_update.present? %> <%= "data-ds-callback-with-values=\"#{ds_callback_with_values}\" " if ds_callback_with_values.present? %>class='dyna-span<%= ' ds-content-present' if (attr_object.try(attrib).present? || master_ds_object.try(attrib).present?) %>'>
3
+ <%= hidden_field_tag "last_dyna_span_val_#{unique_ref_id}", attr_object.try(attrib) || master_ds_object.try(attrib), id: "last_dyna_span_val_#{unique_ref_id}" %>
4
+ <div id="<%= "dyna_span_div#{unique_ref_id}" %>" style="display:none;">
5
+ <%= form_for(master_ds_object, **form_for_options.symbolize_keys) do |f| %>
6
+ <% if master_ds_object.nested_attributes_options.keys.any? {|i| i.to_s.=~(/#{attr_object.class.try(:model_name).try(:i18n_key).to_s}/) || i.to_s.=~(/#{attr_object.class.try(:table_name)}/) } and !attr_object.nil? %>
7
+ <%= f.fields_for master_ds_object.nested_attributes_options.keys.select {|i| i.to_s.=~(/#{attr_object.class.model_name.i18n_key.to_s}/) || i.to_s.=~(/#{attr_object.class.table_name}/) }.first, attr_object do |a|%>
8
+ <%= a.hidden_field(:id, value: attr_object.id) if attr_object.id.present? %>
9
+ <% hidden_fields.each do |hkey, hval| %>
10
+ <%= a.hidden_field hkey.to_sym, value: hval %>
11
+ <% end if hidden_fields %>
12
+ <%= a.select( attrib, schoices, soptions, {**html_options.symbolize_keys, id: "dyna_span_field_val_#{unique_ref_id}", onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');"}, &block) %>
13
+ <% end %>
14
+ <% else %>
15
+ <%= f.select( attrib, schoices, soptions, {**html_options.symbolize_keys, id: "dyna_span_field_val_#{unique_ref_id}", onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');"}, &block) %>
16
+ <% hidden_fields.each do |hkey, hval| %>
17
+ <%= f.hidden_field hkey.to_sym, value: hval %>
18
+ <% end if hidden_fields %>
19
+ <% end %>
20
+ <% end %>
21
+ </div>
22
+ <%= content_tag 'span', attr_object.try(attrib) || master_ds_object.try(attrib), id: "dyna_span_span#{unique_ref_id}", onclick: "$().dynaspan.upShow('#{unique_ref_id}');", class: 'dyna-span dyna-span-text', style: 'display:block;' %>
23
+ <%= content_tag('div', dyna_span_edit_text, class: 'dyna-span-edit-text pull-right', onclick: "$().dynaspan.upShow('#{unique_ref_id}');", style: 'cursor:pointer;') %>
24
+ </div>
@@ -1,3 +1,3 @@
1
1
  module Dynaspan
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3.beta1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynaspan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-29 00:00:00.000000000 Z
11
+ date: 2015-06-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: In place text editing with AJAX substituting text to input field.
14
14
  email:
@@ -25,6 +25,7 @@ files:
25
25
  - app/helpers/dynaspan/application_helper.rb
26
26
  - app/views/dynaspan/_dynaspan_text_area.html.erb
27
27
  - app/views/dynaspan/_dynaspan_text_field.html.erb
28
+ - app/views/dynaspan/_dynaspan_text_select.html.erb
28
29
  - config/routes.rb
29
30
  - dynaspan.gemspec
30
31
  - lib/assets/javascripts/dynaspan-jquery.js
@@ -48,14 +49,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
49
  version: '2.0'
49
50
  required_rubygems_version: !ruby/object:Gem::Requirement
50
51
  requirements:
51
- - - ">="
52
+ - - ">"
52
53
  - !ruby/object:Gem::Version
53
- version: '0'
54
+ version: 1.3.1
54
55
  requirements:
55
56
  - jQuery
56
57
  - Rails
57
58
  rubyforge_project:
58
- rubygems_version: 2.4.6
59
+ rubygems_version: 2.4.7
59
60
  signing_key:
60
61
  specification_version: 4
61
62
  summary: Text to AJAX editing in place.