inline_forms 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- aCopyright (c) 2011 Ace Suares
1
+ Copyright (c) 2011 Ace Suares
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -109,6 +109,7 @@ class InlineFormsController < ApplicationController
109
109
  #
110
110
  # GET /examples/1?field=name&form_element=text
111
111
  #
112
+
112
113
  def show
113
114
  @object = @Klass.find(params[:id])
114
115
  @field = params[:field]
@@ -1,16 +1,28 @@
1
1
  INLINE_FORMS_PATH = File.dirname(__FILE__) + "/form_elements/"
2
2
 
3
3
  Dir[INLINE_FORMS_PATH + "*.rb"].each do |form_element|
4
- require form_element
4
+ require form_element
5
5
  end
6
6
 
7
7
  module InlineFormsHelper
8
- # display the forms from an array of attributes
9
- def inline_form_display(object, attributes, action=:show)
8
+ def inline_form(object, attributes) #, collapsed=true)
10
9
  attributes = [ attributes ] if not attributes[0].is_a?(Array) # make sure we have an array of arrays
11
10
  out = String.new #ugly as hell but that's how content_tag works...
12
- case action
13
- when :show
11
+ # if collapsed
12
+ # then
13
+ # name_cell = content_tag :td, :valign=>'top' do
14
+ # content_tag :div, :class=> "field_name" do
15
+ # h(object.presentation)
16
+ # end
17
+ # end
18
+ # value_cell = content_tag :td, :valign=>'top' do
19
+ # content_tag :div, :class=> "field_value" do
20
+ # link_to 'edit', send( @Klass.to_s.underscore + '_path', object, :update => 'inline_form_list'), :remote => true
21
+ # end
22
+ # end
23
+ # out += content_tag :tr, name_cell + value_cell
24
+ # out += "\n"
25
+ # else
14
26
  attributes.each do | attribute, name, form_element, values |
15
27
  #css_class_id = form_element == :associated ? "subform_#{attribute.to_s}_#{object.id}" : "field_#{attribute.to_s}_#{object.id}"
16
28
  css_class_id = "field_#{attribute.to_s}_#{object.id}"
@@ -22,33 +34,37 @@ module InlineFormsHelper
22
34
  value_cell = content_tag :td, :valign=>'top' do
23
35
  content_tag :div, :class=> "field_value field_#{attribute.to_s} form_element_#{form_element.to_s}" do
24
36
  content_tag :span, :id => css_class_id do
25
- send("#{form_element.to_s}_#{action}", object, attribute, values)
37
+ send("#{form_element.to_s}_show", object, attribute, values)
26
38
  end
27
39
  end
28
40
  end
29
41
  out += content_tag :tr, name_cell + value_cell
30
42
  out += "\n"
31
43
  end
32
- return content_tag :table, raw(out), :cellspacing => 0, :cellpadding => 0
33
- when :new
34
- attributes.each do | attribute, name, form_element, values |
35
- #css_class_id = form_element == :associated ? "subform_#{attribute.to_s}_#{object.id}" : "field_#{attribute.to_s}_#{object.id}"
36
- if not form_element.to_sym == :associated
37
- css_class_id = "field_#{attribute.to_s}_#{object.id}"
38
- name_cell = content_tag :td, :valign=>'top' do
39
- content_tag :div, :class=> "field_name field_#{attribute.to_s} form_element_#{form_element.to_s}" do
40
- h(name)
41
- end
44
+ # end
45
+ return content_tag :table, raw(out), :cellspacing => 0, :cellpadding => 0
46
+ end
47
+
48
+ def inline_form_display_new(object, attributes)
49
+ attributes = [ attributes ] if not attributes[0].is_a?(Array) # make sure we have an array of arrays
50
+ out = String.new #ugly as hell but that's how content_tag works...
51
+ attributes.each do | attribute, name, form_element, values |
52
+ #css_class_id = form_element == :associated ? "subform_#{attribute.to_s}_#{object.id}" : "field_#{attribute.to_s}_#{object.id}"
53
+ if not form_element.to_sym == :associated
54
+ css_class_id = "field_#{attribute.to_s}_#{object.id}"
55
+ name_cell = content_tag :td, :valign=>'top' do
56
+ content_tag :div, :class=> "field_name field_#{attribute.to_s} form_element_#{form_element.to_s}" do
57
+ h(name)
42
58
  end
43
- value_cell = content_tag :td, :valign=>'top' do
44
- content_tag :div, :class=> "field_value field_#{attribute.to_s} form_element_#{form_element.to_s}" do
45
- content_tag :span, :id => css_class_id do
46
- send("#{form_element.to_s}_edit", object, attribute, values)
47
- end
59
+ end
60
+ value_cell = content_tag :td, :valign=>'top' do
61
+ content_tag :div, :class=> "field_value field_#{attribute.to_s} form_element_#{form_element.to_s}" do
62
+ content_tag :span, :id => css_class_id do
63
+ send("#{form_element.to_s}_edit", object, attribute, values)
48
64
  end
49
65
  end
50
- out += content_tag :tr, name_cell + value_cell
51
66
  end
67
+ out += content_tag :tr, name_cell + value_cell
52
68
  end
53
69
  end
54
70
  return content_tag :table, raw(out), :cellspacing => 0, :cellpadding => 0
@@ -58,7 +74,7 @@ module InlineFormsHelper
58
74
  t = ''
59
75
  objects.each do |object|
60
76
  t += content_tag tag do
61
- inline_form_display object, object.respond_to?(:inline_forms_field_list) ? object.inline_forms_field_list : [ :name, 'name', 'text' ]
77
+ inline_form object, object.respond_to?(:inline_forms_field_list) ? object.inline_forms_field_list : [ :name, 'name', 'text' ]
62
78
  end
63
79
  end
64
80
  return raw(t)
@@ -1,7 +1,7 @@
1
1
  <% form_tag send(@Klass.to_s.underscore.pluralize + '_path', :update => @update_span || 'inline_form_list' ),
2
2
  :multipart => true, :remote => true, :class => "edit_form" do -%>
3
3
  <div class="edit_form_field">
4
- <%= inline_form_display(@object, @object.respond_to?(:inline_forms_field_list) ? @object.inline_forms_field_list : [ :name, 'name', :text ], :new) %>
4
+ <%= inline_form_display_new(@object, @object.respond_to?(:inline_forms_field_list) ? @object.inline_forms_field_list : [ :name, 'name', :text ] ) %>
5
5
  </div>
6
6
  <%= link_to( send(@Klass.to_s.underscore.pluralize + '_path',:update => @update_span || 'inline_form_list'), :remote => true,
7
7
  :class => "edit_form_cancel" ) do %>
@@ -4,7 +4,7 @@
4
4
  <head>
5
5
  <title><%= h(yield(:title) || "xyxyxyx") %></title>
6
6
  <%= csrf_meta_tag %>
7
- <%= stylesheet_link_tag 'inline_form_elements' %>
7
+ <%= stylesheet_link_tag 'inline_forms/inline_forms' %>
8
8
  <%= javascript_include_tag :defaults %>
9
9
  <%= yield(:head) %>
10
10
  </head>
data/inline_forms.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{inline_forms}
8
- s.version = "0.5.2"
8
+ s.version = "0.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ace Suares"]
12
- s.date = %q{2011-02-05}
12
+ s.date = %q{2011-02-08}
13
13
  s.description = %q{Inline Forms aims to ease the setup of forms that provide inline editing. The field list can be specified in the model.}
14
14
  s.email = %q{ace@suares.an}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ace Suares
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-05 00:00:00 -04:00
18
+ date: 2011-02-08 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency