sunrise-scaffold 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/Rakefile +0 -20
  2. data/lib/generators/sunrise/scaffold/manage_generator.rb +2 -2
  3. data/lib/generators/sunrise/scaffold/templates/multiplay/controller.rb +4 -9
  4. data/lib/generators/sunrise/scaffold/templates/multiplay/spec/controller_spec.rb +96 -0
  5. data/lib/generators/sunrise/scaffold/templates/multiplay/views/index.html.erb +5 -1
  6. data/lib/generators/sunrise/scaffold/templates/multiplay/views/item.html.erb +7 -2
  7. data/lib/generators/sunrise/scaffold/templates/multiplay/views/model_filter.html.erb +11 -9
  8. data/lib/generators/sunrise/scaffold/templates/single/controller.rb +4 -9
  9. data/lib/generators/sunrise/scaffold/templates/single/spec/controller_spec.rb +94 -0
  10. data/lib/generators/sunrise/scaffold/templates/single/views/index.html.erb +7 -1
  11. data/lib/generators/sunrise/scaffold/templates/single/views/item.html.erb +8 -3
  12. data/lib/generators/sunrise/scaffold/templates/single/views/model_filter.html.erb +12 -11
  13. data/lib/sunrise/scaffold/version.rb +1 -1
  14. data/test/dummy/Rakefile +7 -0
  15. data/test/dummy/app/controllers/application_controller.rb +3 -0
  16. data/test/dummy/app/helpers/application_helper.rb +2 -0
  17. data/test/dummy/app/models/comment.rb +3 -0
  18. data/test/dummy/app/models/post.rb +3 -0
  19. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  20. data/test/dummy/config/application.rb +45 -0
  21. data/test/dummy/config/boot.rb +10 -0
  22. data/test/dummy/config/database.yml +22 -0
  23. data/test/dummy/config/environment.rb +5 -0
  24. data/test/dummy/config/environments/development.rb +26 -0
  25. data/test/dummy/config/environments/production.rb +49 -0
  26. data/test/dummy/config/environments/test.rb +35 -0
  27. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  28. data/test/dummy/config/initializers/inflections.rb +10 -0
  29. data/test/dummy/config/initializers/mime_types.rb +5 -0
  30. data/test/dummy/config/initializers/secret_token.rb +7 -0
  31. data/test/dummy/config/initializers/session_store.rb +8 -0
  32. data/test/dummy/config/locales/en.yml +5 -0
  33. data/test/dummy/config/routes.rb +58 -0
  34. data/test/dummy/config.ru +4 -0
  35. data/test/dummy/db/migrate/20110722084440_create_posts.rb +14 -0
  36. data/test/dummy/db/migrate/20110722085934_create_comments.rb +15 -0
  37. data/test/dummy/db/test.sqlite3 +0 -0
  38. data/test/dummy/log/development.log +0 -0
  39. data/test/dummy/log/production.log +0 -0
  40. data/test/dummy/log/server.log +0 -0
  41. data/test/dummy/log/test.log +135 -0
  42. data/test/dummy/public/404.html +26 -0
  43. data/test/dummy/public/422.html +26 -0
  44. data/test/dummy/public/500.html +26 -0
  45. data/test/dummy/public/favicon.ico +0 -0
  46. data/test/dummy/public/javascripts/application.js +2 -0
  47. data/test/dummy/public/javascripts/controls.js +965 -0
  48. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  49. data/test/dummy/public/javascripts/effects.js +1123 -0
  50. data/test/dummy/public/javascripts/prototype.js +6001 -0
  51. data/test/dummy/public/javascripts/rails.js +191 -0
  52. data/test/dummy/script/rails +6 -0
  53. data/test/generators/manage_generator_test.rb +32 -0
  54. data/test/integration/navigation_test.rb +7 -0
  55. data/test/support/integration_case.rb +4 -0
  56. data/test/test_helper.rb +29 -0
  57. data/test/tmp/app/controllers/manage/posts_controller.rb +26 -0
  58. data/test/tmp/app/helpers/manage/posts_helper.rb +2 -0
  59. data/test/tmp/app/views/manage/posts/_form.html.erb +18 -0
  60. data/test/tmp/app/views/manage/posts/_model_filter.html.erb +34 -0
  61. data/test/tmp/app/views/manage/posts/_post.html.erb +32 -0
  62. data/test/tmp/app/views/manage/posts/edit.html.erb +6 -0
  63. data/test/tmp/app/views/manage/posts/index.html.erb +36 -0
  64. data/test/tmp/app/views/manage/posts/new.html.erb +6 -0
  65. data/test/tmp/app/views/manage/posts/show.html.erb +29 -0
  66. data/test/tmp/spec/controllers/manage/posts_controller_spec.rb +94 -0
  67. metadata +137 -35
  68. data/Gemfile.lock +0 -75
  69. data/lib/generators/sunrise/scaffold/templates/multiplay/functional_test.rb +0 -103
  70. data/lib/generators/sunrise/scaffold/templates/single/functional_test.rb +0 -98
