mdd 3.0.6 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/app/controllers/mdwa/requirements_controller.rb +4 -1
  2. data/lib/generators/mdwa/association/association_generator.rb +17 -10
  3. data/lib/generators/mdwa/code/code_generator.rb +9 -1
  4. data/lib/generators/mdwa/{template/templates/views → templates/templates/actions}/view.custom.erb +0 -0
  5. data/lib/generators/mdwa/{template/templates/views → templates/templates/actions}/view.html.erb +0 -0
  6. data/lib/generators/mdwa/{template/templates/views → templates/templates/actions}/view.js.erb +0 -0
  7. data/lib/generators/mdwa/{template/templates/views → templates/templates/actions}/view.json.erb +0 -0
  8. data/lib/generators/mdwa/templates/templates/general/routes.rb +3 -0
  9. data/lib/generators/mdwa/templates/templates/scaffold/controller.rb +150 -0
  10. data/lib/generators/mdwa/templates/templates/scaffold/helper.rb +3 -0
  11. data/lib/generators/mdwa/templates/templates/scaffold/model.rb +50 -0
  12. data/lib/generators/mdwa/templates/templates/scaffold/views/_form.html.erb +23 -0
  13. data/lib/generators/mdwa/templates/templates/scaffold/views/_form_fields.html.erb +45 -0
  14. data/lib/generators/mdwa/templates/templates/scaffold/views/_list.html.erb +47 -0
  15. data/lib/generators/mdwa/templates/templates/scaffold/views/create.js.erb +8 -0
  16. data/lib/generators/mdwa/templates/templates/scaffold/views/destroy.js.erb +3 -0
  17. data/lib/generators/mdwa/templates/templates/scaffold/views/edit.html.erb +10 -0
  18. data/lib/generators/mdwa/templates/templates/scaffold/views/index.html.erb +17 -0
  19. data/lib/generators/mdwa/templates/templates/scaffold/views/index.js.erb +2 -0
  20. data/lib/generators/mdwa/templates/templates/scaffold/views/new.html.erb +10 -0
  21. data/lib/generators/mdwa/templates/templates/scaffold/views/show.html.erb +31 -0
  22. data/lib/generators/mdwa/templates/templates/scaffold/views/update.js.erb +13 -0
  23. data/lib/generators/mdwa/templates/templates_generator.rb +144 -0
  24. data/lib/generators/mdwa/transform/templates/changes_migration.rb +16 -0
  25. data/lib/generators/mdwa/transform/transform_generator.rb +258 -61
  26. data/lib/generators/mdwa/user_scaffold/user_scaffold_generator.rb +32 -14
  27. data/lib/mdwa/dsl/action.rb +10 -1
  28. data/lib/mdwa/dsl/entity.rb +9 -3
  29. data/lib/mdwa/dsl/entity_association.rb +21 -0
  30. data/lib/mdwa/dsl/requirements.rb +4 -0
  31. data/lib/mdwa/generators/model_association.rb +9 -3
  32. data/lib/mdwa/version.rb +1 -1
  33. metadata +25 -9
  34. data/lib/generators/mdwa/template/template_generator.rb +0 -40
@@ -2,7 +2,10 @@ require 'mdwa/dsl'
2
2
  class Mdwa::RequirementsController < Mdwa::MDWAController
3
3
 
4
4
  def index
5
- require_all MDWA::DSL::REQUIREMENTS_PATH
5
+ # reload the requirements
6
+ MDWA::DSL.requirements.clear
7
+
8
+ Dir.glob("#{MDWA::DSL::REQUIREMENTS_PATH}/*.rb").each { |file| load file }
6
9
  @requirements = MDWA::DSL.requirements.all
7
10
  end
8
11
 
@@ -22,6 +22,7 @@ module Mdwa
22
22
  class_option :with_opposite, :desc => 'Generate the opposite relation too. For example, the oposite of belongs_to is has_many.', :type => :boolean, :default => false
23
23
  class_option :skip_rake_migrate, :desc => 'Skips rake db:migrate', :type => :boolean, :default => false
24
24
  class_option :skip_migrations, :desc => 'Skips migration files', :type => :boolean, :default => false
25
+ class_option :skip_models, :desc => 'Skips model code injection', :type => :boolean, :default => false
25
26
  class_option :ask, :desc => 'Asks if the opposite should be generated.', :type => :boolean, :default => false
26
27
 
27
28
  def initialize(*args, &block)
@@ -34,6 +35,9 @@ module Mdwa
34
35
 
35
36
 
36
37
  def model
38
+
39
+ return nil if options.skip_models
40
+
37
41
  if @association.belongs_to?
38
42
  inject_into_class "app/models/#{@association.model1.space}/#{@association.model1.singular_name}.rb", @association.model1.model_class do
39
43
  ret = []
@@ -70,7 +74,7 @@ module Mdwa
70
74
  end
71
75
  if @association.nested_many?
72
76
  inject_into_class "app/models/#{@association.model1.space}/#{@association.model1.singular_name}.rb", @association.model1.model_class do
73
- # belongs_to
77
+ # has_many
74
78
  # attr_accessible attributes
75
79
  # attr_nested_attributes
76
80
  "\n\thas_many :#{@association.model2.plural_name}, :class_name => '#{@association.model2.klass}', :dependent => :destroy\n\tattr_accessible :#{@association.model2.plural_name}_attributes\n\taccepts_nested_attributes_for :#{@association.model2.plural_name}, :allow_destroy => true\n"
@@ -80,20 +84,23 @@ module Mdwa
80
84
  end
81
85
 
82
86
  def migrate
83
- unless options.skip_migrations
87
+ return nil if options.skip_migrations
84
88
 
85
- @pending_migrations = true
86
- case @association.relation.to_sym
87
- when :belongs_to, :nested_one
88
- @table = @association.model1
89
- @field = @association.model2
90
- migration_template 'migrate/one_field.rb', "db/migrate/add_#{@field.singular_name.foreign_key}_to_#{@table.plural_name}.rb"
91
- when :has_and_belongs_to_many
89
+ @pending_migrations = true
90
+ case @association.relation.to_sym
91
+ when :belongs_to, :nested_one
92
+ @table = @association.model1
93
+ @field = @association.model2
94
+ migration_template 'migrate/one_field.rb', "db/migrate/add_#{@field.singular_name.foreign_key}_to_#{@table.plural_name}.rb"
95
+ when :has_and_belongs_to_many
96
+ # only generates if table does not exist yet
97
+ if Dir.glob("db/migrate/*create_#{many_to_many_table_name}.rb").count.zero?
92
98
  migration_template 'migrate/many_to_many.rb', "db/migrate/create_#{many_to_many_table_name}.rb"
93
99
  else
94
100
  @pending_migrations = false
95
101
  end
96
-
102
+ else
103
+ @pending_migrations = false
97
104
  end
98
105
 
99
106
  end
@@ -89,7 +89,7 @@ module Mdwa
89
89
  entity_attribute = entity.attributes[column.name]
90
90
  # model attribute exists, but not in entity -> was erased
91
91
  if entity_attribute.nil?
92
- @changes << {:entity => entity, :type => 'remove_column', :column => column.name}
92
+ @changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type}
93
93
  # attribute exists in model and entity, but changed type
94
94
  elsif entity_attribute.type.to_sym != column.type.to_sym
95
95
  next if entity_attribute.type.to_sym == :file or entity_attribute.type.to_sym == :password
@@ -106,6 +106,14 @@ module Mdwa
106
106
  end
107
107
  end
108
108
 
109
+ # new foreign keys
110
+ # belongs_to and nested_one associations that are in the entity, but not database
111
+ entity.generator_model.associations.select{|a| a.belongs_to? or a.nested_one?}.each do |assoc|
112
+ if model_class.columns.select{|c| c.name == assoc.model2.singular_name.foreign_key}.count.zero?
113
+ @changes << {:entity => entity, :type => 'add_column', :column => assoc.model2.name.foreign_key, :attr_type => 'integer'}
114
+ end
115
+ end
116
+
109
117
  end
110
118
 
111
119
  # generate changed code
