mdd 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/mdwa_helper.rb +13 -4
  3. data/app/views/template/mdwa/_autocomplete_multiple_tag.html.erb +3 -3
  4. data/app/views/template/mdwa/_autocomplete_remote_multiple_tag.html.erb +5 -2
  5. data/app/views/template/mdwa/_autocomplete_remote_tag.html.erb +21 -1
  6. data/lib/generators/mdwa/sandbox/sandbox_generator.rb +30 -7
  7. data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/login_manifest.js +1 -1
  8. data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/system_manifest.js +1 -1
  9. data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/ajaxloader.js +16 -16
  10. data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/all_pages.js +34 -30
  11. data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/batch_update.js +35 -0
  12. data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/xls_export.js +14 -0
  13. data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/jquery/{jquery-ui-1.10.0.custom.css → jquery-ui.css} +60 -57
  14. data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/login/login.css +26 -2
  15. data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/system_manifest.css +1 -0
  16. data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/backend.css.erb +11 -91
  17. data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/menu.css +86 -0
  18. data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/template.css.erb +71 -18
  19. data/lib/generators/mdwa/sandbox/templates/app/controllers/a/backend_controller.rb +14 -0
  20. data/lib/generators/mdwa/sandbox/templates/app/models/permission.rb +2 -2
  21. data/lib/generators/mdwa/sandbox/templates/app/views/layouts/login.html.erb +4 -1
  22. data/lib/generators/mdwa/sandbox/templates/app/views/layouts/public.html.erb +3 -3
  23. data/lib/generators/mdwa/sandbox/templates/app/views/layouts/system.html.erb +6 -4
  24. data/lib/generators/mdwa/sandbox/templates/app/views/template/mdwa/_login_text.html.erb +4 -0
  25. data/lib/generators/mdwa/sandbox/templates/app/views/template/mdwa/_menubar.html.erb +3 -0
  26. data/lib/generators/mdwa/sandbox/templates/app/views/template/mdwa/menubar/_administrators.html.erb +10 -0
  27. data/lib/generators/mdwa/sandbox/templates/config/initializers/mime_types.rb +2 -0
  28. data/lib/generators/mdwa/sandbox/templates/config/locales/mdwa.en.yml +8 -0
  29. data/lib/generators/mdwa/sandbox/templates/deploy.sh +17 -0
  30. data/lib/generators/mdwa/templates/templates/scaffold/controller.erb +23 -5
  31. data/lib/generators/mdwa/templates/templates/scaffold/model.erb +61 -19
  32. data/lib/generators/mdwa/templates/templates/scaffold/views/_form.html.erb +3 -5
  33. data/lib/generators/mdwa/templates/templates/scaffold/views/_form_fields.html.erb +23 -15
  34. data/lib/generators/mdwa/templates/templates/scaffold/views/_list.html.erb +38 -26
  35. data/lib/generators/mdwa/templates/templates/scaffold/views/batch_update.js.erb +3 -0
  36. data/lib/generators/mdwa/templates/templates/scaffold/views/index.html.erb +19 -4
  37. data/lib/generators/mdwa/templates/templates/scaffold/views/index.xls.erb +23 -0
  38. data/lib/generators/mdwa/templates/templates/scaffold/views/menu/menu.html.erb +13 -0
  39. data/lib/generators/mdwa/templates/templates_generator.rb +5 -0
  40. data/lib/generators/mdwa/transform/transform_generator.rb +91 -49
  41. data/lib/generators/mdwa/translate/templates/br/config/initializers/inflections.rb +58 -0
  42. data/lib/generators/mdwa/translate/templates/br/config/locales/devise.pt-BR.yml +59 -0
  43. data/lib/generators/mdwa/translate/templates/br/config/locales/mdwa.pt-BR.yml +294 -0
  44. data/lib/generators/mdwa/translate/templates/br/config/locales/mdwa.specific.pt-BR.yml +2 -0
  45. data/lib/generators/mdwa/translate/translate_generator.rb +38 -0
  46. data/lib/mdwa/dsl/entity.rb +1 -0
  47. data/lib/mdwa/generators/model_attribute.rb +5 -3
  48. data/lib/mdwa/version.rb +1 -1
  49. data/mdd.gemspec +4 -1
  50. data/test/entity_actions_test.rb +0 -1
  51. data/test/entity_attributes_options_test.rb +1 -2
  52. data/test/entity_specifications_test.rb +0 -1
  53. data/test/entity_status_test.rb +40 -0
  54. data/test/entity_test.rb +6 -7
  55. data/test/layout_test.rb +0 -1
  56. data/test/process_test.rb +0 -1
  57. data/test/requirements_test.rb +0 -1
  58. data/test/users_test.rb +0 -1
  59. metadata +52 -8
  60. data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/jquery/jquery.popup_window.js +0 -62
  61. data/lib/generators/mdwa/sandbox/templates/app/views/template/_leftbar.html.erb +0 -11
