mdd 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/controllers/mdwa/mdwa_controller.rb +2 -1
- data/app/controllers/mdwa/requirements_controller.rb +2 -1
- data/app/helpers/mdwa_helper.rb +19 -5
- data/app/views/template/mdwa/_autocomplete_multiple_tag.html.erb +2 -2
- data/app/views/template/mdwa/_autocomplete_remote_multiple_tag.html.erb +49 -0
- data/app/views/template/mdwa/_autocomplete_remote_tag.html.erb +24 -0
- data/app/views/template/mdwa/_autocomplete_tag.html.erb +1 -1
- data/app/views/template/mdwa/_crud_error.html.erb +1 -1
- data/app/views/template/mdwa/_login_text.html.erb +4 -3
- data/app/views/template/mdwa/_notice.html.erb +3 -3
- data/lib/extensions/string.rb +2 -2
- data/lib/generators/mdwa/entity/entity_generator.rb +1 -1
- data/lib/generators/mdwa/entity/templates/entity.rb +1 -1
- data/lib/generators/mdwa/from_requirements/from_requirements_generator.rb +2 -2
- data/lib/generators/mdwa/requirement/templates/requirement.rb +2 -3
- data/lib/generators/mdwa/sandbox/sandbox_generator.rb +2 -1
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/blank.gif +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/fancybox_loading.gif +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/fancybox_overlay.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/fancybox_sprite.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_flat_10_000000_40x100.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_228ef1_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_ef8c08_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_ffd27a_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/jquery/jquery.fancybox.js +45 -31
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/jquery/jquery.mousewheel.js +12 -12
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/login_manifest.js +1 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/all_pages.js +6 -3
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/pagination.js +6 -2
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/jquery/jquery-ui-1.10.0.custom.css +1174 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/jquery/{jquery.fancybox.css → jquery.fancybox.css.erb} +94 -71
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/login/login.css +67 -60
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/system_manifest.css +1 -7
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/backend.css.erb +35 -66
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/template.css.erb +372 -34
- data/lib/generators/mdwa/sandbox/templates/config/locales/mdwa.en.yml +4 -0
- data/lib/generators/mdwa/scaffold/templates/controllers/ajax_controller.rb +1 -1
- data/lib/generators/mdwa/scaffold/templates/controllers/controller.rb +1 -1
- data/lib/generators/mdwa/scaffold/templates/specs/routing.rb +1 -1
- data/lib/generators/mdwa/templates/templates/general/routes.rb +2 -1
- data/lib/generators/mdwa/templates/templates/scaffold/controller.erb +51 -37
- data/lib/generators/mdwa/templates/templates/scaffold/views/_form_fields.html.erb +2 -2
- data/lib/generators/mdwa/templates/templates/scaffold/views/_list.html.erb +10 -9
- data/lib/generators/mdwa/templates/templates/scaffold/views/create.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/destroy.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/index.html.erb +46 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/index.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/update.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates_generator.rb +1 -1
- data/lib/generators/mdwa/transform/transform_generator.rb +81 -73
- data/lib/generators/mdwa/user/templates/user.rb +1 -1
- data/lib/generators/mdwa/user_scaffold/templates/migrate.erb +12 -4
- data/lib/generators/mdwa/user_scaffold/user_scaffold_generator.rb +9 -2
- data/lib/mdwa/dsl/entity.rb +11 -10
- data/lib/mdwa/dsl/entity_association.rb +11 -3
- data/lib/mdwa/dsl/entity_attribute.rb +8 -1
- data/lib/mdwa/dsl/process.rb +2 -0
- data/lib/mdwa/dsl/process_detail.rb +2 -0
- data/lib/mdwa/dsl/process_detail_next_action.rb +3 -1
- data/lib/mdwa/dsl/requirement.rb +6 -3
- data/lib/mdwa/dsl/requirements.rb +1 -1
- data/lib/mdwa/dsl/workflow.rb +1 -1
- data/lib/mdwa/generators/model.rb +8 -0
- data/lib/mdwa/generators/model_association.rb +9 -0
- data/lib/mdwa/generators/model_attribute.rb +46 -24
- data/lib/mdwa/version.rb +1 -1
- data/mdd.gemspec +1 -1
- data/test/entity_attributes_options_test.rb +43 -0
- data/test/entity_test.rb +6 -6
- data/test/process_test.rb +31 -31
- data/test/requirements_test.rb +3 -5
- metadata +36 -57
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/button_submit.gif +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/jquery/jquery.bgiframe.js +0 -10
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/jquery/jquery-ui-theme1.css +0 -573
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/leftbar.css.erb +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/visualization.css +0 -3
@@ -12,6 +12,7 @@ en:
|
|
12
12
|
logged_info_edit_account: "My Account"
|
13
13
|
cancel_button: "Cancel"
|
14
14
|
save_button: "Save"
|
15
|
+
search_button: "Search"
|
15
16
|
index_id: "ID"
|
16
17
|
index_edit: "Edit"
|
17
18
|
index_edit_label: "Edit"
|
@@ -21,6 +22,9 @@ en:
|
|
21
22
|
add_by_ajax: "Add new %{name}"
|
22
23
|
edit_by_ajax: "Edit %{name}"
|
23
24
|
no_file: "No file"
|
25
|
+
yes: "Yes"
|
26
|
+
no: "No"
|
27
|
+
both: "Both"
|
24
28
|
|
25
29
|
administrators:
|
26
30
|
edit_title: "Editing account: %{name}"
|
@@ -4,7 +4,7 @@ class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'Appl
|
|
4
4
|
load_and_authorize_resource :class => "<%= @model.klass %>"
|
5
5
|
|
6
6
|
def index
|
7
|
-
@<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => params[:page]
|
7
|
+
@<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => params[:page], :per_page => params[:per_page]
|
8
8
|
|
9
9
|
respond_to do |format|
|
10
10
|
format.html
|
@@ -4,7 +4,7 @@ class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'Appl
|
|
4
4
|
load_and_authorize_resource :class => "<%= @model.klass %>"
|
5
5
|
|
6
6
|
def index
|
7
|
-
@<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => params[:page]
|
7
|
+
@<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => params[:page], :per_page => params[:per_page]
|
8
8
|
|
9
9
|
respond_to do |format|
|
10
10
|
format.html
|
@@ -9,17 +9,44 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
|
|
9
9
|
# Hook for code generations. Do not delete.
|
10
10
|
#===controller_init===
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
def index
|
13
|
+
conditions = []
|
14
|
+
<%-
|
15
|
+
atributos_com_filtro = @entity.attributes.values.select {|attr| attr.options[:filtered]}
|
16
|
+
associacoes_com_filtro = @entity.associations.values.select {|assoc| assoc.options[:filtered]}
|
17
|
+
-%>
|
18
|
+
<%- if !atributos_com_filtro.count.zero? -%>
|
19
|
+
<%- atributos_com_filtro.each do |atributo| -%>
|
20
|
+
<%- if [:integer, :float, :decimal, :boolean].include? atributo.type.to_sym -%>
|
21
|
+
conditions << "(<%= @model.plural_name %>.<%= atributo.name %> = '#{params[:<%= atributo.name %>]}')" unless params[:<%= atributo.name %>].blank?
|
22
|
+
<%- elsif [:string, :text].include? atributo.type.to_sym -%>
|
23
|
+
conditions << "(<%= @model.plural_name %>.<%= atributo.name %> LIKE '%#{params[:<%= atributo.name %>]}%')" unless params[:<%= atributo.name %>].blank?
|
24
|
+
<%- elsif [:date].include? atributo.type.to_sym -%>
|
25
|
+
conditions << "(<%= @model.plural_name %>.<%= atributo.name %> BETWEEN '#{params[:<%= atributo.name %>_0].to_date}' AND '#{params[:<%= atributo.name %>_1].to_date}')" if !params[:<%= atributo.name %>_0].blank? and !params[:<%= atributo.name %>_1].blank?
|
26
|
+
conditions << "(<%= @model.plural_name %>.<%= atributo.name %> >= '#{params[:<%= atributo.name %>_0].to_date}')" if !params[:<%= atributo.name %>_0].blank? and params[:<%= atributo.name %>_0].blank?
|
27
|
+
conditions << "(<%= @model.plural_name %>.<%= atributo.name %> <= '#{params[:<%= atributo.name %>_1].to_date}')" if params[:<%= atributo.name %>_0].blank? and !params[:<%= atributo.name %>_1].blank?
|
28
|
+
<%- elsif [:datetime, :timestamp].include? atributo.type.to_sym -%>
|
29
|
+
conditions << "(<%= @model.plural_name %>.<%= atributo.name %> BETWEEN '#{params[:<%= atributo.name %>_0].to_date.beginning_of_day}' AND '#{params[:<%= atributo.name %>_1].to_date.end_of_day}')" if !params[:<%= atributo.name %>_0].blank? and !params[:<%= atributo.name %>_1].blank?
|
30
|
+
conditions << "(<%= @model.plural_name %>.<%= atributo.name %> >= '#{params[:<%= atributo.name %>_0].to_date.beginning_of_day}')" if !params[:<%= atributo.name %>_0].blank? and params[:<%= atributo.name %>_0].blank?
|
31
|
+
conditions << "(<%= @model.plural_name %>.<%= atributo.name %> <= '#{params[:<%= atributo.name %>_1].to_date.end_of_day}')" if params[:<%= atributo.name %>_0].blank? and !params[:<%= atributo.name %>_1].blank?
|
32
|
+
<%- end -%>
|
33
|
+
<%- end -%>
|
34
|
+
<%- end -%>
|
35
|
+
|
36
|
+
<%- associacoes_com_filtro.each do |associacao| -%>
|
37
|
+
conditions << "(<%= @model.plural_name %>.<%= associacao.name %>_id = #{params[:<%= associacao.name %>_id]})" unless params[:<%= associacao.name %>_id].blank?
|
38
|
+
<%- end -%>
|
39
|
+
|
40
|
+
@<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => params[:page], :per_page => params[:per_page], :conditions => conditions.join(' AND ')
|
14
41
|
|
15
42
|
respond_to do |format|
|
16
43
|
format.html
|
17
44
|
format.js
|
18
45
|
end
|
19
|
-
|
46
|
+
end
|
20
47
|
|
21
48
|
|
22
|
-
|
49
|
+
def show
|
23
50
|
@<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
|
24
51
|
|
25
52
|
<%- if @entity.ajax? -%>
|
@@ -29,9 +56,9 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
|
|
29
56
|
format.html
|
30
57
|
end
|
31
58
|
<%- end -%>
|
32
|
-
|
59
|
+
end
|
33
60
|
|
34
|
-
|
61
|
+
def new
|
35
62
|
@<%= @model.singular_name %> = <%= @model.klass %>.new
|
36
63
|
<%- @model.associations.select {|a| a.nested_one?}.each do |assoc| -%>
|
37
64
|
@<%= @model.singular_name %>.<%= assoc.model2.singular_name %> = <%= assoc.model2.klass %>.new
|
@@ -44,9 +71,9 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
|
|
44
71
|
format.html
|
45
72
|
end
|
46
73
|
<%- end -%>
|
47
|
-
|
74
|
+
end
|
48
75
|
|
49
|
-
|
76
|
+
def edit
|
50
77
|
@<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
|
51
78
|
|
52
79
|
<%- if @entity.ajax? -%>
|
@@ -56,15 +83,12 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
|
|
56
83
|
format.html
|
57
84
|
end
|
58
85
|
<%- end -%>
|
59
|
-
|
86
|
+
end
|
60
87
|
|
61
|
-
|
88
|
+
def create
|
62
89
|
@<%= @model.singular_name %> = <%= @model.klass %>.new(params[:<%= @model.to_params %>])
|
63
90
|
saved_ok = @<%= @model.singular_name %>.save
|
64
|
-
@system_notice = t('<%= @model.plural_name %>.
|
65
|
-
<%- if @entity.ajax? -%>
|
66
|
-
load_list # loads all <%= @model.plural_name %> to display in the list
|
67
|
-
<%- end -%>
|
91
|
+
@system_notice = t('<%= @model.plural_name %>.notice.create') if saved_ok
|
68
92
|
|
69
93
|
<%- @model.associations.select{|a| a.has_and_belongs_to_many? and a.composition?}.each do |association| -%>
|
70
94
|
unless params[:<%= association.model2.plural_name %>].nil?
|
@@ -86,9 +110,9 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
|
|
86
110
|
end
|
87
111
|
<%- end -%>
|
88
112
|
end
|
89
|
-
|
113
|
+
end
|
90
114
|
|
91
|
-
|
115
|
+
def update
|
92
116
|
@<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
|
93
117
|
<%- if @entity.user? -%>
|
94
118
|
# if password is blank, delete from params
|
@@ -97,11 +121,9 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
|
|
97
121
|
params[:<%= @model.object_name %>].delete :password_confirmation
|
98
122
|
end
|
99
123
|
<%- end -%>
|
100
|
-
|
101
|
-
|
102
|
-
@system_notice = t('<%= @model.plural_name %>.
|
103
|
-
load_list # loads all <%= @model.plural_name %> to display in the list
|
104
|
-
<%- end -%>
|
124
|
+
@<%= @model.singular_name %>.attributes = params[:<%= @model.to_params %>]
|
125
|
+
saved_ok = @<%= @model.singular_name %>.save
|
126
|
+
@system_notice = t('<%= @model.plural_name %>.notice.update') if saved_ok
|
105
127
|
|
106
128
|
<%- @model.associations.select{|a| a.has_and_belongs_to_many? and a.composition?}.each do |association| -%>
|
107
129
|
unless params[:<%= association.model2.plural_name %>].nil?
|
@@ -116,21 +138,18 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
|
|
116
138
|
<%- if @entity.ajax? -%>
|
117
139
|
format.js
|
118
140
|
<%- else -%>
|
119
|
-
if
|
120
|
-
format.html { redirect_to <%= @model.object_name.pluralize %>_path, notice:
|
141
|
+
if saved_ok
|
142
|
+
format.html { redirect_to <%= @model.object_name.pluralize %>_path, notice: @system_notice }
|
121
143
|
else
|
122
144
|
format.html { render action: "edit" }
|
123
145
|
end
|
124
146
|
<%- end -%>
|
125
147
|
end
|
126
|
-
|
148
|
+
end
|
127
149
|
|
128
|
-
|
150
|
+
def destroy
|
129
151
|
@<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
|
130
|
-
@system_notice = t('<%= @model.plural_name %>.
|
131
|
-
<%- if @entity.ajax? -%>
|
132
|
-
load_list # loads all <%= @model.plural_name %> to display in the list
|
133
|
-
<%- end -%>
|
152
|
+
@system_notice = t('<%= @model.plural_name %>.notice.destroy') if @<%= @model.singular_name %>.destroy
|
134
153
|
|
135
154
|
respond_to do |format|
|
136
155
|
<%- if @entity.ajax? -%>
|
@@ -139,12 +158,7 @@ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::
|
|
139
158
|
format.html { redirect_to <%= @model.object_name.pluralize %>_path, notice: @system_notice }
|
140
159
|
<%- end -%>
|
141
160
|
end
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
private
|
146
|
-
def load_list
|
147
|
-
@<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => 1
|
148
|
-
end
|
149
|
-
|
161
|
+
end
|
162
|
+
|
163
|
+
|
150
164
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<div class="field">
|
4
4
|
<%%= f.label :<%= attr.name %>, t('<%= @model.plural_name %>.edit.<%= attr.name %>') %>
|
5
5
|
<%- if attr.type.to_sym == :file -%>
|
6
|
-
<%%
|
6
|
+
<%% if !@<%= @model.singular_name %>.new_record? and !@<%= @model.singular_name %>.<%= attr.name %>.blank? %>
|
7
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
8
|
<%% end %>
|
9
9
|
<%- end -%>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<%%= f.label :<%= assoc.model2.singular_name.foreign_key %>, t('<%= @model.plural_name %>.edit.<%= assoc.model2.singular_name %>') %>
|
19
19
|
<%%= f.select :<%= assoc.model2.singular_name.foreign_key %>,
|
20
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 => '
|
21
|
+
:prompt => t('<%= @model.plural_name %>.edit.<%= assoc.model2.singular_name %>_select') %>
|
22
22
|
</div>
|
23
23
|
<%- end # if -%>
|
24
24
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
===entity_code===
|
2
2
|
<table class="list">
|
3
3
|
<thead>
|
4
|
-
<th class="list_show"><%%= t '
|
5
|
-
<th class="list_edit"><%%= t 'system.index_edit' %></th>
|
4
|
+
<th class="list_show"><%%= t '<%= @model.plural_name %>.index.id' %></th>
|
6
5
|
<%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.each do |attr| -%>
|
7
|
-
<th><%%= t '<%= @model.plural_name %>.
|
6
|
+
<th><%%= t '<%= @model.plural_name %>.index.<%= attr.name %>' %></th>
|
8
7
|
<%- end -%>
|
9
8
|
<%- @model.associations.each do |assoc| -%>
|
10
9
|
<th><%%= t '<%= @model.plural_name %>.index.<%= assoc.model2.singular_name %>' %></th>
|
11
10
|
<%- end -%>
|
12
|
-
<th class="
|
11
|
+
<th class="list_edit"><%%= t '<%= @model.plural_name %>.index.edit' %></th>
|
12
|
+
<th class="list_remove"><%%= t '<%= @model.plural_name %>.index.remove' %></th>
|
13
13
|
</thead>
|
14
14
|
|
15
15
|
<%% @<%= @model.plural_name %>.each do |<%= @model.singular_name %>| %>
|
@@ -17,16 +17,14 @@
|
|
17
17
|
<td class="list_show">
|
18
18
|
<%%= link_to <%= @model.singular_name %>.id, <%= @model.object_name %>_path(<%= @model.singular_name %>) <%= ", :class => 'lightbox various fancybox.ajax'" if @entity.ajax %> %>
|
19
19
|
</td>
|
20
|
-
|
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>
|
20
|
+
|
23
21
|
<%- @model.attributes.select{|a| a.name != 'id' and a.name != 'created_at' and a.name != 'updated_at'}.each do |attr| -%>
|
24
22
|
<td>
|
25
23
|
<%- if attr.type.to_sym == :file -%>
|
26
24
|
<%% unless <%= @model.singular_name %>.<%= attr.name %>_file_name.blank? %>
|
27
25
|
<%%= link_to image_tag(file_icon_path(<%= @model.singular_name %>.<%= attr.name %>_file_name)), <%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %>
|
28
26
|
<%% else %>
|
29
|
-
|
27
|
+
<%%= t 'system.no_file' %>
|
30
28
|
<%% end %>
|
31
29
|
<%- else -%>
|
32
30
|
<%%= <%= @model.singular_name %>.<%= attr.name %> %>
|
@@ -47,8 +45,11 @@
|
|
47
45
|
<%- end -%>
|
48
46
|
</td>
|
49
47
|
<%- end -%>
|
48
|
+
<td class="list_edit">
|
49
|
+
<%%= 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
|
+
</td>
|
50
51
|
<td class="list_remove">
|
51
|
-
<%%= link_to t('
|
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')} %>
|
52
53
|
</td>
|
53
54
|
</tr>
|
54
55
|
<%% end %>
|
@@ -3,6 +3,6 @@
|
|
3
3
|
$("#mdwa_error").html("<%%= j( render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> )%>");
|
4
4
|
<%% else %>
|
5
5
|
$.fancybox.close(true);
|
6
|
-
$(
|
6
|
+
$('#<%= @model.plural_name %>_filter_form').submit();
|
7
7
|
$('body').append("<%%= j( render '/template/mdwa/notice', :notice => @system_notice )%>");
|
8
8
|
<%% end %>
|
@@ -4,12 +4,57 @@
|
|
4
4
|
<h1><%%= t '<%= @model.plural_name %>.title.index' %></h1>
|
5
5
|
<%- if @entity.ajax -%>
|
6
6
|
<div class="page_header_right_tab">
|
7
|
-
<%%= link_to t('
|
7
|
+
<%%= link_to t('<%= @model.plural_name %>.index.add'), new_<%= @model.object_name %>_path, :class => 'lightbox various fancybox.ajax' %>
|
8
8
|
</div>
|
9
9
|
<%- end -%>
|
10
10
|
</div>
|
11
11
|
|
12
12
|
<div class="inside">
|
13
|
+
|
14
|
+
<div class="topo">
|
15
|
+
<div class="yui3-g">
|
16
|
+
<%%= form_tag <%= @model.object_name.pluralize %>_path, :method => :get, :remote => true, :id => '<%= @model.plural_name %>_filter_form' do %>
|
17
|
+
|
18
|
+
<%-
|
19
|
+
atributos_com_filtro = @entity.attributes.values.select {|attr| attr.options[:filtered]}
|
20
|
+
associacoes_com_filtro = @entity.associations.values.select {|assoc| assoc.options[:filtered]}
|
21
|
+
-%>
|
22
|
+
<%- if !atributos_com_filtro.count.zero? or !associacoes_com_filtro.count.zero? -%>
|
23
|
+
<%- atributos_com_filtro.each do |atributo| -%>
|
24
|
+
<div class="yui3-u-1-5">
|
25
|
+
<div class="field">
|
26
|
+
<%%= label_tag :<%= atributo.name %>, t('<%= @model.plural_name %>.filtros.<%= atributo.name %>') %>
|
27
|
+
<%- atributo.to_model_attribute.filter_input.each do |input| -%>
|
28
|
+
<%%= <%= input %> %>
|
29
|
+
<%- end -%>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<%- end -%>
|
33
|
+
|
34
|
+
<%- associacoes_com_filtro.each do |associacao| -%>
|
35
|
+
<div class="yui3-u-1-5">
|
36
|
+
<div class="field">
|
37
|
+
<%%= label_tag :<%= associacao.name %>, t('<%= @model.plural_name %>.filtros.<%= associacao.name %>') %>
|
38
|
+
<%- associacao.to_model_association.filter_input(associacao.options[:filter_field]).each do |input| -%>
|
39
|
+
<%%= <%= input %> %>
|
40
|
+
<%- end -%>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
<%- end -%>
|
44
|
+
|
45
|
+
<!-- Botão buscar -->
|
46
|
+
<div class="yui3-u-1-5">
|
47
|
+
<div class="field">
|
48
|
+
<label> </label>
|
49
|
+
<%%= submit_tag t('system.search_button'), :class => :button %>
|
50
|
+
</div>
|
51
|
+
</div>
|
52
|
+
<%- end -%>
|
53
|
+
|
54
|
+
<%% end %>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
|
13
58
|
<div id="<%= @model.plural_name %>_list">
|
14
59
|
<%%= render 'list' %>
|
15
60
|
</div>
|
@@ -1,2 +1,2 @@
|
|
1
1
|
===entity_code===
|
2
|
-
$("#<%= @model.plural_name %>_list").html("<%%=
|
2
|
+
$("#<%= @model.plural_name %>_list").html("<%%= j( render 'list' )%>");
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<%% else %>
|
5
5
|
if( $('#<%= @model.plural_name %>_list').length > 0 ) {
|
6
6
|
$.fancybox.close(true);
|
7
|
-
$(
|
7
|
+
$('#<%= @model.plural_name %>_filter_form').submit();
|
8
8
|
}
|
9
9
|
else if( $("#edit_<%= @model.plural_name %>").length > 0 ) {
|
10
10
|
$("#edit_<%= @model.plural_name %> .inside").html("<%%= j( render 'form' )%>");
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
1
3
|
require 'erb'
|
2
4
|
require 'mdwa/dsl'
|
3
5
|
|
@@ -15,6 +17,7 @@ module Mdwa
|
|
15
17
|
attr_accessor :pending_migrations
|
16
18
|
|
17
19
|
argument :entities, :type => :array, :banner => 'Entities to transform', :default => []
|
20
|
+
class_option :skip_locales, :type => :boolean, :default => false, :desc => "Skip I18n generation?"
|
18
21
|
|
19
22
|
source_root File.expand_path("../templates", __FILE__)
|
20
23
|
|
@@ -45,30 +48,34 @@ module Mdwa
|
|
45
48
|
def generate_model_controller_helper_views
|
46
49
|
@entities.each do |entity|
|
47
50
|
generator_model = entity.generator_model
|
48
|
-
|
49
|
-
|
51
|
+
|
52
|
+
#
|
53
|
+
# Para cada namespace, gera seu código
|
54
|
+
#
|
55
|
+
# Pasta onde o código gerado vai ser colocado
|
56
|
+
# Namespace 'frontend' é o público e gera código nas raízes do Rails
|
57
|
+
namespaces = Dir.glob("#{Rails.root}/#{MDWA::DSL::TEMPLATES_PATH}#{entity.file_name}/*").select{|d| File.directory?(d)}.collect {|n| File.basename(n)}
|
50
58
|
if !namespaces.count.zero?
|
51
59
|
namespaces.each do |namespace|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
|
61
|
+
namespace_destino = (namespace != 'frontend') ? namespace : ''
|
62
|
+
templates_deste_namespace = MDWA::DSL::TEMPLATES_PATH + entity.file_name + '/' + namespace + '/'
|
63
|
+
|
64
|
+
# Gera model, controllers e helper
|
65
|
+
mdwa_template "#{entity.file_name}/#{namespace}/model.erb", "app/models/#{namespace_destino}/#{generator_model.singular_name}.rb" if File.exists?(templates_deste_namespace + 'model.erb')
|
66
|
+
mdwa_template "#{entity.file_name}/#{namespace}/helper.erb", "app/helpers/#{namespace_destino}/#{generator_model.plural_name}_helper.rb" if File.exists?(templates_deste_namespace + 'helper.erb')
|
67
|
+
mdwa_template "#{entity.file_name}/#{namespace}/controller.erb", "app/controllers/#{namespace_destino}/#{generator_model.plural_name}_controller.rb" if File.exists?(templates_deste_namespace + 'controller.erb')
|
68
|
+
|
69
|
+
# Gera as views
|
70
|
+
Dir.glob("#{templates_deste_namespace}/views/*").each do |file|
|
56
71
|
file_name = File.basename(file)
|
57
|
-
mdwa_template "#{entity.file_name}/#{
|
72
|
+
mdwa_template "#{entity.file_name}/#{namespace}/views/#{file_name}", "app/views/#{namespace_destino}/#{generator_model.plural_name}/#{file_name}"
|
58
73
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
mdwa_template "#{entity_name}/controller.rb", "app/controllers/#{generator_model.space}/#{generator_model.plural_name}_controller.rb"
|
65
|
-
Dir.glob("#{entity_name}/views/*").each do |file|
|
66
|
-
file_name = File.basename(file)
|
67
|
-
mdwa_template "#{entity.file_name}/views/#{file_name}", "app/views/#{generator_model.space}/#{generator_model.plural_name}/#{file_name}"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
74
|
+
|
75
|
+
end # nm.each
|
76
|
+
end # if nm == 0
|
77
|
+
end # each
|
78
|
+
end # def
|
72
79
|
|
73
80
|
def generate_routes
|
74
81
|
|
@@ -120,6 +127,8 @@ module Mdwa
|
|
120
127
|
|
121
128
|
def generate_locales
|
122
129
|
|
130
|
+
return nil if options.skip_locales
|
131
|
+
|
123
132
|
locales_file = 'config/locales/mdwa.specific.en.yml'
|
124
133
|
locales_content = File.read(locales_file)
|
125
134
|
# make sure the file exist
|
@@ -128,46 +137,52 @@ module Mdwa
|
|
128
137
|
@entities.each do |entity|
|
129
138
|
model = entity.generator_model
|
130
139
|
if !locales_content.include?( " #{model.plural_name}:" )
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
lines << ((assoc.belongs_to? or assoc.nested_one? or assoc.has_one?) ? " #{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\"" : " #{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\"")
|
158
|
-
end
|
159
|
-
# SHOW
|
160
|
-
lines << " show:"
|
161
|
-
model.attributes.each do |attr|
|
162
|
-
lines << " #{attr.name}: \"#{attr.name.humanize}\""
|
163
|
-
end
|
164
|
-
model.associations.each do |assoc|
|
165
|
-
lines << ((assoc.belongs_to? or assoc.nested_one? or assoc.has_one?) ? " #{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\"" : " #{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\"")
|
166
|
-
end
|
167
|
-
|
168
|
-
lines << "\n"
|
169
|
-
lines.join("\n")
|
140
|
+
puts "Não tem"
|
141
|
+
lines = []
|
142
|
+
lines << "\n"
|
143
|
+
lines << " #{model.plural_name}:"
|
144
|
+
lines << " notice:"
|
145
|
+
lines << " create: \"#{model.singular_name.humanize} created.\""
|
146
|
+
lines << " update: \"#{model.singular_name.humanize} updated.\""
|
147
|
+
lines << " destroy: \"#{model.singular_name.humanize} destroyed.\""
|
148
|
+
lines << " title:"
|
149
|
+
lines << " index: \"#{model.plural_name.humanize}\""
|
150
|
+
lines << " show: \"#{model.singular_name.humanize}\""
|
151
|
+
lines << " new: \"New #{model.singular_name.humanize}\""
|
152
|
+
lines << " edit: \"Edit #{model.singular_name.humanize}\""
|
153
|
+
# INDEX
|
154
|
+
lines << " index:"
|
155
|
+
lines << " add: 'Adicionar'"
|
156
|
+
lines << " edit: 'Edit'"
|
157
|
+
lines << " edit_label: 'Edit'"
|
158
|
+
lines << " remove: 'Remove'"
|
159
|
+
lines << " remove_label: 'Remove'"
|
160
|
+
lines << " confirm_deletion: 'Are you sure?'"
|
161
|
+
model.attributes.each do |attr|
|
162
|
+
lines << " #{attr.name}: \"#{attr.name.humanize}\""
|
163
|
+
end
|
164
|
+
model.associations.each do |assoc|
|
165
|
+
lines << ((assoc.belongs_to? or assoc.nested_one? or assoc.has_one?) ? " #{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\"" : " #{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\"")
|
170
166
|
end
|
167
|
+
# EDIT
|
168
|
+
lines << " edit:"
|
169
|
+
model.attributes.each do |attr|
|
170
|
+
lines << " #{attr.name}: \"#{attr.name.humanize}\""
|
171
|
+
end
|
172
|
+
model.associations.each do |assoc|
|
173
|
+
lines << ((assoc.belongs_to? or assoc.nested_one? or assoc.has_one?) ? " #{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\"" : " #{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\"")
|
174
|
+
end
|
175
|
+
# SHOW
|
176
|
+
lines << " show:"
|
177
|
+
model.attributes.each do |attr|
|
178
|
+
lines << " #{attr.name}: \"#{attr.name.humanize}\""
|
179
|
+
end
|
180
|
+
model.associations.each do |assoc|
|
181
|
+
lines << ((assoc.belongs_to? or assoc.nested_one? or assoc.has_one?) ? " #{assoc.model2.singular_name}: \"#{assoc.model2.singular_name.humanize}\"" : " #{assoc.model2.singular_name}: \"#{assoc.model2.plural_name.humanize}\"")
|
182
|
+
end
|
183
|
+
lines << "\n"
|
184
|
+
|
185
|
+
append_file locales_file, lines.join("\n"), :after => "en:"
|
171
186
|
end
|
172
187
|
|
173
188
|
end # @entities loop
|
@@ -235,10 +250,10 @@ module Mdwa
|
|
235
250
|
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type}
|
236
251
|
else
|
237
252
|
# se o atributo é derivado de file e não existe o file na entidade, apaga
|
238
|
-
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_file_name") and entity.attributes[column.name.
|
239
|
-
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_content_type") and entity.attributes[column.name.
|
240
|
-
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_file_size") and entity.attributes[column.name.
|
241
|
-
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_updated_at") and entity.attributes[column.name.
|
253
|
+
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_file_name") and entity.attributes[column.name.gsub("_file_name", '')].nil?
|
254
|
+
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_content_type") and entity.attributes[column.name.gsub("_content_type", '')].nil?
|
255
|
+
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_file_size") and entity.attributes[column.name.gsub("_file_size", '')].nil?
|
256
|
+
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type} if column.name.ends_with?("_updated_at") and entity.attributes[column.name.gsub("_updated_at", '')].nil?
|
242
257
|
end
|
243
258
|
# attribute exists in model and entity, but changed type
|
244
259
|
elsif entity_attribute.type.to_sym != column.type.to_sym
|
@@ -251,7 +266,7 @@ module Mdwa
|
|
251
266
|
# new attributes
|
252
267
|
# no column with that name -> column must be added
|
253
268
|
entity.attributes.each do |key, attr|
|
254
|
-
# se
|
269
|
+
# se o atributo for file e não existir seus atributos no banco de dados, corrige
|
255
270
|
if attr.type.to_sym == :file
|
256
271
|
@changes << {:entity => entity, :type => 'add_column', :column => "#{attr.name}_file_name", :attr_type => 'string'} if model_class.columns.select{|c| c.name == "#{attr.name}_file_name"}.count.zero?
|
257
272
|
@changes << {:entity => entity, :type => 'add_column', :column => "#{attr.name}_content_type", :attr_type => 'string'} if model_class.columns.select{|c| c.name == "#{attr.name}_content_type"}.count.zero?
|
@@ -321,14 +336,7 @@ module Mdwa
|
|
321
336
|
migration_string << "\n\tdef self.up"
|
322
337
|
migration_string << "\t\tcreate_table :#{generator_model.plural_name} do |t|"
|
323
338
|
generator_model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.each do |attr|
|
324
|
-
|
325
|
-
migration_string << "\t\t\tt.#{attr.migration_field} :#{attr.name}"
|
326
|
-
else
|
327
|
-
migration_string << "\t\t\tt.string :#{attr.name}_file_name"
|
328
|
-
migration_string << "\t\t\tt.string :#{attr.name}_content_type"
|
329
|
-
migration_string << "\t\t\tt.integer :#{attr.name}_file_size"
|
330
|
-
migration_string << "\t\t\tt.datetime :#{attr.name}_updated_at"
|
331
|
-
end
|
339
|
+
migration_string << "\t\t\tt.#{attr.migration_field} :#{attr.name}"
|
332
340
|
end
|
333
341
|
generator_model.associations.each do |assoc|
|
334
342
|
if assoc.belongs_to? or assoc.nested_one?
|
@@ -392,4 +400,4 @@ module Mdwa
|
|
392
400
|
end
|
393
401
|
|
394
402
|
end
|
395
|
-
end
|
403
|
+
end
|