@@ -0,0 +1,3 @@
1
+ def mdwa_router(router)
2
+
3
+ end
@@ -0,0 +1,150 @@
1
+ # -*- encoding : utf-8 -*-
2
+ ===entity_code===
3
+ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::BackendController' : 'ApplicationController' %>
4
+
5
+ <%- if @entity.resource? -%>
6
+ load_and_authorize_resource :class => "<%= @model.klass %>"
7
+ <%- end -%>
8
+
9
+ # Hook for code generations. Do not delete.
10
+ #===controller_init===
11
+
12
+ def index
13
+ @<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => params[:page]
14
+
15
+ respond_to do |format|
16
+ format.html
17
+ format.js
18
+ end
19
+ end
20
+
21
+
22
+ def show
23
+ @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
24
+
25
+ <%- if @entity.ajax? -%>
26
+ render :layout => false
27
+ <%- else -%>
28
+ respond_to do |format|
29
+ format.html
30
+ end
31
+ <%- end -%>
32
+ end
33
+
34
+ def new
35
+ @<%= @model.singular_name %> = <%= @model.klass %>.new
36
+ <%- @model.attributes.select {|a| a.nested_one?}.each do |attr| -%>
37
+ @<%= @model.singular_name %>.<%= attr.type.singular_name %> = <%= attr.type.klass %>.new
38
+ <%- end -%>
39
+
40
+ <%- if @entity.ajax? -%>
41
+ render :layout => false
42
+ <%- else -%>
43
+ respond_to do |format|
44
+ format.html
45
+ end
46
+ <%- end -%>
47
+ end
48
+
49
+ def edit
50
+ @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
51
+
52
+ <%- if @entity.ajax? -%>
53
+ render :layout => false
54
+ <%- else -%>
55
+ respond_to do |format|
56
+ format.html
57
+ end
58
+ <%- end -%>
59
+ end
60
+
61
+ def create
62
+ @<%= @model.singular_name %> = <%= @model.klass %>.new(params[:<%= @model.to_params %>])
63
+ saved_ok = @<%= @model.singular_name %>.save
64
+ @system_notice = t('<%= @model.plural_name %>.create_success') if saved_ok
65
+ <%- if @entity.ajax? -%>
66
+ load_list # loads all <%= @model.plural_name %> to display in the list
67
+ <%- end -%>
68
+
69
+ <%- @model.associations.select{|a| a.has_and_belongs_to_many? and a.composition?}.each do |association| -%>
70
+ unless params[:<%= association.model2.plural_name %>].nil?
71
+ @<%= @model.singular_name %>.<%= association.model2.plural_name %>.clear
72
+ params[:<%= association.model2.plural_name %>].each do |<%= association.model2.singular_name.foreign_key %>|
73
+ @<%= @model.singular_name %>.<%= association.model2.plural_name %>.push <%= association.model2.klass %>.find <%= association.model2.singular_name.foreign_key %>
74
+ end
75
+ end
76
+ <%- end -%>
77
+
78
+ respond_to do |format|
79
+ <%- if @entity.ajax? -%>
80
+ format.js
81
+ <%- else -%>
82
+ if saved_ok
83
+ format.html { redirect_to <%= @model.object_name.pluralize %>_path, notice: @system_notice }
84
+ else
85
+ format.html { render action: "new" }
86
+ end
87
+ <%- end -%>
88
+ end
89
+ end
90
+
91
+ def update
92
+ @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
93
+ <%- if @entity.user? -%>
94
+ # if password is blank, delete from params
95
+ if params[:<%= @model.object_name %>][:password].blank?
96
+ params[:<%= @model.object_name %>].delete :password
97
+ params[:<%= @model.object_name %>].delete :password_confirmation
98
+ end
99
+ <%- end -%>
100
+ saved_ok = @<%= @model.singular_name %>.update_attributes(params[:<%= @model.to_params %>])
101
+ <%- if @entity.ajax? -%>
102
+ @system_notice = t('<%= @model.plural_name %>.update_success') if saved_ok
103
+ load_list # loads all <%= @model.plural_name %> to display in the list
104
+ <%- end -%>
105
+
106
+ <%- @model.associations.select{|a| a.has_and_belongs_to_many? and a.composition?}.each do |association| -%>
107
+ unless params[:<%= association.model2.plural_name %>].nil?
108
+ @<%= @model.singular_name %>.<%= association.model2.plural_name %>.clear
109
+ params[:<%= association.model2.plural_name %>].each do |<%= association.model2.singular_name.foreign_key %>|
110
+ @<%= @model.singular_name %>.<%= association.model2.plural_name %>.push <%= association.model2.klass %>.find <%= association.model2.singular_name.foreign_key %>
111
+ end
112
+ end
113
+ <%- end -%>
114
+
115
+ respond_to do |format|
116
+ <%- if @entity.ajax? -%>
117
+ format.js
118
+ <%- else -%>
119
+ if @<%= @model.singular_name %>.update_attributes(params[:<%= @model.object_name %>])
120
+ format.html { redirect_to <%= @model.object_name.pluralize %>_path, notice: t('<%= @model.plural_name %>.update_success') }
121
+ else
122
+ format.html { render action: "edit" }
123
+ end
124
+ <%- end -%>
125
+ end
126
+ end
127
+
128
+ def destroy
129
+ @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
130
+ @system_notice = t('<%= @model.plural_name %>.destroy_success') if @<%= @model.singular_name %>.destroy
131
+ <%- if @entity.ajax? -%>
132
+ load_list # loads all <%= @model.plural_name %> to display in the list
133
+ <%- end -%>
134
+
135
+ respond_to do |format|
136
+ <%- if @entity.ajax? -%>
137
+ format.js
138
+ <%- else -%>
139
+ format.html { redirect_to <%= @model.object_name.pluralize %>_path, notice: @system_notice }
140
+ <%- end -%>
141
+ end
142
+ end
143
+
144
+
145
+ private
146
+ def load_list
147
+ @<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => 1
148
+ end
149
+
150
+ end
@@ -0,0 +1,3 @@
1
+ ===entity_code===
2
+ module <%= @entity.klass %>Helper
3
+ end
@@ -0,0 +1,50 @@
1
+ # -*- encoding : utf-8 -*-
2
+ ===entity_code===
3
+ class <%= @model.klass %> < <%= !@entity.user? ? 'ActiveRecord::Base' : 'User' %>
4
+
5
+ <%- # model attributes -%>
6
+ <%- unless @model.attributes.count.zero? -%>
7
+ attr_accessible <%= @model.attributes.collect {|a| ":" + a.name }.join(', ') %>
8
+ <%- end -%>
9
+
10
+ <%- if @entity.user? -%>
11
+ <%- require_all "#{MDWA::DSL::USERS_PATH}#{@entity.file_name}.rb" -%>
12
+ <%- @roles = MDWA::DSL.user(@entity.name).nil? ? @roles = [@model.name] : MDWA::DSL.user(@entity.name).user_roles -%>
13
+ <%- @roles.each do |role| -%>
14
+ after_create :create_<%= role.underscore %>_permission
15
+ def create_<%= role.underscore %>_permission
16
+ <%= role.underscore %>_permission = Permission.find_by_name('<%= role.underscore %>')
17
+ <%= role.underscore %>_permission = Permission.create(:name => '<%= role.underscore %>') if <%= role.underscore %>_permission.nil?
18
+ self.permissions.push <%= role.underscore %>_permission
19
+ end
20
+ <%- end -%>
21
+ <%- end -%>
22
+
23
+ <%- # model associations -%>
24
+ <%- @model.associations.each do |association| -%>
25
+ <%- if association.belongs_to? -%>
26
+ belongs_to :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
27
+ attr_accessible :<%= association.model2.singular_name.foreign_key %>
28
+ <%- end -%>
29
+ <%- if association.has_one? -%>
30
+ has_one :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
31
+ <%- end -%>
32
+ <%- if association.has_many? -%>
33
+ has_many :<%= association.model2.plural_name %>, :class_name => '<%= association.model2.klass %>'
34
+ <%- end -%>
35
+ <%- if association.has_and_belongs_to_many? -%>
36
+ has_and_belongs_to_many :<%= association.model2.plural_name %>, :join_table => :<%= association.ordered.first.plural_name %>_<%= association.ordered.last.plural_name %>
37
+ <%- end -%>
38
+ <%- if association.nested_one? -%>
39
+ belongs_to :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
40
+ attr_accessible :<%= association.model2.singular_name %>_attributes, :<%= association.model2.singular_name.foreign_key %>
41
+ accepts_nested_attributes_for :<%= association.model2.singular_name %>, :allow_destroy => true
42
+ <%- end -%>
43
+ <%- if association.nested_many? -%>
44
+ has_many :<%= association.model2.plural_name %>, :class_name => '<%= association.model2.klass %>', :dependent => :destroy
45
+ attr_accessible :<%= association.model2.plural_name %>_attributes
46
+ accepts_nested_attributes_for :<%= association.model2.plural_name %>, :allow_destroy => true
47
+ <%- end -%>
48
+ <%- end -%>
49
+
50
+ end
@@ -0,0 +1,23 @@
1
+ ===entity_code===
2
+ <%%= <%= 'nested_' unless @model.attributes.select{|a| a.nested_many?}.count.zero? %>form_for(<%= @model.to_route_object('@') %><%= ', :remote => true, :html => {:class => :mdwa_ajax}' if @entity.ajax %>) do |f| %>
3
+
4
+ <div id="mdwa_error">
5
+ <%%= render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> %>
6
+ </div>
7
+
8
+ <div class="yui3-g">
9
+ <div class="yui3-u">
10
+ <%%= render 'form_fields', :f => f %>
11
+ </div>
12
+ </div>
13
+
14
+ <div class="actions">
15
+ <%- if !@entity.ajax -%>
16
+ <%%= link_to t('system.cancel_button'), <%= @model.object_name.pluralize %>_path, :class => :cancel %>
17
+ <%- else -%>
18
+ <%%= link_to t('system.cancel_button'), '#', :class => :cancel %>
19
+ <%- end -%>
20
+ <%%= f.submit :class => :button %>
21
+ </div>
22
+
23
+ <%% end %>
@@ -0,0 +1,45 @@
1
+ ===entity_code===
2
+ <%- @model.attributes.each do |attr| -%>
3
+ <div class="field">
4
+ <%%= f.label :<%= attr.name %> %>
5
+ <%%= f.<%= attr.form_field %> :<%= attr.name %> %>
6
+ </div>
7
+ <%- end # model.attributes.each -%>
8
+
9
+ <%- @model.associations.each do |assoc| -%>
10
+ <%- if assoc.belongs_to? -%>
11
+ <div class="field">
12
+ <%%= f.label :<%= assoc.model2.singular_name.foreign_key %> %>
13
+ <%%= f.select :<%= assoc.model2.singular_name.foreign_key %>,
14
+ 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 %> ),
15
+ :prompt => '-- Select --' %>
16
+ </div>
17
+ <%- end # if -%>
18
+
19
+ <%- if assoc.has_and_belongs_to_many? and assoc.composition? -%>
20
+ <div class="nested">
21
+ <%%- <%= assoc.model2.klass %>.order('<%= assoc.reference_field %> ASC').each do |<%= assoc.model2.singular_name %>| -%>
22
+ <div class="checkbox">
23
+ <%%= 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) %>
24
+ <span><%%= <%= assoc.model2.singular_name %>.<%= assoc.reference_field %> %></span>
25
+ </div>
26
+ <%%- end -%>
27
+ </div>
28
+ <%- end -%>
29
+
30
+ <%- if assoc.nested? -%>
31
+ <div class="nested">
32
+ <%%= f.fields_for :<%= (assoc.nested_many?) ? assoc.model2.plural_name : assoc.model2.singular_name %> do |ff| %>
33
+ <%%= render '<%= assoc.model2.space %>/<%= assoc.model2.plural_name %>/form_fields', :f => ff %>
34
+ <%- unless assoc.nested_one? -%>
35
+ <%%= ff.link_to_remove t('nested.remove') %>
36
+ <%- end -%>
37
+
38
+ <%% end %>
39
+ <%- unless assoc.nested_one? -%>
40
+ <%%= f.link_to_add t('nested.add', :name => '<%= assoc.model2.singular_name %>'), :<%= assoc.model2.plural_name %> %>
41
+ <%- end -%>
42
+ </div>
43
+ <%- end # if -%>
44
+
45
+ <%- end # associations loop -%>
@@ -0,0 +1,47 @@
1
+ ===entity_code===
2
+ <table class="list">
3
+ <thead>
4
+ <th class="list_show"><%%= t 'system.index_id' %></th>
5
+ <th class="list_edit"><%%= t 'system.index_edit' %></th>
6
+ <%- @model.attributes.each do |attr| -%>
7
+ <th><%%= t '<%= @model.plural_name %>.index_<%= attr.name %>' %></th>
8
+ <%- end -%>
9
+ <%- @model.associations.each do |assoc| -%>
10
+ <th><%%= t '<%= @model.plural_name %>.index_<%= assoc.model2.singular_name %>' %></th>
11
+ <%- end -%>
12
+ <th class="list_remove"><%%= t 'system.index_remove' %></th>
13
+ </thead>
14
+
15
+ <%% @<%= @model.plural_name %>.each do |<%= @model.singular_name %>| %>
16
+ <tr class="<%%= cycle 'odd_line', 'even_line' %>" >
17
+ <td>
18
+ <%%= link_to <%= @model.singular_name %>.id, <%= @model.object_name %>_path(<%= @model.singular_name %>) <%= ", :class => 'lightbox various fancybox.ajax'" if @entity.ajax %> %>
19
+ </td>
20
+ <td>
21
+ <%%= link_to t('system.index_edit_label'), edit_<%= @model.object_name %>_path(<%= @model.singular_name %>) <%= ", :class => 'lightbox various fancybox.ajax'" if @entity.ajax %> %>
22
+ </td>
23
+ <%- @model.attributes.each do |attr| -%>
24
+ <td><%%= <%= @model.singular_name %>.<%= attr.name %> %></td>
25
+ <%- end -%>
26
+
27
+ <%- @model.associations.each do |assoc| -%>
28
+ <td>
29
+ <%- if assoc.belongs_to? || assoc.nested_one? || assoc.has_one? -%>
30
+ <%%= <%= @model.singular_name %>.<%= assoc.model2.singular_name %>.<%= assoc.reference_field %> unless <%= @model.singular_name %>.<%= assoc.model2.singular_name %>.nil? %>
31
+ <%- elsif assoc.has_many? or assoc.has_and_belongs_to_many? or assoc.nested_many? -%>
32
+ <ul>
33
+ <%% <%= @model.singular_name %>.<%= assoc.model2.plural_name %>.each do |<%= assoc.model2.singular_name %>| %>
34
+ <li><%%= <%= assoc.model2.singular_name %>.<%= assoc.reference_field %> %> </li>
35
+ <%% end %>
36
+ </ul>
37
+ <%- end -%>
38
+ </td>
39
+ <%- end -%>
40
+ <td>
41
+ <%%= link_to t('system.index_remove_label'), <%= @model.to_route_object %>, :method => :delete, <%= ':remote => true,' if @entity.ajax %> :data => {:confirm => t('system.index_confirm_deletion')} %>
42
+ </td>
43
+ </tr>
44
+ <%% end %>
45
+ </table>
46
+
47
+ <%%= pagination_footer @<%= @model.plural_name %> %>
@@ -0,0 +1,8 @@
1
+ ===entity_code===
2
+ <%% if @<%= @model.singular_name %>.errors.any? %>
3
+ $("#mdwa_error").html("<%%= escape_javascript( render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> )%>");
4
+ <%% else %>
5
+ $.fancybox.close(true);
6
+ $("#<%= @model.plural_name %>_list").html("<%%= j( render 'list' )%>");
7
+ $('body').append("<%%= j( render '/template/mdwa/notice', :notice => @system_notice )%>");
8
+ <%% end %>
@@ -0,0 +1,3 @@
1
+ ===entity_code===
2
+ $("#<%= @model.plural_name %>_list").html("<%%= j( render 'list' )%>");
3
+ $('body').append("<%%= escape_javascript( render '/template/mdwa/notice', :notice => @system_notice )%>");
@@ -0,0 +1,10 @@
1
+ ===entity_code===
2
+ <div id="<%= @model.plural_name %>_edit" class="mdwa_edit">
3
+ <div class="page_header">
4
+ <h1><%%= t('<%= @model.plural_name %>.edit_title') %></h1>
5
+ </div>
6
+
7
+ <div class="inside">
8
+ <%%= render 'form' %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,17 @@
1
+ ===entity_code===
2
+ <div id="<%= @model.plural_name %>_index" class="mdwa_index">
3
+ <div class="page_header">
4
+ <h1><%%= t '<%= @model.plural_name %>.index_title' %></h1>
5
+ <%- if @entity.ajax -%>
6
+ <div class="page_header_right_tab">
7
+ <%%= link_to t('system.add_by_ajax', :name => '<%= @model.singular_name.humanize %>'), new_<%= @model.object_name %>_path, :class => 'lightbox various fancybox.ajax' %>
8
+ </div>
9
+ <%- end -%>
10
+ </div>
11
+
12
+ <div class="inside">
13
+ <div id="<%= @model.plural_name %>_list">
14
+ <%%= render 'list' %>
15
+ </div>
16
+ </div>
17
+ </div>
@@ -0,0 +1,2 @@
1
+ ===entity_code===
2
+ $("#<%= @model.plural_name %>_list").html("<%%= escape_javascript( render 'list' )%>");
@@ -0,0 +1,10 @@
1
+ ===entity_code===
2
+ <div id="<%= @model.plural_name %>_new" class="mdwa_new">
3
+ <div class="page_header">
4
+ <h1><%%= t('<%= @model.plural_name %>.new_title') %></h1>
5
+ </div>
6
+
7
+ <div class="inside">
8
+ <%%= render 'form' %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,31 @@
1
+ ===entity_code===
2
+ <div id="<%= @model.plural_name %>_show" class="mdwa_show">
3
+ <div class="page_header">
4
+ <h1><%%= t('<%= @model.plural_name %>.show_title') %></h1>
5
+ </div>
6
+
7
+ <div class="inside">
8
+ <%- @model.attributes.each do |attr| -%>
9
+ <div class="field">
10
+ <label><%%= t '<%= @model.plural_name %>.show_<%= attr.name %>' %></label>
11
+ <span><%%= @<%= @model.singular_name %>.<%= attr.name %> %></span>
12
+ </div>
13
+ <%- end -%>
14
+ <%- @model.associations.each do |assoc| -%>
15
+ <div class="field">
16
+ <label><%%= t '<%= @model.plural_name %>.show_<%= assoc.model2.singular_name %>' %></label>
17
+ <span>
18
+ <%- if assoc.belongs_to? || assoc.nested_one? -%>
19
+ <%%= @<%= @model.singular_name %>.<%= assoc.model2.singular_name %>.<%= assoc.reference_field %> unless @<%= @model.singular_name %>.<%= assoc.model2.singular_name %>.nil? %>
20
+ <%- elsif assoc.has_many? or assoc.nested_many? -%>
21
+ <ul>
22
+ <%% @<%= @model.singular_name %>.<%= assoc.model2.plural_name %>.each do |<%= assoc.model2.singular_name %>| %>
23
+ <li><%%= <%= assoc.model2.singular_name %>.<%= assoc.reference_field %> %> </li>
24
+ <%% end %>
25
+ </ul>
26
+ <%- end -%>
27
+ </span>
28
+ </div>
29
+ <%- end -%>
30
+ </div>
31
+ </div>
@@ -0,0 +1,13 @@
1
+ ===entity_code===
2
+ <%% if @<%= @model.singular_name %>.errors.any? %>
3
+ $("#mdwa_error").html("<%%= escape_javascript( render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> )%>");
4
+ <%% else %>
5
+ if( $('#<%= @model.plural_name %>_list').length > 0 ) {
6
+ $.fancybox.close(true);
7
+ $("#<%= @model.plural_name %>_list").html("<%%= j( render 'list' )%>");
8
+ }
9
+ else if( $("#edit_<%= @model.plural_name %>").length > 0 ) {
10
+ $("#edit_<%= @model.plural_name %> .inside").html("<%%= j( render 'form' )%>");
11
+ }
12
+ $('body').append("<%%= j( render '/template/mdwa/notice', :notice => @system_notice )%>");
13
+ <%% end %>