data/Rakefile CHANGED
@@ -2,7 +2,6 @@
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
4
  require 'rake/rdoctask'
5
- require File.join(File.dirname(__FILE__), 'lib', 'sunrise', 'scaffold', 'version')
6
5
 
7
6
  desc 'Default: run unit tests.'
8
7
  task :default => :test
@@ -23,22 +22,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
23
22
  rdoc.rdoc_files.include('README')
24
23
  rdoc.rdoc_files.include('lib/**/*.rb')
25
24
  end
26
-
27
- begin
28
- require 'jeweler'
29
- Jeweler::Tasks.new do |s|
30
- s.name = "sunrise-scaffold"
31
- s.version = Sunrise::Scaffold::VERSION.dup
32
- s.summary = "Rails CMS"
33
- s.description = "Sunrise is a Aimbulance CMS"
34
- s.email = "galeta.igor@gmail.com"
35
- s.homepage = "https://github.com/galetahub/sunrise-scaffold"
36
- s.authors = ["Igor Galeta", "Pavlo Galeta"]
37
- s.files = FileList["[A-Z]*", "lib/**/*"]
38
- s.extra_rdoc_files = FileList["[A-Z]*"] - %w(Gemfile Rakefile)
39
- end
40
-
41
- Jeweler::GemcutterTasks.new
42
- rescue LoadError
43
- puts "Jeweler not available. Install it with: gem install jeweler"
44
- end
@@ -22,8 +22,8 @@ module Sunrise
22
22
  end
23
23
 
24
24
  def create_tests_files
25
- template "#{generator_dir}/functional_test.rb",
26
- File.join('test/functional', manage_path, "#{controller_file_name}_controller_test.rb")
25
+ template "#{generator_dir}/spec/controller_spec.rb",
26
+ File.join('spec/controllers', manage_path, "#{controller_file_name}_controller_spec.rb")
27
27
  end
28
28
 
29
29
  def create_views_files
@@ -1,12 +1,12 @@
1
1
  class Manage::<%= controller_class_name %>Controller < Manage::BaseController
2
2
  inherit_resources
3
- defaults :route_prefix => 'manage'
4
3
  belongs_to :<%= parent_singular_name %>
5
4
 
6
- before_filter :make_filter, :only=>[:index]
7
-
8
5
  load_and_authorize_resource :<%= singular_name %>, :through => :<%= parent_singular_name %>
9
6
 
7
+ has_scope :with_title, :as => :title, :only => :index
8
+ order_by :created_at, :updated_at
9
+
10
10
  def create
11
11
  create!{ manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id) }
12
12
  end
@@ -26,11 +26,6 @@ class Manage::<%= controller_class_name %>Controller < Manage::BaseController
26
26
  end
27
27
 
28
28
  def collection
29
- @<%= plural_name %> = (@<%= plural_name %> || end_of_association_chain).merge(@search.scoped).page(params[:page])
30
- end
31
-
32
- def make_filter
33
- @search = Sunrise::ModelFilter.new(<%= model_name %>, :attributes=>[ <%= model.attributes.keys.map{ |a| ":#{a}" }.join(', ') %> ] )
34
- @search.update_attributes(params[:search])
29
+ @<%= plural_name %> = (@<%= plural_name %> || end_of_association_chain).order(search_filter.order).page(params[:page])
35
30
  end
36
31
  end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ describe Manage::<%= controller_class_name %>Controller do