@@ -5,6 +5,9 @@
5
5
  <%= stylesheet_link_tag "mdwa/login_manifest", :media => "all" %>
6
6
  <%= javascript_include_tag "mdwa/login_manifest" %>
7
7
  <%= csrf_meta_tags %>
8
+
9
+ <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,700,600,300' rel='stylesheet' type='text/css'>
10
+
8
11
  </head>
9
12
  <body>
10
13
 
@@ -12,7 +15,7 @@
12
15
 
13
16
  <div id="mainbody">
14
17
  <%= render '/template/mdwa/login_text' %>
15
- <%= yield %>
18
+ <%= yield %>
16
19
  </div>
17
20
 
18
21
  </body>
@@ -3,10 +3,10 @@
3
3
  <head>
4
4
  <title>MDWA Public pages</title>
5
5
  <%= stylesheet_link_tag "mdwa/public_manifest", :media => "all" %>
6
- <%= javascript_include_tag "mdwa/public_manifest" %>
7
- <%= csrf_meta_tags %>
6
+ <%= javascript_include_tag "mdwa/public_manifest" %>
7
+ <%= csrf_meta_tags %>
8
8
  </head>
9
9
  <body>
10
- <%= yield %>
10
+ <%= yield %>
11
11
  </body>
12
12
  </html>
@@ -1,11 +1,13 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>MDWA Application</title>
4
+ <title>MDWA Application - Administration</title>
5
5
  <%= stylesheet_link_tag 'mdwa/system_manifest' %>
6
6
  <%= javascript_include_tag 'mdwa/system_manifest' %>
7
7
 
8
8
  <%= csrf_meta_tag %>
9
+
10
+ <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,700,600,300' rel='stylesheet' type='text/css'>
9
11
  </head>
10
12
 
11
13
  <body>
@@ -14,7 +16,7 @@
14
16
 
15
17
  <div id="header" class="yui3-g">
16
18
  <div id="logo" class="yui3-u-1-3">
17
- <%= link_to "MDWA Application", a_root_path, :target => '_self' %>
19
+ <%= link_to image_tag('rails.png'), a_root_path, :target => '_self' %>
18
20
  </div>
19
21
  <div id="logged_info" class="yui3-u-1-3">
20
22
  <%= render "/a/users/welcome" %>
@@ -22,8 +24,8 @@
22
24
  <div class="clear"></div>
23
25
  </div>
24
26
 
25
- <div id="leftbar">
26
- <%= render '/template/mdwa/leftbar' %>
27
+ <div id="menu">
28
+ <%= render '/template/mdwa/menubar' %>
27
29
  </div>
28
30
 
29
31
  <div id="content">
@@ -0,0 +1,4 @@
1
+ <div id="login_session_text">
2
+ <%= image_tag 'rails.png' %>
3
+ <%= t('login.login_text_pre_form').html_safe %>
4
+ </div>
@@ -0,0 +1,3 @@
1
+ <ul>
2
+ <%= render '/template/mdwa/menubar/administrators' %>
3
+ </ul>
@@ -0,0 +1,10 @@
1
+ <% if can? :index, A::Administrator %>
2
+ <li>
3
+ <%= link_to a_administrators_path do %><span><%= t 'menu.administrators' %></span><% end %>
4
+ <% if can? :create, A::Administrator %>
5
+ <ul class="submenu">
6
+ <li><%= link_to new_a_administrator_path do %><span><%= t( 'menu.add_administrator' ) %></span><% end %></li>
7
+ </ul>
8
+ <% end %>
9
+ </li>
10
+ <% end %>
@@ -0,0 +1,2 @@
1
+ # -*- encoding : utf-8 -*-
2
+ Mime::Type.register "application/xls", :xls
@@ -5,6 +5,14 @@ en:
5
5
  login_button_label: "Login"
6
6
  login_text_pre_form: "Welcome to a MDWA software. <br />Please login to access this app."
7
7
 
8
+ will_paginate:
9
+ previous_label: "Previous"
10
+ next_label: "Next"
11
+ page_gap: "&hellip;"
12
+ all: '- All -'
13
+ show_label: 'Show'
14
+
15
+
8
16
  system:
9
17
  error: "error"
10
18
  logged_info_user: "Welcome, <span>%{user}</span>."
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+ #
3
+ # Procedure for updating the production version
4
+ # Usage: sh deploy.sh <production|staging>
5
+ BRANCH=$1
6
+
7
+ git reset --hard
8
+ git checkout $BRANCH
9
+ git pull origin $BRANCH
10
+ rm -rf .bundle vendor/bundle
11
+ bundle install
12
+ bundle install --deployment
13
+ rake db:migrate RAILS_ENV=production
14
+ rake db:seed RAILS_ENV=production
15
+
16
+ chown -R www-data:www-data .
17
+ chmod -R 744 .
@@ -17,7 +17,7 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
17
17
  -%>
18
18
  <%- if !atributos_com_filtro.count.zero? -%>
19
19
  <%- atributos_com_filtro.each do |atributo| -%>
20
- <%- if [:integer, :float, :decimal, :boolean].include? atributo.type.to_sym -%>
20
+ <%- if [:integer, :float, :decimal, :boolean, :status].include? atributo.type.to_sym -%>
21
21
  conditions << "(<%= @model.plural_name %>.<%= atributo.name %> = '#{params[:<%= atributo.name %>]}')" unless params[:<%= atributo.name %>].blank?
22
22
  <%- elsif [:string, :text].include? atributo.type.to_sym -%>
23
23
  conditions << "(<%= @model.plural_name %>.<%= atributo.name %> LIKE '%#{params[:<%= atributo.name %>]}%')" unless params[:<%= atributo.name %>].blank?
@@ -37,11 +37,15 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
37
37
  conditions << "(<%= @model.plural_name %>.<%= associacao.name %>_id = #{params[:<%= associacao.name %>_id]})" unless params[:<%= associacao.name %>_id].blank?
38
38
  <%- end -%>
39
39
 
40
- @<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => params[:page], :per_page => params[:per_page], :conditions => conditions.join(' AND ')
40
+ @<%= @model.plural_name %> = <%= @model.klass %>.not_removed.where(conditions.join(' AND '))
41
+ unless params[:skip_pagination]
42
+ @<%= @model.plural_name %> = @<%= @model.plural_name %>.paginate page: params[:page], per_page: params[:per_page]
43
+ end
41
44
 
42
45
  respond_to do |format|
43
46
  format.html
44
47
  format.js
48
+ format.xls
45
49
  end
46
50
  end
47
51
 
@@ -149,7 +153,9 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
149
153
 
150
154
  def destroy
151
155
  @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
152
- @system_notice = t('<%= @model.plural_name %>.notice.destroy') if @<%= @model.singular_name %>.destroy
156
+ @<%= @model.singular_name %>.removed = true
157
+
158
+ @system_notice = t('<%= @model.plural_name %>.notice.destroy') if @<%= @model.singular_name %>.save
153
159
 
154
160
  respond_to do |format|
155
161
  <%- if @entity.ajax? -%>
@@ -159,6 +165,18 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
159
165
  <%- end -%>
160
166
  end
161
167
  end
162
-
163
-
168
+
169
+
170
+ def batch_update
171
+ <%= @model.klass %>.where(id: params[:ids]).each do |<%= @model.singular_name %>|
172
+ <%= @model.singular_name %>.update_column( params[:attribute], params[:value] )
173
+ end
174
+
175
+ @system_notice = t('<%= @model.plural_name %>.notice.batch_update')
176
+
177
+ respond_to do |format|
178
+ format.js
179
+ end
180
+ end
181
+
164
182
  end
@@ -5,51 +5,93 @@ class <%= @model.klass %> < <%= !@entity.user? ? 'ActiveRecord::Base' : 'User' %
5
5
 
6
6
  <%- # model attributes -%>
7
7
  <%- unless @model.attributes.count.zero? -%>
8
- attr_accessible <%= @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.collect {|a| ":" + a.name }.join(', ') %>
8
+ attr_accessible <%= @model.attributes.select{|a| !['id', 'created_at', 'updated_at', 'removed'].include?(a.name)}.collect {|a| ":" + a.name }.join(', ') %>
9
9
  <%- end -%>
10
10
  <%- # paperclip file uploads -%>
11
11
  <%- unless @model.attributes.select{|attr| attr.type.to_sym == :file}.count.zero? -%>
12
- has_attached_file <%= @model.attributes.select{|attr| attr.type.to_sym == :file}.collect {|a| ":" + a.name }.join(', ') %>
12
+ has_attached_file <%= @model.attributes.select{|attr| attr.type.to_sym == :file}.collect {|a| ":" + a.name }.join(', ') %>
13
13
  <%- end -%>
14
14
 
15
15
  <%- if @entity.user? -%>
16
16
  <%- require_all "#{MDWA::DSL::USERS_PATH}#{@entity.file_name}.rb" -%>
17
17
  <%- @roles = MDWA::DSL.user(@entity.name).nil? ? @roles = [@model.name] : MDWA::DSL.user(@entity.name).user_roles -%>
18
18
  <%- @roles.each do |role| -%>
19
- after_create :create_<%= role.underscore %>_permission
20
- def create_<%= role.underscore %>_permission
21
- <%= role.underscore %>_permission = Permission.find_by_name('<%= role.underscore %>')
22
- <%= role.underscore %>_permission = Permission.create(:name => '<%= role.underscore %>') if <%= role.underscore %>_permission.nil?
23
- self.permissions.push <%= role.underscore %>_permission
24
- end
19
+ after_create :create_<%= role.underscore %>_permission
20
+ def create_<%= role.underscore %>_permission
21
+ <%= role.underscore %>_permission = Permission.find_by_name('<%= role.underscore %>')
22
+ <%= role.underscore %>_permission = Permission.create(:name => '<%= role.underscore %>') if <%= role.underscore %>_permission.nil?
23
+ self.permissions.push <%= role.underscore %>_permission
24
+ end
25
25
  <%- end -%>
26
26
  <%- end -%>
27
27
 
28
28
  <%- # model associations -%>
29
29
  <%- @model.associations.each do |association| -%>
30
30
  <%- if association.belongs_to? -%>
31
- belongs_to :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
32
- attr_accessible :<%= association.model2.singular_name.foreign_key %>
31
+ belongs_to :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
32
+ attr_accessible :<%= association.model2.singular_name.foreign_key %>
33
33
  <%- end -%>
34
34
  <%- if association.has_one? -%>
35
- has_one :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
35
+ has_one :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
36
36
  <%- end -%>
37
37
  <%- if association.has_many? -%>
38
- has_many :<%= association.model2.plural_name %>, :class_name => '<%= association.model2.klass %>'
38
+ has_many :<%= association.model2.plural_name %>, :class_name => '<%= association.model2.klass %>'
39
39
  <%- end -%>
40
40
  <%- if association.has_and_belongs_to_many? -%>
41
- has_and_belongs_to_many :<%= association.model2.plural_name %>, :join_table => :<%= association.ordered.first.plural_name %>_<%= association.ordered.last.plural_name %>
41
+ has_and_belongs_to_many :<%= association.model2.plural_name %>, :join_table => :<%= association.ordered.first.plural_name %>_<%= association.ordered.last.plural_name %>
42
42
  <%- end -%>
43
43
  <%- if association.nested_one? -%>
44
- belongs_to :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
45
- attr_accessible :<%= association.model2.singular_name %>_attributes, :<%= association.model2.singular_name.foreign_key %>
46
- accepts_nested_attributes_for :<%= association.model2.singular_name %>, :allow_destroy => true
44
+ belongs_to :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
45
+ attr_accessible :<%= association.model2.singular_name %>_attributes, :<%= association.model2.singular_name.foreign_key %>
46
+ accepts_nested_attributes_for :<%= association.model2.singular_name %>, :allow_destroy => true
47
47
  <%- end -%>
48
48
  <%- if association.nested_many? -%>
49
- has_many :<%= association.model2.plural_name %>, :class_name => '<%= association.model2.klass %>', :dependent => :destroy
50
- attr_accessible :<%= association.model2.plural_name %>_attributes
51
- accepts_nested_attributes_for :<%= association.model2.plural_name %>, :allow_destroy => true
49
+ has_many :<%= association.model2.plural_name %>, :class_name => '<%= association.model2.klass %>', :dependent => :destroy
50
+ attr_accessible :<%= association.model2.plural_name %>_attributes
51
+ accepts_nested_attributes_for :<%= association.model2.plural_name %>, :allow_destroy => true
52
52
  <%- end -%>
53
53
  <%- end -%>
54
+
55
+ scope :not_removed, -> {where('removed != 1')}
56
+
57
+ <%- # create the status attributes %>
58
+ <%- if @entity.attributes.select{|name, attr| attr.type.to_sym == :status}.count > 0 -%>
59
+ <%- @entity.attributes.select{|name, attr| attr.type.to_sym == :status}.each do |name, attr| -%>
60
+ <%- attr.options[:possible_values].each_with_index do |value, index| -%>
61
+ <%= value.to_s.underscore.upcase %> = <%= index %>
62
+ <%- end -%>
54
63
 
64
+ <%- end -%>
65
+ <%- @entity.attributes.select{|name, attr| attr.type.to_sym == :status}.each do |name, attr| -%>
66
+ <%- attr.options[:possible_values].each do |value| -%>
67
+ def <%= attr.name.to_s + '_' + value.to_s.underscore %>?
68
+ <%= attr.name.to_s %> == <%= value.to_s.underscore.upcase %>
69
+ end
70
+ <%- end -%>
71
+
72
+ def <%= attr.name.to_s %>_to_s
73
+ <%- attr.options[:possible_values].each do |value| -%>
74
+ return I18n.t('<%= @model.plural_name %>.<%= attr.name %>.<%= value.to_s.underscore %>') if <%= attr.name.to_s + '_' + value.to_s.underscore %>?
75
+ <%- end -%>
76
+ end
77
+ <%- end -%>
78
+
79
+ <%- @entity.attributes.select{|name, attr| attr.type.to_sym == :status}.each do |name, attr| -%>
80
+ def self.<%= attr.name.to_s %>_to_select
81
+ [
82
+ <%- attr.options[:possible_values].each do |value| -%>
83
+ [I18n.t('<%= @model.plural_name %>.<%= attr.name %>.<%= value.to_s.underscore %>'), <%= value.to_s.underscore.upcase %>],
84
+ <%- end -%>
85
+ ]
86
+ end
87
+ <%- end -%>
88
+ <%- end -%>
89
+
90
+ <%- # create boolean methods for all boolean attributes %>
91
+ <%- @model.attributes.select{|attr| attr.type.to_sym == :boolean}.each do |attr| -%>
92
+ def <%= attr.name %>?
93
+ <%= attr.name %>
94
+ end
95
+ <%- end -%>
96
+
55
97
  end
@@ -2,13 +2,11 @@
2
2
  <%%= <%= 'nested_' if @model.nested_many? %>form_for(<%= @model.to_route_object('@') %><%= ", :remote => true, :html => {:class => :mdwa_ajax #{',:multipart => true' unless @model.attributes.select{|attr| attr.type.to_sym == :file}.count.zero?}}" if @entity.ajax %>) do |f| %>
3
3
 
4
4
  <div id="mdwa_error">
5
- <%%= render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> %>
5
+ <%%= render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> %>
6
6
  </div>
7
7
 
8
8
  <div class="yui3-g">
9
- <div class="yui3-u">
10
- <%%= render 'form_fields', :f => f %>
11
- </div>
9
+ <%%= render 'form_fields', :f => f %>
12
10
  </div>
13
11
 
14
12
  <div class="actions">
@@ -17,7 +15,7 @@
17
15
  <%- else -%>
18
16
  <%%= link_to t('system.cancel_button'), '#', :class => :cancel %>
19
17
  <%- end -%>
20
- <%%= f.submit t('system.save_button'), :class => :button %>
18
+ <%%= f.submit t('system.save_button'), :class => :button %>
21
19
  </div>
22
20
 
23
21
  <%% end %>
@@ -1,29 +1,37 @@
1
1
  ===entity_code===
2
- <%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.each do |attr| -%>
3
- <div class="field">
2
+ <%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at', 'removed'].include?(a.name)}.each do |attr| -%>
3
+ <div class="yui3-u-1-3">
4
+ <div class="field">
4
5
  <%%= f.label :<%= attr.name %>, t('<%= @model.plural_name %>.edit.<%= attr.name %>') %>
5
- <%- if attr.type.to_sym == :file -%>
6
- <%% if !@<%= @model.singular_name %>.new_record? and !@<%= @model.singular_name %>.<%= attr.name %>.blank? %>
7
- <span><%%= link_to image_tag(file_icon_path(@<%= @model.singular_name %>.<%= attr.name %>_file_name)), @<%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %></span>
8
- <%% end %>
9
- <%- end -%>
10
- <%%= f.<%= attr.form_field %> :<%= attr.name %> %>
6
+ <%- if attr.type.to_sym == :file -%>
7
+ <%% if !@<%= @model.singular_name %>.new_record? and !@<%= @model.singular_name %>.<%= attr.name %>.blank? %>
8
+ <span><%%= link_to image_tag(file_icon_path(@<%= @model.singular_name %>.<%= attr.name %>_file_name)), @<%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %></span>
9
+ <%% end %>
10
+ <%%= f.<%= attr.form_field %> :<%= attr.name %> %>
11
+ <%- elsif attr.type.to_sym == :status -%>
12
+ <%%= f.select :<%= attr.name %>, options_for_select(<%= @model.klass %>.<%= attr.name %>_to_select, f.object.<%= attr.name %>), :prompt => t('<%= @model.plural_name %>.<%= attr.name %>.prompt_select') %>
13
+ <%- else -%>
14
+ <%%= f.<%= attr.form_field %> :<%= attr.name %><%= ', class: :datepicker' if attr.type.to_sym == :date %> %>
15
+ <%- end -%>
16
+ </div>
11
17
  </div>
12
18
  <%- end # model.attributes.each -%>
13
19
 
14
20
  <%- @model.associations.each do |assoc| -%>
15
21
  <%- next if assoc.skip_views? %>
16
22
  <%- if assoc.belongs_to? -%>
17
- <div class="field">
18
- <%%= f.label :<%= assoc.model2.singular_name.foreign_key %>, t('<%= @model.plural_name %>.edit.<%= assoc.model2.singular_name %>') %>
19
- <%%= f.select :<%= assoc.model2.singular_name.foreign_key %>,
20
- options_for_select( <%= assoc.model2.klass %>.order('<%= assoc.reference_field %> ASC').collect{ |c| [c.<%= assoc.reference_field %>, c.id] }, f.object.<%= assoc.model2.singular_name.foreign_key %> ),
21
- :prompt => t('<%= @model.plural_name %>.edit.<%= assoc.model2.singular_name %>_select') %>
23
+ <div class="yui3-u-1-3">
24
+ <div class="field">
25
+ <%%= f.label :<%= assoc.model2.singular_name.foreign_key %>, t('<%= @model.plural_name %>.edit.<%= assoc.model2.singular_name %>') %>
26
+ <%%= f.select :<%= assoc.model2.singular_name.foreign_key %>,
27
+ options_for_select( <%= assoc.model2.klass %>.not_removed.order('<%= assoc.reference_field %> ASC').collect{ |c| [c.<%= assoc.reference_field %>, c.id] }, f.object.<%= assoc.model2.singular_name.foreign_key %> ),
28
+ :prompt => t('<%= @model.plural_name %>.edit.<%= assoc.model2.singular_name %>_select') %>
29
+ </div>
22
30
  </div>
23
31
  <%- end # if -%>
24
32
 
25
33
  <%- if assoc.has_and_belongs_to_many? and assoc.composition? -%>
26
- <div class="nested">
34
+ <div class="yui3-u-1 nested">
27
35
  <%%- <%= assoc.model2.klass %>.order('<%= assoc.reference_field %> ASC').each do |<%= assoc.model2.singular_name %>| -%>
28
36
  <div class="checkbox">
29
37
  <%%= check_box_tag '<%= assoc.model2.plural_name %>[]', <%= assoc.model2.singular_name %>.id, (@<%= @model.singular_name %>.<%= assoc.model2.plural_name %>.include?(<%= assoc.model2.singular_name %>) ? true : false) %>
@@ -34,7 +42,7 @@
34
42
  <%- end -%>
35
43
 
36
44
  <%- if assoc.nested? -%>
37
- <div class="nested">
45
+ <div class="yui3-u-1 nested">
38
46
  <%%= f.fields_for :<%= (assoc.nested_many?) ? assoc.model2.plural_name : assoc.model2.singular_name %> do |ff| %>
39
47
  <%%= render '<%= assoc.model2.space %>/<%= assoc.model2.plural_name %>/form_fields', :f => ff %>
40
48
  <%- unless assoc.nested_one? -%>
@@ -1,36 +1,48 @@
1
1
  ===entity_code===
2
2
  <table class="list">
3
3
  <thead>
4
- <th class="list_show"><%%= t '<%= @model.plural_name %>.index.id' %></th>
5
- <%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.each do |attr| -%>
6
- <th><%%= t '<%= @model.plural_name %>.index.<%= attr.name %>' %></th>
7
- <%- end -%>
8
- <%- @model.associations.each do |assoc| -%>
9
- <th><%%= t '<%= @model.plural_name %>.index.<%= assoc.model2.singular_name %>' %></th>
10
- <%- end -%>
11
- <th class="list_edit"><%%= t '<%= @model.plural_name %>.index.edit' %></th>
12
- <th class="list_remove"><%%= t '<%= @model.plural_name %>.index.remove' %></th>
4
+ <%% if can? :update, <%= @model.klass %> %>
5
+ <th><%%= check_all_th %></th>
6
+ <%% end %>
7
+ <th class="list_show"><%%= t '<%= @model.plural_name %>.index.id' %></th>
8
+ <%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at', 'removed'].include?(a.name)}.each do |attr| -%>
9
+ <th><%%= t '<%= @model.plural_name %>.index.<%= attr.name %>' %></th>
10
+ <%- end -%>
11
+ <%- @model.associations.each do |assoc| -%>
12
+ <th><%%= t '<%= @model.plural_name %>.index.<%= assoc.model2.singular_name %>' %></th>
13
+ <%- end -%>
14
+ <th class="list_edit"><%%= t '<%= @model.plural_name %>.index.edit' %></th>
15
+ <th class="list_remove"><%%= t '<%= @model.plural_name %>.index.remove' %></th>
13
16
  </thead>
