beautiful_scaffold 0.0.1 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +21 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +10 -0
- data/beautiful_scaffold.gemspec +18 -0
- data/lib/generators/USAGE +15 -0
- data/lib/generators/beautiful_locale_generator.rb +34 -0
- data/lib/generators/beautiful_migration_generator.rb +53 -0
- data/lib/generators/beautiful_scaffold_common_methods.rb +104 -0
- data/lib/generators/beautiful_scaffold_generator.rb +158 -0
- data/lib/generators/templates/app/assets/images/bg-bottom-login.jpg +0 -0
- data/lib/generators/templates/app/assets/images/bg-error.png +0 -0
- data/lib/generators/templates/app/assets/images/bg-left.jpg +0 -0
- data/lib/generators/templates/app/assets/images/bg-notice.jpg +0 -0
- data/lib/generators/templates/app/assets/images/bg-notice.png +0 -0
- data/lib/generators/templates/app/assets/images/bg-success.png +0 -0
- data/lib/generators/templates/app/assets/images/bg-top-login.jpg +0 -0
- data/lib/generators/templates/app/assets/images/bg-warning.png +0 -0
- data/lib/generators/templates/app/assets/javascripts/beautiful_scaffold.js +80 -0
- data/lib/generators/templates/app/assets/javascripts/jquery.pjax.js +370 -0
- data/lib/generators/templates/app/assets/javascripts/modernizr.custom.js +4 -0
- data/lib/generators/templates/app/assets/stylesheets/beautiful_scaffold.css.scss +719 -0
- data/lib/generators/templates/app/assets/stylesheets/reset.css +48 -0
- data/lib/generators/templates/app/controllers/base.rb +177 -0
- data/lib/generators/templates/app/controllers/master_base.rb +37 -0
- data/lib/generators/templates/app/helpers/beautiful_helper.rb +130 -0
- data/lib/generators/templates/app/helpers/model_helper.rb +4 -0
- data/lib/generators/templates/app/locales/beautiful_scaffold.en.yml +30 -0
- data/lib/generators/templates/app/locales/beautiful_scaffold.fr.yml +30 -0
- data/lib/generators/templates/app/models/pdf_report.rb +40 -0
- data/lib/generators/templates/app/views/_beautiful_menu.html.erb +9 -0
- data/lib/generators/templates/app/views/_form.html.erb +24 -0
- data/lib/generators/templates/app/views/edit.html.erb +6 -0
- data/lib/generators/templates/app/views/index.html.erb +86 -0
- data/lib/generators/templates/app/views/layout.html.erb +70 -0
- data/lib/generators/templates/app/views/new.html.erb +5 -0
- data/lib/generators/templates/app/views/partials/_form_field.html.erb +37 -0
- data/lib/generators/templates/app/views/partials/_index_batch.html.erb +6 -0
- data/lib/generators/templates/app/views/partials/_index_column.html.erb +19 -0
- data/lib/generators/templates/app/views/partials/_index_header.html.erb +9 -0
- data/lib/generators/templates/app/views/partials/_index_search.html.erb +10 -0
- data/lib/generators/templates/app/views/partials/_show_field.html.erb +14 -0
- data/lib/generators/templates/app/views/show.html.erb +7 -0
- data/lib/generators/templates/markitup/jquery.markitup.js +593 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/clean.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/code.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/fonts.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/list-item.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/quotes.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/underline.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/bbcode/set.js +39 -0
- data/lib/generators/templates/markitup/sets/bbcode/style.css +47 -0
- data/lib/generators/templates/markitup/sets/default/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/clean.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/image.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/default/set.js +30 -0
- data/lib/generators/templates/markitup/sets/default/style.css +34 -0
- data/lib/generators/templates/markitup/sets/html/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/clean.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h1.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h2.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h3.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h4.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h5.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h6.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/image.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/list-item.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/paragraph.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/html/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/html/set.js +39 -0
- data/lib/generators/templates/markitup/sets/html/style.css +59 -0
- data/lib/generators/templates/markitup/sets/markdown/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/code.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h1.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h2.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h3.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h4.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h5.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h6.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/quotes.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/markdown/set.js +52 -0
- data/lib/generators/templates/markitup/sets/markdown/style.css +54 -0
- data/lib/generators/templates/markitup/sets/textile/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/code.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h1.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h2.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h3.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h4.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h5.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h6.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/paragraph.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/quotes.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/textile/set.js +40 -0
- data/lib/generators/templates/markitup/sets/textile/style.css +60 -0
- data/lib/generators/templates/markitup/sets/wiki/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/code.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h1.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h2.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h3.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h4.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h5.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h6.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/quotes.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/url.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/wiki/set.js +37 -0
- data/lib/generators/templates/markitup/sets/wiki/style.css +57 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-container.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-bbcode.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-dotclear.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-html.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-json.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-markdown.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-textile.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-wiki.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-xml.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/handle.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/menu.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/submenu.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/style.css +147 -0
- data/lib/generators/templates/markitup/skins/simple/images/handle.png +0 -0
- data/lib/generators/templates/markitup/skins/simple/images/menu.png +0 -0
- data/lib/generators/templates/markitup/skins/simple/images/submenu.png +0 -0
- data/lib/generators/templates/markitup/skins/simple/style.css +118 -0
- data/lib/generators/templates/markitup/templates/preview.css +5 -0
- data/lib/generators/templates/markitup/templates/preview.html +11 -0
- data/lib/generators/templates/modules/beautiful_scaffold_module.rb +28 -0
- metadata +175 -3
@@ -0,0 +1,48 @@
|
|
1
|
+
/* http://meyerweb.com/eric/tools/css/reset/
|
2
|
+
v2.0 | 20110126
|
3
|
+
License: none (public domain)
|
4
|
+
*/
|
5
|
+
|
6
|
+
html, body, div, span, applet, object, iframe,
|
7
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
8
|
+
a, abbr, acronym, address, big, cite, code,
|
9
|
+
del, dfn, em, img, ins, kbd, q, s, samp,
|
10
|
+
small, strike, strong, sub, sup, tt, var,
|
11
|
+
b, u, i, center,
|
12
|
+
dl, dt, dd, ol, ul, li,
|
13
|
+
fieldset, form, label, legend,
|
14
|
+
table, caption, tbody, tfoot, thead, tr, th, td,
|
15
|
+
article, aside, canvas, details, embed,
|
16
|
+
figure, figcaption, footer, header, hgroup,
|
17
|
+
menu, nav, output, ruby, section, summary,
|
18
|
+
time, mark, audio, video {
|
19
|
+
margin: 0;
|
20
|
+
padding: 0;
|
21
|
+
border: 0;
|
22
|
+
font-size: 100%;
|
23
|
+
font: inherit;
|
24
|
+
vertical-align: baseline;
|
25
|
+
}
|
26
|
+
/* HTML5 display-role reset for older browsers */
|
27
|
+
article, aside, details, figcaption, figure,
|
28
|
+
footer, header, hgroup, menu, nav, section {
|
29
|
+
display: block;
|
30
|
+
}
|
31
|
+
body {
|
32
|
+
line-height: 1;
|
33
|
+
}
|
34
|
+
ol, ul {
|
35
|
+
list-style: none;
|
36
|
+
}
|
37
|
+
blockquote, q {
|
38
|
+
quotes: none;
|
39
|
+
}
|
40
|
+
blockquote:before, blockquote:after,
|
41
|
+
q:before, q:after {
|
42
|
+
content: '';
|
43
|
+
content: none;
|
44
|
+
}
|
45
|
+
table {
|
46
|
+
border-collapse: collapse;
|
47
|
+
border-spacing: 0;
|
48
|
+
}
|
@@ -0,0 +1,177 @@
|
|
1
|
+
# encoding : utf-8
|
2
|
+
class <%= namespace_for_class %><%= model_camelize.pluralize %>Controller < BeautifulController
|
3
|
+
# Official Rails version : master/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
|
4
|
+
|
5
|
+
before_filter :load_<%= model %>, :only => [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
def index
|
8
|
+
#@<%= model_pluralize %>
|
9
|
+
|
10
|
+
do_sort_and_paginate(:<%= model %>)
|
11
|
+
|
12
|
+
@q = <%= model_camelize %>.search(
|
13
|
+
params[:q]
|
14
|
+
)
|
15
|
+
|
16
|
+
@<%= model %>_scope = @q.result(
|
17
|
+
:distinct => true
|
18
|
+
).sorting(
|
19
|
+
params[:sorting]
|
20
|
+
)
|
21
|
+
|
22
|
+
@<%= model %>_scope_for_scope = @<%= model %>_scope.dup
|
23
|
+
|
24
|
+
unless params[:scope].blank?
|
25
|
+
@<%= model %>_scope = @<%= model %>_scope.send(params[:scope])
|
26
|
+
end
|
27
|
+
|
28
|
+
@<%= model_pluralize %> = @<%= model %>_scope.paginate(
|
29
|
+
:page => params[:page],
|
30
|
+
:per_page => 20
|
31
|
+
).all
|
32
|
+
|
33
|
+
respond_to do |format|
|
34
|
+
format.html{
|
35
|
+
if request.headers['X-PJAX']
|
36
|
+
render :layout => false
|
37
|
+
else
|
38
|
+
render
|
39
|
+
end
|
40
|
+
}
|
41
|
+
format.json{
|
42
|
+
render :json => @<%= model %>_scope.all
|
43
|
+
}
|
44
|
+
format.csv{
|
45
|
+
require 'csv'
|
46
|
+
csvstr = CSV.generate do |csv|
|
47
|
+
csv << <%= model_camelize %>.attribute_names
|
48
|
+
@<%= model %>_scope.all.each{ |o|
|
49
|
+
csv << <%= model_camelize %>.attribute_names.map{ |a| o[a] }
|
50
|
+
}
|
51
|
+
end
|
52
|
+
render :text => csvstr
|
53
|
+
}
|
54
|
+
format.xml{
|
55
|
+
render :xml => @<%= model %>_scope.all
|
56
|
+
}
|
57
|
+
format.pdf{
|
58
|
+
pdfcontent = PdfReport.new.to_pdf(<%= model_camelize %>,@<%= model %>_scope)
|
59
|
+
send_data pdfcontent
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def show
|
65
|
+
respond_to do |format|
|
66
|
+
format.html{
|
67
|
+
if request.headers['X-PJAX']
|
68
|
+
render :layout => false
|
69
|
+
else
|
70
|
+
render
|
71
|
+
end
|
72
|
+
}
|
73
|
+
format.json { render :json => @<%= model %> }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def new
|
78
|
+
@<%= model %> = <%= model_camelize %>.new
|
79
|
+
|
80
|
+
respond_to do |format|
|
81
|
+
format.html{
|
82
|
+
if request.headers['X-PJAX']
|
83
|
+
render :layout => false
|
84
|
+
else
|
85
|
+
render
|
86
|
+
end
|
87
|
+
}
|
88
|
+
format.json { render :json => @<%= model %> }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def edit
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
def create
|
97
|
+
@<%= model %> = <%= model_camelize %>.create(params[:<%= model %>])
|
98
|
+
|
99
|
+
respond_to do |format|
|
100
|
+
if @<%= model %>.save
|
101
|
+
format.html { redirect_to <%= namespace_for_route %><%= singular_table_name %>_path(@<%= model %>), :notice => t(:create_success, :model => "<%= model %>") }
|
102
|
+
format.json { render :json => @<%= model %>, :status => :created, :location => @<%= model %> }
|
103
|
+
else
|
104
|
+
format.html { render :action => "new" }
|
105
|
+
format.json { render :json => @<%= model %>.errors, :status => :unprocessable_entity }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def update
|
111
|
+
|
112
|
+
respond_to do |format|
|
113
|
+
if @<%= model %>.update_attributes(params[:<%= model %>])
|
114
|
+
format.html { redirect_to <%= namespace_for_route %><%= singular_table_name %>_path(@<%= model %>), :notice => t(:update_success, :model => "<%= model %>") }
|
115
|
+
format.json { head :ok }
|
116
|
+
else
|
117
|
+
format.html { render :action => "edit" }
|
118
|
+
format.json { render :json => @<%= model %>.errors, :status => :unprocessable_entity }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def destroy
|
124
|
+
@<%= model %>.destroy
|
125
|
+
|
126
|
+
respond_to do |format|
|
127
|
+
format.html { redirect_to <%= namespace_for_route %><%= model_pluralize %>_url }
|
128
|
+
format.json { head :ok }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def batch
|
133
|
+
attr_or_method, value = params[:actionprocess].split(".")
|
134
|
+
|
135
|
+
@<%= model_pluralize %> = []
|
136
|
+
|
137
|
+
<%= model_camelize %>.transaction do
|
138
|
+
if params[:checkallelt] == "all" then
|
139
|
+
# Selected with filter and search
|
140
|
+
do_sort_and_paginate(:<%= model %>)
|
141
|
+
|
142
|
+
@<%= model_pluralize %> = <%= model_camelize %>.search(
|
143
|
+
params[:q]
|
144
|
+
).result(
|
145
|
+
:distinct => true
|
146
|
+
)
|
147
|
+
else
|
148
|
+
# Selected elements
|
149
|
+
@<%= model_pluralize %> = <%= model_camelize %>.find(params[:ids].to_a)
|
150
|
+
end
|
151
|
+
|
152
|
+
@<%= model_pluralize %>.each{ |<%= model %>|
|
153
|
+
if not <%= model_camelize %>.columns_hash[attr_or_method].nil? and
|
154
|
+
<%= model_camelize %>.columns_hash[attr_or_method].type == :boolean then
|
155
|
+
<%= model %>.update_attribute(attr_or_method, boolean(value))
|
156
|
+
<%= model %>.save
|
157
|
+
else
|
158
|
+
case attr_or_method
|
159
|
+
# Set here your own batch processing
|
160
|
+
# <%= model %>.save
|
161
|
+
when "destroy" then
|
162
|
+
<%= model %>.destroy
|
163
|
+
end
|
164
|
+
end
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
168
|
+
redirect_to :back
|
169
|
+
end
|
170
|
+
|
171
|
+
private
|
172
|
+
|
173
|
+
def load_<%= model %>
|
174
|
+
@<%= model %> = <%= model_camelize %>.find(params[:id])
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding : utf-8
|
2
|
+
class BeautifulController < ApplicationController
|
3
|
+
|
4
|
+
layout "beautiful_layout"
|
5
|
+
|
6
|
+
def do_sort_and_paginate(model_sym)
|
7
|
+
# Paginate
|
8
|
+
session[:paginate] ||= {}
|
9
|
+
session[:paginate][model_sym] ||= nil
|
10
|
+
params[:page] ||= session[:paginate][model_sym]
|
11
|
+
session[:paginate][model_sym] = params[:page]
|
12
|
+
|
13
|
+
# Sort
|
14
|
+
session[:sorting] ||= {}
|
15
|
+
session[:sorting][model_sym] ||= { :attribute => "id", :sorting => "DESC" }
|
16
|
+
params[:sorting] ||= session[:sorting][model_sym]
|
17
|
+
session[:sorting][model_sym] = params[:sorting]
|
18
|
+
|
19
|
+
# Search and Filter
|
20
|
+
session[:search] ||= {}
|
21
|
+
session[:search][model_sym] = nil if not params[:nosearch].blank?
|
22
|
+
params[:q] ||= session[:search][model_sym]
|
23
|
+
session[:search][model_sym] = params[:q]
|
24
|
+
|
25
|
+
# Scope
|
26
|
+
session[:scope] ||= {}
|
27
|
+
session[:scope][model_sym] ||= nil
|
28
|
+
params[:scope] ||= session[:scope][model_sym]
|
29
|
+
session[:scope][model_sym] = params[:scope]
|
30
|
+
end
|
31
|
+
|
32
|
+
def boolean(string)
|
33
|
+
return true if string == true || string =~ (/(true|t|yes|y|1)$/i)
|
34
|
+
return false if string == false || string.nil? || string =~ (/(false|f|no|n|0)$/i)
|
35
|
+
raise ArgumentError.new("invalid value for Boolean: \"#{string}\"")
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# encoding : utf-8
|
2
|
+
module BeautifulHelper
|
3
|
+
|
4
|
+
def sorting_header(model_name, attribute_name, namespace)
|
5
|
+
attr = nil
|
6
|
+
sort = nil
|
7
|
+
|
8
|
+
if not params[:sorting].blank? then
|
9
|
+
attr = params[:sorting][:attribute]
|
10
|
+
sort = params[:sorting][:sorting]
|
11
|
+
end
|
12
|
+
|
13
|
+
attr = attr.to_s.downcase
|
14
|
+
sortstr = sort.to_s.downcase
|
15
|
+
opposite_sortstr = ""
|
16
|
+
csort = "▪"
|
17
|
+
if attribute_name == attr then
|
18
|
+
if sortstr == "asc" then
|
19
|
+
csort = "▲"
|
20
|
+
opposite_sortstr = "desc"
|
21
|
+
elsif sortstr == "desc" then
|
22
|
+
csort = "▼"
|
23
|
+
opposite_sortstr = "asc"
|
24
|
+
end
|
25
|
+
else
|
26
|
+
opposite_sortstr = "asc"
|
27
|
+
end
|
28
|
+
|
29
|
+
default_caption = attribute_name.capitalize
|
30
|
+
if is_belongs_to_column?(default_caption) then
|
31
|
+
default_caption = get_belongs_to_model(default_caption)
|
32
|
+
end
|
33
|
+
|
34
|
+
caption = t(attribute_name, :default => default_caption)
|
35
|
+
return link_to(
|
36
|
+
"#{csort} #{caption}",
|
37
|
+
eval(namespace + '_' + model_name.pluralize + "_url") + "?" +
|
38
|
+
CGI.unescape({:sorting => {:attribute => attribute_name.downcase,:sorting => opposite_sortstr}}.to_query)
|
39
|
+
).html_safe
|
40
|
+
end
|
41
|
+
|
42
|
+
def ransack_field(model_name, attribute_name, f, caption = nil)
|
43
|
+
ar_model = model_name.classify.constantize
|
44
|
+
|
45
|
+
default_caption = caption
|
46
|
+
if default_caption.blank? then
|
47
|
+
default_caption = attribute_name.capitalize
|
48
|
+
if is_belongs_to_column?(default_caption) then
|
49
|
+
default_caption = get_belongs_to_model(default_caption)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
name_field = attribute_name
|
54
|
+
response = '<div class="ransack-filter-field">'
|
55
|
+
|
56
|
+
response += f.label name_field, t(attribute_name, :default => default_caption)
|
57
|
+
|
58
|
+
type_of_column = ar_model.columns_hash[attribute_name].type unless ar_model.columns_hash[attribute_name].nil?
|
59
|
+
type_of_column ||= :other
|
60
|
+
case type_of_column
|
61
|
+
when :date then
|
62
|
+
# DatePicker
|
63
|
+
response += f.date_select((name_field + "_gteq").to_sym)
|
64
|
+
response += f.date_select((name_field + "_lteq").to_sym)
|
65
|
+
when :datetime then
|
66
|
+
# DateTime Picker
|
67
|
+
response += f.date_select((name_field + "_gteq").to_sym)
|
68
|
+
response += f.date_select((name_field + "_lteq").to_sym)
|
69
|
+
when :boolean then
|
70
|
+
# Specify a default value (false) in rails migration
|
71
|
+
response += f.label name_field + "_eq_true", raw(f.radio_button((name_field + "_eq").to_sym, true)) + h(t(:yes, :default => "Yes"))
|
72
|
+
response += f.label name_field + "_eq_false", raw(f.radio_button((name_field + "_eq").to_sym, false)) + h(t(:no, :default => "No"))
|
73
|
+
response += f.label name_field + "_eq", raw(f.radio_button((name_field + "_eq").to_sym, nil)) + h(t(:all, :default => "All"))
|
74
|
+
when :string then
|
75
|
+
response += f.text_field((name_field + "_cont").to_sym, :class => "filter")
|
76
|
+
when :integer then
|
77
|
+
if is_belongs_to_column?(name_field) then
|
78
|
+
btmodel = get_belongs_to_model(name_field).classify.constantize
|
79
|
+
response += f.collection_select((name_field + "_eq").to_sym, btmodel.all, :id, :caption, { :include_blank => t(:all, :default => "All") })
|
80
|
+
elsif name_field == "id" then
|
81
|
+
response += f.text_field((name_field + "_eq").to_sym, :class => "filter")
|
82
|
+
else
|
83
|
+
response += f.text_field((name_field + "_gteq").to_sym, :class => "#{align_attribute("integer")} filter-min")
|
84
|
+
response += f.text_field((name_field + "_lteq").to_sym, :class => "#{align_attribute("integer")} filter-max")
|
85
|
+
end
|
86
|
+
when :float then
|
87
|
+
response += f.text_field((name_field + "_gteq").to_sym, :class => "#{align_attribute("integer")} filter-min")
|
88
|
+
response += f.text_field((name_field + "_lteq").to_sym, :class => "#{align_attribute("integer")} filter-max")
|
89
|
+
else
|
90
|
+
response += f.text_field((name_field + "_cont").to_sym, :class => "filter")
|
91
|
+
end
|
92
|
+
|
93
|
+
response += "</div>"
|
94
|
+
|
95
|
+
return response.html_safe
|
96
|
+
end
|
97
|
+
|
98
|
+
def align_attribute(attribute_type)
|
99
|
+
return case attribute_type
|
100
|
+
when "string" then
|
101
|
+
"al"
|
102
|
+
when "integer", "float", "numeric" then
|
103
|
+
"ar"
|
104
|
+
when "boolean" then
|
105
|
+
"ac"
|
106
|
+
when "date", "datetime", "timestamp" then
|
107
|
+
"ac"
|
108
|
+
else
|
109
|
+
"al"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def exclude_richtext_field(array_of_attributes, only_fulltext = true)
|
114
|
+
pattern = /$()_fulltext/
|
115
|
+
richtext_attributes = []
|
116
|
+
array_of_attributes.each{ |a|
|
117
|
+
richtext_attributes << a[pattern] if a[pattern]
|
118
|
+
}
|
119
|
+
array_of_attributes.reject!{ |a| richtext_attributes.include?(a) or richtext_attributes.include?(a + "_typetext") }
|
120
|
+
return array_of_attributes
|
121
|
+
end
|
122
|
+
|
123
|
+
def is_belongs_to_column?(column)
|
124
|
+
return true if column[-3,3] == "_id"
|
125
|
+
end
|
126
|
+
|
127
|
+
def get_belongs_to_model(column)
|
128
|
+
return column[0..-4]
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
en:
|
3
|
+
edit: "Edit"
|
4
|
+
editing: "Editing"
|
5
|
+
update: "Update"
|
6
|
+
show: "Show"
|
7
|
+
showing: "Showing"
|
8
|
+
delete: "Delete"
|
9
|
+
destroy: "Destroy"
|
10
|
+
are_you_sure: "Are you sure ?"
|
11
|
+
new: "New"
|
12
|
+
create: "Create"
|
13
|
+
listing: "Listing"
|
14
|
+
filter: "Filter"
|
15
|
+
cancel: "Cancel"
|
16
|
+
export: "Export"
|
17
|
+
search: "Search"
|
18
|
+
sort: "Sort"
|
19
|
+
download: "Download"
|
20
|
+
yes: "Yes"
|
21
|
+
no: "No"
|
22
|
+
all: "All"
|
23
|
+
back: "Back"
|
24
|
+
manage: "Manage"
|
25
|
+
settrueforattr: "Set %{attr} as true"
|
26
|
+
setfalseforattr: "Set %{attr} as false"
|
27
|
+
processing: "Processing"
|
28
|
+
batch: "Batch"
|
29
|
+
create_success: "%{model} was successfully created."
|
30
|
+
update_success: "%{model} was successfully updated."
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
fr:
|
3
|
+
edit: "Editer"
|
4
|
+
editing: "Edition"
|
5
|
+
update: "Mise à jour"
|
6
|
+
show: "Afficher"
|
7
|
+
showing: "Affichage"
|
8
|
+
delete: "Supprimer"
|
9
|
+
destroy: "Détruire"
|
10
|
+
are_you_sure: "Etes-vous sûr ?"
|
11
|
+
new: "Nouveau"
|
12
|
+
create: "Créer"
|
13
|
+
listing: "Liste"
|
14
|
+
filter: "Filtrer"
|
15
|
+
cancel: "Annuler"
|
16
|
+
export: "Exporter"
|
17
|
+
search: "Rechercher"
|
18
|
+
sort: "Trier"
|
19
|
+
download: "Télécharger"
|
20
|
+
yes: "Oui"
|
21
|
+
no: "Non"
|
22
|
+
all: "Tout"
|
23
|
+
back: "Retour"
|
24
|
+
manage: "Administrer"
|
25
|
+
settrueforattr: "Mettre %{attr} à vrai"
|
26
|
+
setfalseforattr: "Mettre %{attr} à faux"
|
27
|
+
processing: "Effectuer"
|
28
|
+
batch: "Traitement par lot"
|
29
|
+
create_success: "%{model} a été créé(e) avec succès."
|
30
|
+
update_success: "%{model} a été mis(e) à jour avec succès."
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding : utf-8
|
2
|
+
class PdfReport < Prawn::Document
|
3
|
+
def to_pdf(model, mode_scope)
|
4
|
+
|
5
|
+
columns = model.attribute_names
|
6
|
+
|
7
|
+
data = [columns]
|
8
|
+
|
9
|
+
mode_scope.each{ |modelobj|
|
10
|
+
data << (columns.map{ |c| modelobj[c].to_s }).to_a
|
11
|
+
}
|
12
|
+
|
13
|
+
table data, :header => true, :cell_style => { :padding => 5 } do
|
14
|
+
i = 0
|
15
|
+
for col in columns
|
16
|
+
align = case model.columns_hash[col].type
|
17
|
+
when "integer" then
|
18
|
+
'right'
|
19
|
+
when "string", "text" then
|
20
|
+
'left'
|
21
|
+
else
|
22
|
+
'center'
|
23
|
+
end
|
24
|
+
style(columns(i)){ |c| c.align = align.to_sym }
|
25
|
+
i += 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Paginate
|
30
|
+
font_size 10
|
31
|
+
number_pages Time.now.strftime('%d/%m/%Y - %H:%M') + ' - <page>/<total>', :at => [0, -5], :align => :center
|
32
|
+
repeat(:all) do
|
33
|
+
bounding_box([0,0], :width => 540, :height => 2) do
|
34
|
+
stroke_horizontal_rule
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
render
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<p class="menuelt" data-id="sub-dashboard"><%%= t(:dashboard, :default => "DashBoard") %></p>
|
2
|
+
<!--
|
3
|
+
<ul class="submenu" id="sub-dashboard">
|
4
|
+
<li><%%= link_to "Home", "/" %></li>
|
5
|
+
<li><%%= link_to "Bla1", "" %></li>
|
6
|
+
<li><%%= link_to "Bla1", "" %></li>
|
7
|
+
</ul>
|
8
|
+
-->
|
9
|
+
<!-- Beautiful Scaffold Menu Do Not Touch This -->
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%-
|
2
|
+
strformfor = singular_table_name
|
3
|
+
if not namespace_alone.blank? then
|
4
|
+
strformfor = "[:#{namespace_alone}, @#{singular_table_name} ]"
|
5
|
+
end
|
6
|
+
-%>
|
7
|
+
|
8
|
+
<%%= form_for(<%= strformfor %>) do |f| %>
|
9
|
+
<%% if @<%= singular_table_name %>.errors.any? %>
|
10
|
+
<div id="error_explanation">
|
11
|
+
<h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
12
|
+
|
13
|
+
<ul>
|
14
|
+
<%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %><li><%%= msg %></li><%% end %>
|
15
|
+
</ul>
|
16
|
+
</div>
|
17
|
+
<%% end %>
|
18
|
+
<%= render_partial 'app/views/partials/_form_field.html.erb' %><!-- Beautiful_scaffold - AddField - Do not remove -->
|
19
|
+
<div class="actions">
|
20
|
+
<%%= f.submit %>
|
21
|
+
</div>
|
22
|
+
<%% end %>
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<div class="box content-box">
|
2
|
+
<div class="box-title"><%%= t(:editing, :default => 'Editing') %><%= singular_table_name %></div>
|
3
|
+
<%%= render 'form' %>
|
4
|
+
<%%= link_to t(:edit, :default => "Edit"), edit_<%= namespace_for_route %><%= singular_table_name %>_path(@<%= singular_table_name %>), :class => "btn" %>
|
5
|
+
<%%= link_to t(:back, :default => "Back"), <%= namespace_for_route %><%= plural_table_name %>_path, :class => "btn" %>
|
6
|
+
</div>
|
@@ -0,0 +1,86 @@
|
|
1
|
+
<div class="box content-box">
|
2
|
+
<div class="box-title"><%%= t(:listing, :default => "Listing") %> <%= plural_table_name %></div>
|
3
|
+
|
4
|
+
<%%= link_to t(:new, :default => "New") + ' <%= model %>', new_<%= namespace_for_route %><%= singular_table_name %>_path, :class => "btn box-margintl" %>
|
5
|
+
|
6
|
+
<div id="table-items-and-filter">
|
7
|
+
<%%= form_tag batch_<%= namespace_for_route %><%= plural_table_name %>_path, :class => "table-items" do %>
|
8
|
+
<div class="group-processing">
|
9
|
+
<p id="batch_label"><%%= t(:batch, :default => "Batch") %> : </p>
|
10
|
+
<select name="actionprocess">
|
11
|
+
<option value="destroy"><%%= t(:destroy, :default => "Destroy") %></option>
|
12
|
+
<%= render_partial 'app/views/partials/_index_batch.html.erb' %>
|
13
|
+
<!-- Beautiful_scaffold - AddField - Batch - Do not remove -->
|
14
|
+
</select>
|
15
|
+
<input type="submit" value="<%%= t(:processing, :default => "Processing") %>" />
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<%%# Set your scopes below (string in array) %>
|
19
|
+
<%% scopes = [] %>
|
20
|
+
<%% if not scopes.blank? then %>
|
21
|
+
<%%= link_to "All (#{@<%= model %>_scope_for_scope.count})", <%= namespace_for_route %><%= plural_table_name %>_path(:scope => ""), :class => "btn#{((session[:scope][:<%= model %>].to_s == '') ? 'selected' : '')}" %>
|
22
|
+
<%% for scope in scopes %>
|
23
|
+
<%%= link_to "#{scope} (#{@<%= model %>_scope_for_scope.send(scope).count})", <%= namespace_for_route %><%= plural_table_name %>_path(:scope => scope), :class => "btn#{((session[:scope][:<%= model %>].to_s == scope) ? 'selected' : '')}" %>
|
24
|
+
<%% end %>
|
25
|
+
<%% end %>
|
26
|
+
|
27
|
+
<div class="index_table">
|
28
|
+
<table>
|
29
|
+
<tr>
|
30
|
+
<th>
|
31
|
+
<%%= check_box_tag :checkall, '' %>
|
32
|
+
<script type="text/javascript">
|
33
|
+
$('#checkall').click(function(){
|
34
|
+
$('.cbbatch').attr('checked', ($(this).attr('checked') != undefined));
|
35
|
+
});
|
36
|
+
</script>
|
37
|
+
</th>
|
38
|
+
<%= render_partial 'app/views/partials/_index_header.html.erb' %>
|
39
|
+
<!-- Beautiful_scaffold - AddField - Header - Do not remove -->
|
40
|
+
<th colspan="3">
|
41
|
+
<label class="allitems">
|
42
|
+
<%%= check_box_tag :checkallelt, 'all' %>
|
43
|
+
<%%= pluralize(@<%= singular_table_name %>_scope.count, "<%= singular_table_name %>") %>
|
44
|
+
</label>
|
45
|
+
</th>
|
46
|
+
</tr>
|
47
|
+
|
48
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
49
|
+
<tr class="line-<%%= cycle("1","2") %>">
|
50
|
+
<td><%%= check_box_tag "ids[]",<%= singular_table_name %>.id, false, :class => 'cbbatch' %></td>
|
51
|
+
<%= render_partial 'app/views/partials/_index_column.html.erb' %><!-- Beautiful_scaffold - AddField - Column - Do not remove -->
|
52
|
+
<td><%%= link_to t(:show, :default => "Show"), <%= namespace_for_route %><%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
|
53
|
+
<td><%%= link_to t(:edit, :default => "Edit"), edit_<%= namespace_for_route %><%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
|
54
|
+
<td><%%= link_to t(:destroy, :default => "Destroy"), <%= namespace_for_route %><%= singular_table_name %>_path(<%= singular_table_name %>), :confirm => t(:areyousure, :default => "Are you sure?"), :method => :delete %></td>
|
55
|
+
</tr>
|
56
|
+
<%% end %>
|
57
|
+
</table>
|
58
|
+
|
59
|
+
<div class="beautiful_pagination">
|
60
|
+
<%%= will_paginate @<%= plural_table_name %>,
|
61
|
+
:inner_window => 0,
|
62
|
+
:outer_window => 0,
|
63
|
+
:previous_label => t(:prev, :default => "Previous"),
|
64
|
+
:next_label => t(:next, :default => "Next") %>
|
65
|
+
<div id="export">
|
66
|
+
<p>
|
67
|
+
<span id="export_label"><%%= t(:download, :default => "Download") %></span>
|
68
|
+
<%%= link_to "CSV", <%= namespace_for_route %><%= plural_table_name %>_path(:format => :csv), :class => "nopjax" %>
|
69
|
+
<%%= link_to "XML", <%= namespace_for_route %><%= plural_table_name %>_path(:format => :xml), :class => "nopjax" %>
|
70
|
+
<%%= link_to "JSON", <%= namespace_for_route %><%= plural_table_name %>_path(:format => :json), :class => "nopjax" %>
|
71
|
+
<%%= link_to "PDF", <%= namespace_for_route %><%= plural_table_name %>_path(:format => :pdf), :class => "nopjax" %>
|
72
|
+
</p>
|
73
|
+
</div>
|
74
|
+
</div>
|
75
|
+
</div>
|
76
|
+
<%% end %>
|
77
|
+
<div class="index_filter" id="index_filter_<%= singular_table_name %>">
|
78
|
+
<%%= search_form_for @q, :url => { :controller => "<%= namespace_for_url %><%= model_pluralize %>" } do |f| %>
|
79
|
+
<%= render_partial 'app/views/partials/_index_search.html.erb' %>
|
80
|
+
<!-- Beautiful_scaffold - AddField - Search - Do not remove -->
|
81
|
+
<%%= f.submit t(:filter, :default => "Filter") %>
|
82
|
+
<%%= link_to t(:cancel, :default => "Cancel"), <%= namespace_for_route %><%= model_pluralize %>_path(:nosearch => "ok"), :class => "btn" %>
|
83
|
+
<%% end %>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
</div>
|