4
+ render_views
5
+
6
+ before(:all) do
7
+ @<%= parent_singular_name %> = FactoryGirl.create(:<%= parent_singular_name %>)
8
+ @attrs = FactoryGirl.attributes_for(:<%= singular_name %>, :<%= parent_singular_name %> => @<%= parent_singular_name %>)
9
+ end
10
+
11
+ context "administrator" do
12
+ login_admin
13
+
14
+ it "should render new action" do
15
+ get :new, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
16
+ response.should be_success
17
+ response.should render_template("new")
18
+ end
19
+
20
+ it "should create new <%= singular_name %>" do
21
+ lambda {
22
+ post :create, :<%= singular_name %> => @attrs, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
23
+ }.should change { <%= class_name %>.count }.by(1)
24
+ end
25
+
26
+ context "exists default <%= singular_name %>" do
27
+ before(:each) do
28
+ @<%= singular_name %> = <%= model_name %>.create(@attrs)
29
+ end
30
+
31
+ it "should render index action" do
32
+ get :index, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
33
+ assigns(:<%= parent_singular_name %>).should == @<%= parent_singular_name %>
34
+ assigns(:<%= plural_name %>).should include(@<%= singular_name %>)
35
+ response.should render_template('index')
36
+ end
37
+
38
+ it "should render edit action" do
39
+ controller.should_receive :edit, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
40
+ get :edit, :id => @<%= singular_name %>.id
41
+ end
42
+
43
+ it "should update <%= singular_name %>" do
44
+ put :update, :id => @<%= singular_name %>.id, :<%= singular_name %> => @attrs, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
45
+ assigns(:<%= singular_name %>).should be_valid
46
+ response.should redirect_to(manage_<%= parent_singular_name %>_<%= plural_name %>_path)
47
+ end
48
+
49
+ it "should destroy <%= singular_name %>" do
50
+ lambda {
51
+ delete :destroy, :id => @<%= singular_name %>.id
52
+ }.should change { <%= class_name %>.count }.by(-1)
53
+ end
54
+ end
55
+ end
56
+
57
+ context "anonymous user" do
58
+ user_logout
59
+
60
+ it "should not render index action" do
61
+ controller.should_not_receive :index
62
+ get :index, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
63
+ end
64
+
65
+ it "should not render new action" do
66
+ controller.should_not_receive :new
67
+ get :new, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
68
+ end
69
+
70
+ it "should not render create action" do
71
+ controller.should_not_receive :create
72
+ post :create, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
73
+ end
74
+
75
+ context "with exists <%= singular_name %>" do
76
+ before(:each) do
77
+ @<%= singular_name %> = <%= model_name %>.create(@attrs)
78
+ end
79
+
80
+ it "should not render edit action" do
81
+ controller.should_not_receive :edit
82
+ get :edit, :id => @<%= singular_name %>.id, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
83
+ end
84
+
85
+ it "should not render update action" do
86
+ controller.should_not_receive :update
87
+ put :update, :id => @<%= singular_name %>.id, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
88
+ end
89
+
90
+ it "should not render destroy action" do
91
+ controller.should_not_receive :destroy
92
+ delete :destroy, :id => @<%= singular_name %>.id, :<%= parent_singular_name %>_id => @<%= parent_singular_name %>.id
93
+ end
94
+ end
95
+ end
96
+ end
@@ -6,11 +6,14 @@
6
6
  <div class="r-corn">
7
7
  <%%= link_to t('manage.menu.<%= plural_name %>'), manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id), :class=>"dark-text" %>
8
8
  <div class="act-bl">
9
- <%%= link_to t('manage.add'), new_manage_<%= parent_singular_name %>_<%= singular_name %>_path(@<%= parent_singular_name %>.id), :class=>"create" %>
9
+ <%% if can? :create, <%= class_name %>, :context => :manage %>
10
+ <%%= link_to t('manage.add'), new_manage_<%= parent_singular_name %>_<%= singular_name %>_path(@<%= parent_singular_name %>.id), :class=>"create" %>
11
+ <%% end -%>
10
12
  </div>
11
13
  </div>
12
14
  </div>
13
15
  </div>
16
+
14
17
  <div id="<%= plural_name %>" class="stage">
15
18
  <%%= render :partial=>"manage/<%= plural_name %>/<%= singular_name %>", :collection=>@<%= plural_name %> %>
16
19
  <%%= paginate @<%= plural_name %>, :theme => 'manage' %>
@@ -21,6 +24,7 @@
21
24
  Manage.init_collection('<%= plural_name %>', 'dinamic-bl');
22
25
  });
23
26
  </script>
27
+
24
28
  </div>
25
29
  </div>
26
30
 
@@ -1,9 +1,13 @@
1
1
  <%%= content_tag(:div, :id=>dom_id(<%= singular_name %>), :class=>"dinamic-bl") do %>