14
17
 
15
18
  <%% @<%= @model.plural_name %>.each do |<%= @model.singular_name %>| %>
16
19
  <tr class="<%%= cycle 'odd_line', 'even_line' %>" >
20
+
21
+ <%% if can? :update, <%= @model.klass %> %>
22
+ <td>
23
+ <%%= check_all_td(<%= @model.singular_name %>.id) %>
24
+ </td>
25
+ <%% end %>
26
+
17
27
  <td class="list_show">
18
- <%%= link_to <%= @model.singular_name %>.id, <%= @model.object_name %>_path(<%= @model.singular_name %>) <%= ", :class => 'lightbox various fancybox.ajax'" if @entity.ajax %> %>
19
- </td>
28
+ <%%= link_to <%= @model.singular_name %>.id, <%= @model.object_name %>_path(<%= @model.singular_name %>) <%= ", class: 'lightbox various fancybox.ajax'" if @entity.ajax %> %>
29
+ </td>
20
30
 
21
- <%- @model.attributes.select{|a| a.name != 'id' and a.name != 'created_at' and a.name != 'updated_at'}.each do |attr| -%>
22
- <td>
23
- <%- if attr.type.to_sym == :file -%>
24
- <%% unless <%= @model.singular_name %>.<%= attr.name %>_file_name.blank? %>
25
- <%%= link_to image_tag(file_icon_path(<%= @model.singular_name %>.<%= attr.name %>_file_name)), <%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %>
26
- <%% else %>
27
- <%%= t 'system.no_file' %>
28
- <%% end %>
29
- <%- else -%>
30
- <%%= <%= @model.singular_name %>.<%= attr.name %> %>
31
- <%- end -%>
32
- </td>
33
- <%- end -%>
31
+ <%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at', 'removed'].include?(a.name)}.each do |attr| -%>
32
+ <td>
33
+ <%- if attr.type.to_sym == :file -%>
34
+ <%% unless <%= @model.singular_name %>.<%= attr.name %>_file_name.blank? %>
35
+ <%%= link_to image_tag(file_icon_path(<%= @model.singular_name %>.<%= attr.name %>_file_name)), <%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %>
36
+ <%% else %>
37
+ <%%= t 'system.no_file' %>
38
+ <%% end %>
39
+ <%- elsif attr.type.to_sym == :status -%>
40
+ <%%= <%= @model.singular_name %>.<%= attr.name %>_to_s %>
41
+ <%- else -%>
42
+ <%%= <%= @model.singular_name %>.<%= attr.name %> %>
43
+ <%- end -%>
44
+ </td>
45
+ <%- end -%>
34
46
 
35
47
  <%- @model.associations.each do |assoc| -%>
36
48
  <td>
@@ -49,8 +61,8 @@
49
61
  <%%= link_to t('<%= @model.plural_name %>.index.edit_label'), edit_<%= @model.object_name %>_path(<%= @model.singular_name %>) <%= ", :class => 'lightbox various fancybox.ajax'" if @entity.ajax %> %>
50
62
  </td>
51
63
  <td class="list_remove">
52
- <%%= link_to t('<%= @model.plural_name %>.index.remove_label'), <%= @model.to_route_object %>, :method => :delete, <%= ':remote => true,' if @entity.ajax %> :data => {:confirm => t('<%= @model.plural_name %>.index.confirm_deletion')} %>
53
- </td>
64
+ <%%= link_to t('<%= @model.plural_name %>.index.remove_label'), <%= @model.to_route_object %>, :method => :delete, <%= ':remote => true,' if @entity.ajax %> :data => {:confirm => t('<%= @model.plural_name %>.index.confirm_deletion')} %>
65
+ </td>
54
66
  </tr>
55
67
  <%% end %>
56
68
  </table>