dynaspan 0.0.2 → 0.0.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f8b73f36695b138e19ccd95826d193c1f7061b8
|
4
|
+
data.tar.gz: ca04cf602966198137fa0c854c06ffc19c4faee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5315e4d995d22b236baa87ddd6f0db6ea84c2a35cad2a67f1779b4bf85758d0fbd90c04cdbccc68e668575118bf715f89dd3a12d18bfab6823f0c53df703de1b
|
7
|
+
data.tar.gz: 03997513b56b647565c1019402ded5c98abbb90d3ec7b0270c7042cc24799fc1416682aacada8bf7d744613f9cb145b96844280c8861c3e29ebd75aef0f60ecf
|
data/README.md
CHANGED
@@ -13,6 +13,12 @@ Dynaspan also accepts updating an attribute for a nested object, but only 1 leve
|
|
13
13
|
|
14
14
|
###Usage
|
15
15
|
|
16
|
+
Example:
|
17
|
+
|
18
|
+
dynaspan_text_field(@article, comment, :note, '[edit]')
|
19
|
+
|
20
|
+
This will show the value of note in the comment object as plain text. It can be clicked on to instantly become a text field input. And once unselected the `@article` object will update with its nested attribute object `comment` and its new value in the `note` attribute.
|
21
|
+
|
16
22
|
You can use either `dynaspan_text_field` or `dynaspan_text_area` in any of your views. There are two mandatory parameters. The first is a the main Object model instance you will be updating. And the other mandatory field is the symbol of the attribute to update. There are two optional fields. The first is the nested attribute object which will have its field updated. And the last is the optional text for `[edit]`-ing (clicking on to edit which is useful for blank fields).
|
17
23
|
|
18
24
|
dynaspan_text_field(Object,OptionalNestedObject,SymField,OptionalEditText)
|
@@ -1,16 +1,16 @@
|
|
1
|
-
<%# This is used through the helper method
|
1
|
+
<%# This is used through the helper method dynaspan_text_area %>
|
2
2
|
<%= 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}" %>
|
3
3
|
<div id="<%= "dyna_span_div#{unique_ref_id}" %>" class='dyna-span' style="display:none;">
|
4
4
|
<%= form_for(master_ds_object, method: :patch, remote: true, authenticity_token: true) do |f| %>
|
5
5
|
<% 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? %>
|
6
6
|
<%= 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|%>
|
7
7
|
<%= a.hidden_field :id, value: attr_object.id %>
|
8
|
-
<%= a.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control', onfocus: "$().
|
8
|
+
<%= a.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
9
9
|
<% end %>
|
10
10
|
<% else %>
|
11
|
-
<%= f.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control', onfocus: "$().
|
11
|
+
<%= f.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
12
12
|
<% end %>
|
13
13
|
<% end %>
|
14
14
|
</div>
|
15
|
-
<%= content_tag 'span', attr_object.try(attrib) || master_ds_object.try(attrib), id: "dyna_span_span#{unique_ref_id}", onclick: "$().
|
16
|
-
<%= content_tag('div', dyna_span_edit_text, class: 'dyna-span-edit-text pull-right', onclick: "$().
|
15
|
+
<%= 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;' %>
|
16
|
+
<%= content_tag('div', dyna_span_edit_text, class: 'dyna-span-edit-text pull-right', onclick: "$().dynaspan.upShow('#{unique_ref_id}');", style: 'cursor:pointer;') %>
|
@@ -1,16 +1,16 @@
|
|
1
|
-
<%# This is used through the helper method
|
1
|
+
<%# This is used through the helper method dynaspan_text_field %>
|
2
2
|
<%= 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}" %>
|
3
3
|
<div id="<%= "dyna_span_div#{unique_ref_id}" %>" class='dyna-span' style="display:none;">
|
4
4
|
<%= form_for(master_ds_object, method: :patch, remote: true, authenticity_token: true) do |f| %>
|
5
5
|
<% 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? %>
|
6
6
|
<%= 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|%>
|
7
7
|
<%= a.hidden_field :id, value: attr_object.id %>
|
8
|
-
<%= a.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control', onfocus: "$().
|
8
|
+
<%= a.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
9
9
|
<% end %>
|
10
10
|
<% else %>
|
11
|
-
<%= f.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control', onfocus: "$().
|
11
|
+
<%= f.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
12
12
|
<% end %>
|
13
13
|
<% end %>
|
14
14
|
</div>
|
15
|
-
<%= content_tag 'span', attr_object.try(attrib) || master_ds_object.try(attrib), id: "dyna_span_span#{unique_ref_id}", onclick: "$().
|
16
|
-
<%= content_tag('div', dyna_span_edit_text, class: 'dyna-span-edit-text pull-right', onclick: "$().
|
15
|
+
<%= 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;' %>
|
16
|
+
<%= content_tag('div', dyna_span_edit_text, class: 'dyna-span-edit-text pull-right', onclick: "$().dynaspan.upShow('#{unique_ref_id}');", style: 'cursor:pointer;') %>
|
data/lib/dynaspan/version.rb
CHANGED