2
2
  <div class="act-bl" style="display:none;">
3
- <%%= link_to image_tag("manage/ico_edit.gif", :alt=>t('manage.edit'), :title=>t('manage.edit')), edit_manage_<%= parent_singular_name %>_<%= singular_name %>_path(@<%= parent_singular_name %>.id, <%= singular_name %>.id), :class=>"icons" %>
3
+ <%% if can? :update, <%= singular_name %>, :context => :manage %>
4
+ <%%= link_to manage_icon("edit"), edit_manage_<%= parent_singular_name %>_<%= singular_name %>_path(@<%= parent_singular_name %>.id, <%= singular_name %>.id), :class=>"icons" %>
5
+ <%% end -%>
4
6
 
5
- <%%= link_to image_tag("manage/ico_del.gif", :alt=>t('manage.delete'), :title=>t('manage.delete')), manage_<%= parent_singular_name %>_<%= singular_name %>_path(@<%= parent_singular_name %>.id, <%= singular_name %>.id),
7
+ <%% if can? :delete, <%= singular_name %>, :context => :manage %>
8
+ <%%= link_to manage_icon("delete"), manage_<%= parent_singular_name %>_<%= singular_name %>_path(@<%= parent_singular_name %>.id, <%= singular_name %>.id),
6
9
  :method=>:delete, :confirm=>t("manage.confirm_delete"), :class=>"icons" %>
10
+ <%% end -%>
7
11
  </div>
8
12
 
9
13
  <div class="bot-bg">
@@ -16,6 +20,7 @@
16
20
  <%%= link_to <%= singular_name %>.title, edit_manage_<%= parent_singular_name %>_<%= singular_name %>_path(@<%= parent_singular_name %>.id, <%= singular_name %>.id), :class=>"title" %>
17
21
  </div>
18
22
  </div>
23
+ <!--<div class="l-block"> ava img </div>-->
19
24
  </div>
20
25
  </div>
21
26
  </div>
@@ -2,12 +2,14 @@
2
2
  <div class="filt-bl">
3
3
  <%%= link_to_function t('manage.model_filter.title'), "Manage.toggle_element('block_filter')", :class=>"dark-arr" %>
4
4
 
5
+ <%%= t('manage.model_filter.total_count') %>: <%%= @<%= plural_name %>.total_count %>
6
+
5
7
  <%%= cookie_content_tag(:div, :id=>"block_filter", :class=>"filt") do %>
6
- <%%= form_for @search, :as => :search, :url=>manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id), :html=>{:method=>:get, :id=>"form_filter"} do |f| %>
7
- <% model.attributes.each do |attribute, value| -%>
8
- <%%= f.label :<%= attribute %>, t('activerecord.attributes.<%= singular_name %>.<%= attribute %>') %>
9
- <%%= f.text_field :<%= attribute %>, :class=>"text" %>
10
- <% end -%>
8
+ <%%= form_for search_filter, :url=>manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id), :html=>{:method=>:get} do |f| %>
9
+ <%% controller.scopes_configuration.each do |key, value| %>
10
+ <%%= f.label value[:as], t(value[:as], :scope => "activerecord.attributes.<%= singular_name %>") %>
11
+ <%%= f.text_field value[:as], :class => "text", :name => value[:as] %>
12
+ <%% end %>
11
13
 
12
14
  <div class="buts">
13
15
  <%%= content_tag(:button, :value=>"search", :type=>"submit", :name=>"commit", :class=>"gr cupid-green") do %>
@@ -23,10 +25,10 @@
23
25
  <label><%%= t('manage.sort') %></label>
24
26
  <div class="select-input"><%%= link_to_function t("<%= plural_name %>.#{@search.order_column}_#{@search.order_type}", :scope => [:manage, :sort_columns], :default => :"#{@search.order_column}_#{@search.order_type}"), "SelectList.toggle(event)", :class=>"corn", :id=>'sort_select' %></div>
25
27
  <div id='sort_select_list' class="select-list" style='display:none;'>
