ajaxcrud 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +1 -0
  4. data/ajaxcrud.gemspec +24 -0
  5. data/lib/ajaxcrud/version.rb +3 -0
  6. data/lib/ajaxcrud.rb +5 -0
  7. data/lib/generators/ajaxcrud/USAGE +8 -0
  8. data/lib/generators/ajaxcrud/ajaxcrud_generator.rb +56 -0
  9. data/lib/generators/ajaxcrud/templates/assets/ajaxcrud.css.scss +104 -0
  10. data/lib/generators/ajaxcrud/templates/assets/success.png +0 -0
  11. data/lib/generators/ajaxcrud/templates/controllers/models_controller.rb +81 -0
  12. data/lib/generators/ajaxcrud/templates/helpers/ajaxcrud_helper.rb +34 -0
  13. data/lib/generators/ajaxcrud/templates/helpers/models_helper.rb +2 -0
  14. data/lib/generators/ajaxcrud/templates/migration.rb +12 -0
  15. data/lib/generators/ajaxcrud/templates/models/.gitkeep +0 -0
  16. data/lib/generators/ajaxcrud/templates/models/model.rb +2 -0
  17. data/lib/generators/ajaxcrud/templates/test/fixtures/.gitkeep +0 -0
  18. data/lib/generators/ajaxcrud/templates/test/fixtures/models.yml +25 -0
  19. data/lib/generators/ajaxcrud/templates/test/functional/.gitkeep +0 -0
  20. data/lib/generators/ajaxcrud/templates/test/functional/models_controller_test.rb +49 -0
  21. data/lib/generators/ajaxcrud/templates/test/unit/.gitkeep +0 -0
  22. data/lib/generators/ajaxcrud/templates/test/unit/helpers/models_helper_test.rb +4 -0
  23. data/lib/generators/ajaxcrud/templates/test/unit/model_test.rb +7 -0
  24. data/lib/generators/ajaxcrud/templates/views/_form.html.erb +31 -0
  25. data/lib/generators/ajaxcrud/templates/views/_item.html.erb +13 -0
  26. data/lib/generators/ajaxcrud/templates/views/create.js.erb +11 -0
  27. data/lib/generators/ajaxcrud/templates/views/destroy.js.erb +2 -0
  28. data/lib/generators/ajaxcrud/templates/views/edit.js.erb +3 -0
  29. data/lib/generators/ajaxcrud/templates/views/index.html.erb +28 -0
  30. data/lib/generators/ajaxcrud/templates/views/search.js.erb +1 -0
  31. data/lib/generators/ajaxcrud/templates/views/show.html.erb +9 -0
  32. data/lib/generators/ajaxcrud/templates/views/update.js.erb +10 -0
  33. metadata +97 -0
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ajaxcrud.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/ajaxcrud.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ajaxcrud/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ajaxcrud"
7
+ s.version = Ajaxcrud::VERSION
8
+ s.authors = ["Viko Nava"]
9
+ s.email = ["viko.nava@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Scaffolding with Ajax}
12
+ s.description = %q{Creates complete scaffolds using ajax to create, edit and destroy on the same page. Also includes a real-time search field.}
13
+
14
+ s.rubyforge_project = "ajaxcrud"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
@@ -0,0 +1,3 @@
1
+ module Ajaxcrud
2
+ VERSION = "0.9.0"
3
+ end
data/lib/ajaxcrud.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "ajaxcrud/version"
2
+
3
+ module Ajaxcrud
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate ajaxcrud Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,56 @@
1
+ class AjaxcrudGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ argument :name, :type => :string
4
+ argument :attributes, :type => :array, :default => [], :banner => "field:type:boolean field:type:boolean"
5
+
6
+ def get_search_attributes
7
+ @search_attributes = Array.new
8
+ attributes.each do |attribute|
9
+ attribute = attribute.split(':');
10
+ if !attribute[2].nil? && attribute[2].downcase == 'true'
11
+ @search_attributes.push(attribute[0]+":"+attribute[1]);
12
+ end
13
+ end
14
+ end
15
+
16
+ def generators
17
+ template "migration.rb", "db/migrate/#{timestamp}_create_#{plural_model}.rb"
18
+ template "models/model.rb", "app/models/#{model_name}.rb"
19
+ template "test/unit/model_test.rb", "test/unit/#{model_name}_test.rb"
20
+ template "test/fixtures/models.yml", "test/fixtures/#{plural_model}.yml"
21
+ route "resources :#{plural_model}"
22
+ route "match '#{model_name}/search' => '#{plural_model}#search'"
23
+
24
+ template "views/create.js.erb", "app/views/#{plural_model}/create.js.erb"
25
+ template "views/destroy.js.erb", "app/views/#{plural_model}/destroy.js.erb"
26
+ template "views/edit.js.erb", "app/views/#{plural_model}/edit.js.erb"
27
+ template "views/_form.html.erb", "app/views/#{plural_model}/_form.html.erb"
28
+ template "views/index.html.erb", "app/views/#{plural_model}/index.html.erb"
29
+ template "views/_item.html.erb", "app/views/#{plural_model}/_#{model_name}.html.erb"
30
+ template "views/search.js.erb", "app/views/#{plural_model}/search.js.erb"
31
+ template "views/show.html.erb", "app/views/#{plural_model}/show.html.erb"
32
+ template "views/update.js.erb", "app/views/#{plural_model}/update.js.erb"
33
+ template "controllers/models_controller.rb", "app/controllers/#{plural_model}_controller.rb"
34
+
35
+ template "test/unit/helpers/models_helper_test.rb", "test/unit/helpers/#{plural_model}_helper_test.rb"
36
+ template "helpers/models_helper.rb", "app/helpers/#{plural_model}_helper.rb"
37
+ copy_file "helpers/ajaxcrud_helper.rb", "app/helpers/ajaxcrud_helper.rb"
38
+ inject_into_file "app/helpers/application_helper.rb", " include AjaxcrudHelper\n", :after => "module ApplicationHelper\n"
39
+ copy_file "assets/ajaxcrud.css.scss", "app/assets/stylesheets/ajaxcrud.css.scss"
40
+ copy_file "assets/success.png", "app/assets/stylesheets/images/success.png"
41
+ end
42
+
43
+ private
44
+
45
+ def model_name
46
+ name.singularize.downcase
47
+ end
48
+
49
+ def timestamp
50
+ Time.now.utc.strftime("%Y%m%d%k%M%S")
51
+ end
52
+
53
+ def plural_model
54
+ model_name.pluralize
55
+ end
56
+ end
@@ -0,0 +1,104 @@
1
+ body {
2
+ background-color: #fff;
3
+ color: #333;
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px; }
7
+
8
+ p, ol, ul, td {
9
+ font-family: verdana, arial, helvetica, sans-serif;
10
+ font-size: 13px;
11
+ line-height: 18px; }
12
+
13
+ pre {
14
+ background-color: #eee;
15
+ padding: 10px;
16
+ font-size: 11px; }
17
+
18
+ a {
19
+ color: #000;
20
+ &:visited {
21
+ color: #666; }
22
+ &:hover {
23
+ color: #fff;
24
+ background-color: #000; } }
25
+
26
+ div {
27
+ &.field, &.actions {
28
+ margin-bottom: 10px; } }
29
+
30
+ #notice {
31
+ color: green; }
32
+
33
+ .field_with_errors {
34
+ padding: 2px;
35
+ background-color: red;
36
+ display: table; }
37
+
38
+ #error_explanation {
39
+ border: 2px solid red;
40
+ padding: 7px;
41
+ padding-bottom: 0;
42
+ margin-bottom: 20px;
43
+ background-color: #f0f0f0;
44
+ h2 {
45
+ text-align: left;
46
+ font-weight: bold;
47
+ padding: 5px 5px 5px 15px;
48
+ font-size: 12px;
49
+ margin: -7px;
50
+ margin-bottom: 0px;
51
+ background-color: #c00;
52
+ color: #fff; }
53
+ ul li {
54
+ font-size: 12px;
55
+ list-style: square; } }
56
+
57
+ .success {
58
+ display: none;
59
+ margin: 0 auto;
60
+ margin-top: 10px;
61
+ padding: 7px 10px;
62
+ padding-left: 45px;
63
+ background: palegreen url('images/success.png') no-repeat;
64
+ color: forestgreen;
65
+ font-weight: bold;
66
+ border: 2px solid forestgreen;
67
+ border-radius: 10px;
68
+ -moz-border-radius: 10px;
69
+ -webkit-border-radius: 10px;
70
+ width: 98%;
71
+ }
72
+
73
+ .index_table td {
74
+ padding: 5px;
75
+ }
76
+
77
+ .index_table {
78
+ border-spacing: 0;
79
+ min-width: 400px;
80
+ thead {
81
+ font-size: 17px;
82
+ tr {
83
+ background-color: #3299bb;
84
+ color: #ffffff;
85
+ th {
86
+ text-align: center;
87
+ padding: 5px 10px;
88
+ }
89
+ }
90
+ }
91
+ tbody {
92
+ tr {
93
+ background-color: #e9e9e9;
94
+ color: #424242;
95
+ td {
96
+ padding: 5px 10px;
97
+ }
98
+ }
99
+ tr:hover {
100
+ background-color: #FFCC66;
101
+ color: #000000;
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,81 @@
1
+ class <%= plural_model.capitalize %>Controller < ApplicationController
2
+ def index
3
+ @<%= plural_model %> = <%= model_name.capitalize %>.all
4
+ @<%= model_name %> = <%= model_name.capitalize %>.new
5
+
6
+ respond_to do |format|
7
+ format.html
8
+ end
9
+ end
10
+
11
+ def search
12
+ query = "<%
13
+ @search_attributes.each do |attribute|
14
+ attribute = attribute.split(':')
15
+ %><%= attribute[0] %> LIKE ? OR <%
16
+ end
17
+ %>1 > ?"
18
+
19
+ @<%= plural_model %> = <%= model_name.capitalize %>.where(query, <%
20
+ attributes.each do |attribute|
21
+ attribute = attribute.split(':')
22
+ if !attribute[2].nil? && attribute[2] == "true"
23
+ %>"%#{params[:q]}%", <%
24
+ end
25
+ end
26
+ %> 2)
27
+
28
+ respond_to do |format|
29
+ format.js
30
+ end
31
+ end
32
+
33
+ def show
34
+ @<%= model_name %> = <%= model_name.capitalize %>.find(params[:id])
35
+
36
+ render :layout => false
37
+ end
38
+
39
+ def showjs
40
+ @<%= model_name %> = <%= model_name.capitalize %>.find(params[:id])
41
+
42
+ respond_to do |format|
43
+ format.js
44
+ end
45
+ end
46
+
47
+ def edit
48
+ @<%= model_name %> = <%= model_name.capitalize %>.find(params[:id])
49
+
50
+ respond_to do |format|
51
+ format.js
52
+ end
53
+ end
54
+
55
+ def create
56
+ @<%= model_name %> = <%= model_name.capitalize %>.new(params[:<%= model_name %>])
57
+ @<%= model_name %>.save
58
+
59
+ respond_to do |format|
60
+ format.js
61
+ end
62
+ end
63
+
64
+ def update
65
+ @<%= model_name %> = <%= model_name.capitalize %>.find(params[:id])
66
+ @<%= model_name %>.update_attributes(params[:<%= model_name %>])
67
+
68
+ respond_to do |format|
69
+ format.js
70
+ end
71
+ end
72
+
73
+ def destroy
74
+ @<%= model_name %> = <%= model_name.capitalize %>.find(params[:id])
75
+ @<%= model_name %>.destroy
76
+
77
+ respond_to do |format|
78
+ format.js
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,34 @@
1
+ module AjaxcrudHelper
2
+ def ajaxcrud_init_js(record_name, record_new_text, record_info_text)
3
+ ("$(function() { $('button').button(); $('#"+record_name.pluralize+"_dialog').dialog({ autoOpen: false, modal: true, title: '"+record_new_text+"', resizable: false, draggable: false, close: function() { $('#error_explanation').html('').hide(); } }); $('#"+record_name+"_info').dialog({ autoOpen: false, modal: true, title: '"+record_info_text+"', resizable: false, draggable: false }); $('#"+record_name.pluralize+"_search_field').keyup(function() { $.ajax({url:'/"+record_name+"/search?q='+($(this).val())}); }); });").html_safe
4
+ end
5
+
6
+ def ajaxcrud_record_js(record_name, record_new_text)
7
+ ("function viewInfo("+record_name+") { $('#"+record_name+"_info').load("+record_name+", function() { $('#"+record_name.pluralize+"_dialog').dialog('option','width','auto').dialog('option','height','auto').dialog('option','position','center'); $('#"+record_name+"_info').dialog('open'); }); } function new"+record_name.capitalize+"() { $('#"+record_name.pluralize+"_dialog').dialog('open'); $('#"+record_name.pluralize+"_dialog').dialog('option','title','"+record_new_text+"'); $(\".edit_"+record_name+"\").replaceWith(\""+escape_javascript(render(:partial => "form"))+"\"); $(\".new_"+record_name+"\")[0].reset(); $('#"+record_name.pluralize+"_dialog').dialog('option','width','auto').dialog('option','height','auto').dialog('option','position','center'); }").html_safe
8
+ end
9
+
10
+ def ajaxcrud_js(record_name, record_new_text, record_info_text)
11
+ ("<script>"+ajaxcrud_init_js(record_name,record_new_text,record_info_text)+"\n"+ajaxcrud_record_js(record_name,record_new_text)+"</script>").html_safe
12
+ end
13
+
14
+ def ajaxcrud_dialogbox(record_name)
15
+ ("<div id=\""+record_name.pluralize+"_dialog\"><div id=\"form\">"+render(:partial => "form")+"</div></div><div id=\""+record_name+"_info\"></div>").html_safe
16
+ end
17
+
18
+ def ajaxcrud_notices(record_name)
19
+ ("<div id=\""+record_name.pluralize+"_success\" class=\"success\"></div>").html_safe
20
+ end
21
+
22
+ def ajaxcrud_search(record_name)
23
+ ("<input id=\""+record_name.pluralize+"_search_field\"/>").html_safe
24
+ end
25
+
26
+ def ajaxcrud_new_link(record_name)
27
+ ("javascript:new"+record_name.capitalize+"();").html_safe
28
+ end
29
+
30
+ def ajaxcrud_show_link(path)
31
+ ("javascript:viewInfo('"+path+"');").html_safe
32
+ end
33
+ end
34
+
@@ -0,0 +1,2 @@
1
+ module <%= plural_model.capitalize %>Helper
2
+ end
@@ -0,0 +1,12 @@
1
+ class Create<%= plural_model.capitalize %> < ActiveRecord::Migration
2
+ def change
3
+ create_table :<%= plural_model %> do |t|<%
4
+ attributes.each do |attribute|
5
+ attribute = attribute.split(':') %>
6
+ t.<%= attribute[1] %> :<%= attribute[0] %><%
7
+ end
8
+ %>
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ class <%= model_name.capitalize %> < ActiveRecord::Base
2
+ end
@@ -0,0 +1,25 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:<%
4
+ attributes.each do |attribute|
5
+ attribute = attribute.split(':')
6
+ attribute[1] = "MyString" if attribute[1].downcase == "tring"
7
+ attribute[1] = "My Text" if attribute[1].downcase == "text"
8
+ attribute[1] = "1" if attribute[1].downcase == "integer"
9
+ attribute[1] = "1.0" if attribute[1].downcase == "float"
10
+ attribute[1] = "true" if attribute[1].downcase == "boolean"%>
11
+ <%= attribute[0] %>: <%= attribute[1] %><%
12
+ end
13
+ %>
14
+
15
+ two:<%
16
+ attributes.each do |attribute|
17
+ attribute = attribute.split(':')
18
+ attribute[1] = "MyString" if attribute[1].downcase == "tring"
19
+ attribute[1] = "My Text" if attribute[1].downcase == "text"
20
+ attribute[1] = "1" if attribute[1].downcase == "integer"
21
+ attribute[1] = "1.0" if attribute[1].downcase == "float"
22
+ attribute[1] = "true" if attribute[1].downcase == "boolean"%>
23
+ <%= attribute[0] %>: <%= attribute[1] %><%
24
+ end
25
+ %>
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_model.capitalize %>ControllerTest < ActionController::TestCase
4
+ setup do
5
+ @<%= model_name %> =<%= plural_model %>(:one)
6
+ end
7
+
8
+ test "should get index" do
9
+ get :index
10
+ assert_response :success
11
+ assert_not_nil assigns(:<%= plural_model %>)
12
+ end
13
+
14
+ test "should get new" do
15
+ get :new
16
+ assert_response :success
17
+ end
18
+
19
+ test "should create <%= model_name %>" do
20
+ assert_difference('<%= model_name.capitalize %>.count') do
21
+ post :create, :<%= model_name %> => @<%= model_name %>.attributes
22
+ end
23
+
24
+ assert_redirected_to <%= model_name %>_path(assigns(:<%= model_name %>))
25
+ end
26
+
27
+ test "should show <%= model_name %>" do
28
+ get :show, :id => @<%= model_name %>.to_param
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get edit" do
33
+ get :edit, :id => @<%= model_name %>.to_param
34
+ assert_response :success
35
+ end
36
+
37
+ test "should update <%= model_name %>" do
38
+ put :update, :id => @<%= model_name %>.to_param, :<%= model_name %> => @<%= model_name %>.attributes
39
+ assert_redirected_to <%= model_name %>_path(assigns(:<%= model_name %>))
40
+ end
41
+
42
+ test "should destroy <%= model_name %>" do
43
+ assert_difference('<%= model_name.capitalize %>.count', -1) do
44
+ delete :destroy, :id => @<%= model_name %>.to_param
45
+ end
46
+
47
+ assert_redirected_to <%= plural_model %>_path
48
+ end
49
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_model.capitalize %>HelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= model_name.capitalize %>Test < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,31 @@
1
+ <div id="error_explanation" style="display:none"></div>
2
+ <%%= form_for(@<%= model_name %>, :remote => true) do |f| %><%
3
+ attributes.each do |attribute|
4
+ attribute = attribute.split(':')
5
+ type = "text_field"
6
+ if attribute[1].downcase == "text"
7
+ type = "text_area"
8
+ elsif attribute[1].downcase == "integer" || attribute[1].downcase == "float" || attribute[1].downcase == "decimal"
9
+ type = "number_field"
10
+ elsif attribute[1].downcase == "datetime"
11
+ type = "datetime_select"
12
+ elsif attribute[1].downcase == "time"
13
+ type = "time_select"
14
+ elsif attribute[1].downcase == "date"
15
+ type = "date_select"
16
+ elsif attribute[1].downcase == "boolean"
17
+ type = "check_box"
18
+ else
19
+ type = "text_field"
20
+ end
21
+ %>
22
+ <p>
23
+ <%%= f.label :<%= attribute[0] %> %><br />
24
+ <%%= f.<%= type %> :<%= attribute[0] %> %>
25
+ </p><%
26
+ end
27
+ %>
28
+ <p class="actions">
29
+ <%%= f.submit @action %>
30
+ </p>
31
+ <%% end %>
@@ -0,0 +1,13 @@
1
+ <tr id="<%%= dom_id(<%= model_name %>) %>"><%
2
+ @search_attributes.each do |attribute|
3
+ attribute = attribute.split(':') %>
4
+ <td><%%= <%= model_name %>.<%= attribute[0] %> %></td><%
5
+ end
6
+ %>
7
+ <td>
8
+ <%%= link_to 'Show', ajaxcrud_show_link(<%= model_name %>_path(<%= model_name %>)) %>
9
+ <%%= link_to 'Edit', edit_<%= model_name %>_path(<%= model_name %>), :remote => true %>
10
+ <%%= link_to 'Destroy', <%= model_name %>, :confirm => 'Are you sure?', :method => :delete, :remote => true %>
11
+ </td>
12
+ </tr>
13
+
@@ -0,0 +1,11 @@
1
+ <%% if @<%= model_name %>.errors.any? %>
2
+ var x = "<h2><%%= pluralize(@<%= model_name %>.errors.count, "error") %> prohibited this user from being saved:</h2><ul><%% @<%= model_name %>.errors.full_messages.each do |msg| %><li><%%= msg %></li><%% end %></ul></div>"
3
+ $('#error_explanation').html(x).show();
4
+ $('#<%= plural_model %>_dialog').dialog('option','position','center');
5
+ <%% else %>
6
+ $('#<%= plural_model %>_dialog').dialog('close');
7
+ $.ajax({url:'/<%= model_name %>/search?q='+($('#<%= plural_model %>_search_field').val())});
8
+ $("#new_<%= model_name %>")[0].reset();
9
+ $('#<%= plural_model %>_success').html('<%= model_name.capitalize %> was successfully created.').slideToggle('slow').delay(1500).slideToggle('slow');
10
+ <%% end %>
11
+ <%% @<%= model_name %>.errors.clear() %>
@@ -0,0 +1,2 @@
1
+ $('#<%%= dom_id @<%= model_name %> %>').remove();
2
+ $('#<%= plural_model %>_success').html('<%= model_name.capitalize %> was successfully destroyed.').slideToggle('slow').delay(1500).slideToggle('slow');
@@ -0,0 +1,3 @@
1
+ $("#form > form").replaceWith("<%%= escape_javascript(render(:partial => "form"))%>");
2
+ $("#<%= plural_model %>_dialog").dialog("option", "title", "Edit <%= model_name.capitalize %>");
3
+ $("#<%= plural_model %>_dialog").dialog('open');
@@ -0,0 +1,28 @@
1
+ <%%= ajaxcrud_js('<%= model_name %>','New <%= model_name.capitalize %>','View <%= model_name.capitalize %>') %>
2
+ <%%= ajaxcrud_notices('<%= model_name %>') %>
3
+
4
+ <h1><%= model_name.capitalize %></h1>
5
+
6
+ <p>
7
+ Search: <%%= ajaxcrud_search('<%= model_name %>') %>
8
+ </p>
9
+ <a href="<%%= ajaxcrud_new_link('<%= model_name %>') %>">New <%= model_name.capitalize %></a>
10
+ <table id="<%= plural_model %>" class="index_table">
11
+ <thead>
12
+ <tr><%
13
+ @search_attributes.each do |attribute|
14
+ attribute = attribute.split(':') %>
15
+ <th><%= attribute[0].capitalize %></th><%
16
+ end
17
+ %>
18
+ <th></th>
19
+ </tr>
20
+ </thead>
21
+ <tbody id="<%= plural_model %>_data">
22
+ <%%= render @<%= plural_model %> %>
23
+ </tbody>
24
+ </table>
25
+
26
+ <br />
27
+
28
+ <%%= ajaxcrud_dialogbox('<%= model_name %>') %>
@@ -0,0 +1 @@
1
+ $('#<%= plural_model %>_data').html('<%%= escape_javascript(render(@<%= plural_model %>))%>');
@@ -0,0 +1,9 @@
1
+ <%
2
+ attributes.each do |attribute|
3
+ attribute = attribute.split(':')%>
4
+ <p>
5
+ <strong><%= attribute[0] %>:</strong>
6
+ <%%= @<%= model_name %>.<%= attribute[0] %> %>
7
+ </p><%
8
+ end
9
+ %>
@@ -0,0 +1,10 @@
1
+ <%% if @<%= model_name %>.errors.any? %>
2
+ var x = "<h2><%%= pluralize(@<%= model_name %>.errors.count, "error") %> prohibited this user from being saved:</h2><ul><%% @<%= model_name %>.errors.full_messages.each do |msg| %><li><%%= msg %></li><%% end %></ul></div>"
3
+ $('#error_explanation').html(x).show();
4
+ $('#<%= plural_model %>_dialog').dialog('option','position','center');
5
+ <%% else %>
6
+ $("#<%= plural_model %>_dialog").dialog('close');
7
+ $("#<%%= dom_id(@<%= model_name %>) %>").replaceWith("<%%= escape_javascript(render(:partial => @<%= model_name %>)) %>");
8
+ <%% @<%= model_name %> = <%= model_name.capitalize %>.new %>
9
+ $('#<%= plural_model %>_success').html('<%= model_name.capitalize %> was successfully updated.').slideToggle('slow').delay(1500).slideToggle('slow');
10
+ <%% end %>
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ajaxcrud
3
+ version: !ruby/object:Gem::Version
4
+ hash: 59
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
11
+ platform: ruby
12
+ authors:
13
+ - Viko Nava
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-10-22 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Creates complete scaffolds using ajax to create, edit and destroy on the same page. Also includes a real-time search field.
22
+ email:
23
+ - viko.nava@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - Rakefile
34
+ - ajaxcrud.gemspec
35
+ - lib/ajaxcrud.rb
36
+ - lib/ajaxcrud/version.rb
37
+ - lib/generators/ajaxcrud/USAGE
38
+ - lib/generators/ajaxcrud/ajaxcrud_generator.rb
39
+ - lib/generators/ajaxcrud/templates/assets/ajaxcrud.css.scss
40
+ - lib/generators/ajaxcrud/templates/assets/success.png
41
+ - lib/generators/ajaxcrud/templates/controllers/models_controller.rb
42
+ - lib/generators/ajaxcrud/templates/helpers/ajaxcrud_helper.rb
43
+ - lib/generators/ajaxcrud/templates/helpers/models_helper.rb
44
+ - lib/generators/ajaxcrud/templates/migration.rb
45
+ - lib/generators/ajaxcrud/templates/models/.gitkeep
46
+ - lib/generators/ajaxcrud/templates/models/model.rb
47
+ - lib/generators/ajaxcrud/templates/test/fixtures/.gitkeep
48
+ - lib/generators/ajaxcrud/templates/test/fixtures/models.yml
49
+ - lib/generators/ajaxcrud/templates/test/functional/.gitkeep
50
+ - lib/generators/ajaxcrud/templates/test/functional/models_controller_test.rb
51
+ - lib/generators/ajaxcrud/templates/test/unit/.gitkeep
52
+ - lib/generators/ajaxcrud/templates/test/unit/helpers/models_helper_test.rb
53
+ - lib/generators/ajaxcrud/templates/test/unit/model_test.rb
54
+ - lib/generators/ajaxcrud/templates/views/_form.html.erb
55
+ - lib/generators/ajaxcrud/templates/views/_item.html.erb
56
+ - lib/generators/ajaxcrud/templates/views/create.js.erb
57
+ - lib/generators/ajaxcrud/templates/views/destroy.js.erb
58
+ - lib/generators/ajaxcrud/templates/views/edit.js.erb
59
+ - lib/generators/ajaxcrud/templates/views/index.html.erb
60
+ - lib/generators/ajaxcrud/templates/views/search.js.erb
61
+ - lib/generators/ajaxcrud/templates/views/show.html.erb
62
+ - lib/generators/ajaxcrud/templates/views/update.js.erb
63
+ homepage: ""
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project: ajaxcrud
92
+ rubygems_version: 1.8.10
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Scaffolding with Ajax
96
+ test_files: []
97
+