26
- <% model.attributes.each do |attribute, value| -%>
27
- <%%= link_to_sort(t('<%= plural_name %>.<%= attribute %>_desc', :scope => [:manage, :sort_columns], :default => :<%= attribute %>_desc), :name => <%= attribute.inspect %>, :order_type => 'desc') %>
28
- <%%= link_to_sort(t('<%= plural_name %>.<%= attribute %>_asc', :scope => [:manage, :sort_columns], :default => :<%= attribute %>_asc), :name => <%= attribute.inspect %>, :order_type => 'asc') %>
29
- <% end %>
28
+ <%% controller.orders_configuration.each do |key, value| %>
29
+ <%%= link_to_sort(t("#{key}_desc", :scope => "manage.<%= plural_name %>.sort"), :name => key, :order_type=>'desc') %>
30
+ <%%= link_to_sort(t("#{key}_asc", :scope => "manage.<%= plural_name %>.sort"), :name => key, :order_type=>'asc') %>
31
+ <%% end %>
30
32
  </div>
31
33
  </div>
32
34
 
@@ -1,11 +1,11 @@
1
1
  class Manage::<%= controller_class_name %>Controller < Manage::BaseController
2
2
  inherit_resources
3
- defaults :route_prefix => 'manage'
4
-
5
- before_filter :make_filter, :only=>[:index]
6
3
 
7
4
  load_and_authorize_resource :class => <%= class_name %>
8
5
 
6
+ has_scope :with_title, :as => :title, :only => :index
7
+ order_by :created_at, :updated_at
8
+
9
9
  def create
10
10
  create!{ manage_<%= plural_name %>_path }
11
11
  end
@@ -21,11 +21,6 @@ class Manage::<%= controller_class_name %>Controller < Manage::BaseController
21
21
  protected
22
22
 
23
23
  def collection
24
- @<%= plural_name %> = (@<%= plural_name %> || end_of_association_chain).merge(@search.scoped).page(params[:page])
25
- end
26
-
27
- def make_filter
28
- @search = Sunrise::ModelFilter.new(<%= class_name %>, :attributes=>[ <%= model.attributes.keys.map{ |a| ":#{a}" }.join(', ') %> ] )
29
- @search.update_attributes(params[:search])
24
+ @<%= plural_name %> = (@<%= plural_name %> || end_of_association_chain).order(search_filter.order).page(params[:page])
30
25
  end
31
26
  end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ describe Manage::<%= controller_class_name %>Controller do
4
+ render_views
5
+
6
+ context "administrator" do
7
+ login_admin
8
+
9
+ before(:each) do
10
+ @attrs = FactoryGirl.attributes_for(:<%= singular_name %>)
11
+ end
12
+
13
+ it "should render new action" do
14
+ get :new
15
+ response.should be_success
16
+ response.should render_template("new")
17
+ end
18
+
19
+ it "should create new <%= singular_name %>" do
20
+ lambda {
21
+ post :create, :<%= singular_name %> => @attrs
22
+ }.should change { <%= class_name %>.count }.by(1)
23
+ end
24
+
25
+ context "exists default <%= singular_name %>" do
26
+ before(:each) do
27
+ @<%= singular_name %> = FactoryGirl.create(:<%= singular_name %>)
28
+ end
29
+
30
+ it "should render index action" do
31
+ get :index
32
+ assigns(:<%= plural_name %>).should include(@<%= singular_name %>)
33
+ response.should render_template('index')
34
+ end
35
+
36
+ it "should render edit action" do
37
+ controller.should_receive :edit
38
+ get :edit, :id => @<%= singular_name %>.id
39
+ end
40
+
41
+ it "should update <%= singular_name %>" do
42
+ put :update, :id => @<%= singular_name %>.id, :<%= singular_name %> => @attrs
43
+ assigns(:<%= singular_name %>).should be_valid
44
+ response.should redirect_to(manage_<%= plural_name %>_path)
45
+ end
46
+
47
+ it "should destroy <%= singular_name %>" do
48
+ lambda {
49
+ delete :destroy, :id => @<%= singular_name %>.id
50
+ }.should change { <%= class_name %>.count }.by(-1)
51
+ end
52
+ end
53
+ end
54
+
55
+ context "anonymous user" do
56
+ user_logout
57
+
58
+ it "should not render index action" do
59
+ controller.should_not_receive :index
60
+ get :index
61
+ end
62
+
63
+ it "should not render new action" do
64
+ controller.should_not_receive :new
65
+ get :new
66
+ end
67
+
68
+ it "should not render create action" do
69
+ controller.should_not_receive :create
70
+ post :create
71
+ end
72
+
73
+ context "with exists <%= singular_name %>" do
74
+ before(:each) do
75
+ @<%= singular_name %> = FactoryGirl.create(:<%= singular_name %>)
76
+ end
77
+
78
+ it "should not render edit action" do
79
+ controller.should_not_receive :edit
80
+ get :edit, :id => @<%= singular_name %>.id
81
+ end
82
+
83
+ it "should not render update action" do
84
+ controller.should_not_receive :update
85
+ put :update, :id => @<%= singular_name %>.id
86
+ end
87
+
88
+ it "should not render destroy action" do
89
+ controller.should_not_receive :destroy
90
+ delete :destroy, :id => @<%= singular_name %>.id
91
+ end
92
+ end
93
+ end
94
+ end
@@ -6,22 +6,28 @@
6
6
  <div class="r-corn">
7
7
  <%%= link_to t('manage.menu.<%= plural_name %>'), manage_<%= plural_name %>_path, :class=>"dark-text" %>
8
8
  <div class="act-bl">
9
- <%%= link_to t('manage.add'), new_manage_<%= singular_name %>_path, :class=>"create" %>
9
+ <%% if can? :create, <%= class_name %>, :context => :manage %>
10
+ <%%= link_to t('manage.add'), new_manage_<%= singular_name %>_path, :class=>"create" %>
11
+ <%% end -%>
10
12
  </div>
11
13
  </div>
12
14
  </div>
13
15
  </div>
16
+
14
17
  <div id="<%= plural_name %>" class="stage">
15
18
  <%%= render :partial=>"manage/<%= plural_name %>/<%= singular_name %>", :collection=>@<%= plural_name %> %>
16
19
  <%%= paginate @<%= plural_name %>, :theme => 'manage' %>
17
20
  </div>
21
+
18
22
  <script type='text/javascript'>
19
23
  $(document).ready(function(){
20
24
  Manage.init_collection('<%= plural_name %>', 'dinamic-bl');
21
25
  });
22
26
  </script>
27
+
23
28
  </div>
24
29
  </div>
30
+
25
31
  <div class="right-part">
26
32
  <div class="filter-right">
27
33
  <%%= render :partial=>"manage/<%= plural_name %>/model_filter" %>
@@ -1,9 +1,13 @@
1
1
  <%%= content_tag(:div, :id=>dom_id(<%= singular_name %>), :class=>"dinamic-bl") do %>
2
2
  <div class="act-bl" style="display:none;">
3
- <%%= link_to image_tag("manage/ico_edit.gif", :alt=>t('manage.edit'), :title=>t('manage.edit')), edit_manage_<%= singular_name %>_path(:id=><%= singular_name %>.id), :class=>"icons" %>
4
-
5
- <%%= link_to image_tag("manage/ico_del.gif", :alt=>t('manage.delete'), :title=>t('manage.delete')), manage_<%= singular_name %>_path(:id=><%= singular_name %>.id),
3
+ <%% if can? :update, <%= singular_name %>, :context => :manage %>
4
+ <%%= link_to manage_icon("edit"), edit_manage_<%= singular_name %>_path(:id=><%= singular_name %>.id), :class=>"icons" %>
5
+ <%% end -%>
6
+
7
+ <%% if can? :delete, <%= singular_name %>, :context => :manage %>
8
+ <%%= link_to manage_icon("delete"), manage_<%= singular_name %>_path(:id=><%= singular_name %>.id),
6
9
  :method=>:delete, :confirm=>t("manage.confirm_delete"), :class=>"icons" %>
10
+ <%% end -%>
7
11
  </div>
8
12
 
9
13
  <div class="bot-bg">
@@ -16,6 +20,7 @@
16
20
  <%%= link_to <%= singular_name %>.title, edit_manage_<%= singular_name %>_path(:id=><%= singular_name %>.id), :class=>"title" %>
17
21
  </div>
18
22
  </div>
23
+ <!--<div class="l-block"> ava img </div>-->
19
24
  </div>
20
25
  </div>
21
26
  </div>
@@ -2,12 +2,14 @@
2
2
  <div class="filt-bl">
3
3
  <%%= link_to_function t('manage.model_filter.title'), "Manage.toggle_element('block_filter')", :class=>"dark-arr" %>
4
4
 
5
+ <%%= t('manage.model_filter.total_count') %>: <%%= @<%= plural_name %>.total_count %>
6
+
5
7
  <%%= cookie_content_tag(:div, :id=>"block_filter", :class=>"filt") do %>
6
- <%%= form_for @search, :as => :search, :url=>manage_<%= plural_name %>_path, :html=>{:method=>:get, :id=>"form_filter"} do |f| %>
7
- <% model.attributes.each do |attribute, value| -%>
8
- <%%= f.label :<%= attribute %>, t('<%= singular_name %>.<%= attribute %>', :scope => [:activerecord, :attributes]) %>
9
- <%%= f.text_field :<%= attribute %>, :class=>"text" %>
10
- <% end -%>
8
+ <%%= form_for search_filter, :url => manage_<%= plural_name %>_path, :html => { :method => :get } do |f| %>
9
+ <%% controller.scopes_configuration.each do |key, value| %>
10
+ <%%= f.label value[:as], t(value[:as], :scope => "activerecord.attributes.<%= singular_name %>") %>
11
+ <%%= f.text_field value[:as], :class => "text", :name => value[:as] %>
12
+ <%% end %>
11
13
 
12
14
  <div class="buts">
13
15
  <%%= content_tag(:button, :value=>"search", :type=>"submit", :name=>"commit", :class=>"gr cupid-green") do %>
@@ -21,13 +23,12 @@
21
23
  </div>
22
24
  <div class="sort">
23
25
  <label><%%= t('manage.sort') %></label>
24
- <div class="select-input"><%%= link_to_function t("<%= plural_name %>.#{@search.order_column}_#{@search.order_type}", :scope => [:manage, :sort_columns], :default => :"#{@search.order_column}_#{@search.order_type}"), "SelectList.toggle(event)", :class=>"corn", :id=>'sort_select' %></div>
26
+ <div class="select-input"><%%= link_to_function t(search_filter.current_order, :scope => "manage.<%= plural_name %>.sort"), "SelectList.toggle(event)", :class=>"corn", :id=>'sort_select' %></div>
25
27
  <div id='sort_select_list' class="select-list" style='display:none;'>
26
- <% model.attributes.each do |attribute, value| %>
27
- <%%= link_to_sort(t('<%= plural_name %>.<%= attribute %>_desc', :scope => [:manage, :sort_columns], :default => :<%= attribute %>_desc), :name => <%= attribute.inspect %>, :order_type => 'desc') %>
28
- <%%= link_to_sort(t('<%= plural_name %>.<%= attribute %>_asc', :scope => [:manage, :sort_columns], :default => :<%= attribute %>_asc), :name => <%= attribute.inspect %>, :order_type => 'asc') %>
29
- <% end %>
28
+ <%% controller.orders_configuration.each do |key, value| %>
29
+ <%%= link_to_sort(t("#{key}_desc", :scope => "manage.<%= plural_name %>.sort"), :name => key, :order_type=>'desc') %>
30
+ <%%= link_to_sort(t("#{key}_asc", :scope => "manage.<%= plural_name %>.sort"), :name => key, :order_type=>'asc') %>
31
+ <%% end %>
30
32
  </div>
31
33
  </div>
32
-
33
34
  </div>
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Sunrise
3
3
  module Scaffold
4
- VERSION = "0.1.5".freeze
4
+ VERSION = "0.2.0".freeze
5
5
  end
6
6
  end
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ class Comment < ActiveRecord::Base
2
+ belongs_to :post
3
+ end
@@ -0,0 +1,3 @@
1
+ class Post < ActiveRecord::Base
2
+ has_many :comments
3
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag :all %>
6
+ <%= javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "active_model/railtie"
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_view/railtie"
7
+ require "action_mailer/railtie"
8
+
9
+ Bundler.require
10
+ require "sunrise/scaffold"
11
+
12
+ module Dummy
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Custom directories with classes and modules you want to be autoloadable.
19
+ # config.autoload_paths += %W(#{config.root}/extras)
20
+
21
+ # Only load the plugins named here, in the order given (default is alphabetical).
22
+ # :all can be used as a placeholder for all plugins not explicitly named.
23
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
+
25
+ # Activate observers that should always be running.
26
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
+
28
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
+ # config.time_zone = 'Central Time (US & Canada)'
31
+
32
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
+ # config.i18n.default_locale = :de
35
+
36
+ # JavaScript files you want as :defaults (application.js is always included).
37
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
38
+
39
+ # Configure the default encoding used in templates for Ruby 1.9.
40
+ config.encoding = "utf-8"
41
+
42
+ # Configure sensitive parameters which will be filtered from the log file.
43
+ config.filter_parameters += [:password]
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,26 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+