carnival 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/{images/carnival/fonts → fonts/carnival}/opensans-regular-webfont.eot +0 -0
- data/app/assets/{images/carnival/fonts → fonts/carnival}/opensans-regular-webfont.svg +0 -0
- data/app/assets/{images/carnival/fonts → fonts/carnival}/opensans-regular-webfont.ttf +0 -0
- data/app/assets/{images/carnival/fonts → fonts/carnival}/opensans-regular-webfont.woff +0 -0
- data/app/assets/{images/carnival/fonts → fonts/carnival}/opensans-semibold-webfont.eot +0 -0
- data/app/assets/{images/carnival/fonts → fonts/carnival}/opensans-semibold-webfont.svg +0 -0
- data/app/assets/{images/carnival/fonts → fonts/carnival}/opensans-semibold-webfont.ttf +0 -0
- data/app/assets/{images/carnival/fonts → fonts/carnival}/opensans-semibold-webfont.woff +0 -0
- data/app/assets/{images/carnival/fonts → fonts/carnival}/up-not.png +0 -0
- data/app/assets/javascripts/carnival/{vizir_admin.js → vizir_admin.js.erb} +44 -18
- data/app/assets/stylesheets/carnival/actions.css.scss +3 -7
- data/app/assets/stylesheets/carnival/carnival-table.css.scss +12 -3
- data/app/assets/stylesheets/carnival/forms.css.scss +1 -0
- data/app/assets/stylesheets/carnival/menu.css.scss +3 -3
- data/app/assets/stylesheets/carnival/period.css.scss +1 -1
- data/app/assets/stylesheets/carnival/search.css.scss +9 -6
- data/app/assets/stylesheets/carnival/structure.css.scss +10 -10
- data/app/controllers/carnival/base_admin_controller.rb +37 -57
- data/app/helpers/carnival/base_admin_helper.rb +52 -70
- data/app/inputs/admin_date_input.rb +2 -1
- data/app/models/carnival/batch_action.rb +1 -2
- data/app/models/carnival/field.rb +3 -2
- data/app/presenters/carnival/base_admin_presenter.rb +47 -192
- data/app/presenters/carnival/dsl.rb +55 -0
- data/app/services/carnival/klass_service.rb +5 -1
- data/app/services/carnival/presenters/advanced_search_parser.rb +4 -5
- data/app/services/carnival/query_service.rb +15 -24
- data/app/view_objects/carnival/paginator.rb +10 -12
- data/app/view_objects/carnival/thead_renderer.rb +11 -18
- data/app/views/carnival/base_admin/_index_as_table.html.haml +6 -4
- data/app/views/carnival/base_admin/index.html.haml +8 -4
- data/app/views/carnival/shared/_advanced_search.html.haml +6 -5
- data/app/views/carnival/shared/form/_form.html.haml +3 -2
- data/config/locales/carnival.en.yml +13 -5
- data/config/locales/carnival.pt-br.yml +1 -1
- data/lib/carnival.rb +10 -12
- data/lib/carnival/engine.rb +3 -2
- data/lib/carnival/routes.rb +4 -4
- data/lib/carnival/version.rb +1 -1
- data/spec/dummy/app/controllers/admin/todo_lists_controller.rb +7 -0
- data/spec/dummy/app/controllers/admin/todos_controller.rb +7 -0
- data/spec/dummy/app/models/todo.rb +7 -0
- data/spec/dummy/app/models/todo_list.rb +4 -0
- data/spec/dummy/app/presenters/admin/todo_list_presenter.rb +13 -0
- data/spec/dummy/app/presenters/admin/todo_presenter.rb +32 -0
- data/spec/dummy/config/application.rb +3 -0
- data/spec/dummy/config/database.yml +1 -1
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/initializers/carnival_initializer.rb +25 -0
- data/spec/dummy/config/locales/carnival.en.yml +28 -0
- data/spec/dummy/config/locales/carnival.pt-br.yml +259 -0
- data/spec/dummy/config/routes.rb +7 -52
- data/spec/dummy/db/migrate/20150316021645_create_todos.rb +10 -0
- data/spec/dummy/db/migrate/20150408165317_create_todo_lists.rb +8 -0
- data/spec/dummy/db/migrate/20150408165333_add_todo_list_relation_to_todos.rb +5 -0
- data/spec/dummy/db/schema.rb +32 -0
- data/spec/factories/todo_lists_factory.rb +5 -0
- data/spec/factories/todos_factory.rb +18 -0
- data/spec/features/create_spec.rb +28 -0
- data/spec/features/destroy_spec.rb +11 -0
- data/spec/features/index/basic_index_spec.rb +14 -0
- data/spec/features/index/pagination_spec.rb +19 -0
- data/spec/features/index/scope_spec.rb +29 -0
- data/spec/features/index/search_spec.rb +28 -0
- data/spec/features/show_spec.rb +15 -0
- data/spec/features/update_spec.rb +26 -0
- data/spec/rails_helper.rb +25 -5
- data/spec/support/features/index_helpers.rb +15 -0
- metadata +386 -284
- checksums.yaml +0 -7
- data/app/views/carnival/base_admin/index.pdf.haml +0 -13
- data/app/views/carnival/shared/_header.pdf.haml +0 -13
- data/app/views/carnival/shared/_list_cel.pdf.haml +0 -9
- data/app/views/carnival/shared/_report.pdf.haml +0 -21
- data/config/initializers/wicked_pdf.rb +0 -5
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,5 +1,10 @@
|
|
1
1
|
// add/remove dynamic fields
|
2
|
-
var Carnival = {
|
2
|
+
var Carnival = {
|
3
|
+
config: {
|
4
|
+
dateFormat: "<%= I18n.t('date.formats.default').gsub('%', '') %>"
|
5
|
+
}
|
6
|
+
};
|
7
|
+
|
3
8
|
String.prototype.unescapeHtml = function () {
|
4
9
|
var temp = document.createElement("div");
|
5
10
|
temp.innerHTML = this;
|
@@ -185,34 +190,55 @@ var pageLoad = function(){
|
|
185
190
|
});
|
186
191
|
|
187
192
|
var $lefty = $('div.menu.full');
|
188
|
-
$lefty.
|
189
|
-
marginLeft: '-20%'
|
190
|
-
}, 100);
|
193
|
+
$lefty.hide();
|
191
194
|
|
192
195
|
$('.minify').on("click", function(){
|
193
196
|
var $lefty = $('div.menu.full');
|
194
|
-
$lefty.
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
197
|
+
var shouldHideExpandedMenu = (parseInt($lefty.css('margin-left'),10) == 0);
|
198
|
+
|
199
|
+
if(shouldHideExpandedMenu){
|
200
|
+
$lefty.animate({
|
201
|
+
marginLeft: (-$lefty.outerWidth() - 2)
|
202
|
+
}, 100);
|
203
|
+
setTimeout("$('div.menu.full').hide()", 100);
|
204
|
+
}
|
205
|
+
else{
|
206
|
+
$lefty.show();
|
207
|
+
$lefty.animate({
|
208
|
+
marginLeft: 0
|
209
|
+
}, 100);
|
210
|
+
}
|
211
|
+
setTimeout("$('div.menu.short').fadeToggle(100)", 0);
|
212
|
+
setTimeout("$('#content').toggleClass('menu-opened')", 0);
|
213
|
+
});
|
202
214
|
};
|
203
215
|
|
204
216
|
// form load functions
|
205
217
|
|
206
218
|
function setupDateFields(){
|
219
|
+
var dateFormat = Carnival.config.dateFormat;
|
207
220
|
var dateOptions = {
|
208
|
-
|
209
|
-
|
210
|
-
|
221
|
+
format: dateFormat,
|
222
|
+
scrollInput: false,
|
223
|
+
mask: true,
|
224
|
+
timepicker: false
|
211
225
|
};
|
212
|
-
var dateTimeOptions = $.extend({}, dateOptions, { timepicker: true, format: 'Y/m/d H:i'})
|
213
226
|
|
214
|
-
|
215
|
-
|
227
|
+
var dateTimeOptions = $.extend({}, dateOptions, { timepicker: true, mask: true, format: dateFormat + ' H:i'} );
|
228
|
+
|
229
|
+
function addPicker(elem, options){
|
230
|
+
var value = $(elem).val();
|
231
|
+
$(elem).datetimepicker(options);
|
232
|
+
if(value)
|
233
|
+
$(elem).val(value);
|
234
|
+
}
|
235
|
+
|
236
|
+
$(".datepicker").each(function(){
|
237
|
+
addPicker(this, dateOptions);
|
238
|
+
});
|
239
|
+
$(".datetimepicker").each(function(){
|
240
|
+
addPicker(this, dateTimeOptions);
|
241
|
+
});
|
216
242
|
}
|
217
243
|
|
218
244
|
var formLoad = function(){
|
@@ -112,12 +112,12 @@
|
|
112
112
|
color:#fff;
|
113
113
|
}
|
114
114
|
|
115
|
-
.
|
115
|
+
.csv{
|
116
116
|
padding: 0px 10px 0px 25px;
|
117
117
|
position: relative;
|
118
118
|
}
|
119
119
|
|
120
|
-
.
|
120
|
+
.csv:before{
|
121
121
|
content: '';
|
122
122
|
display: block;
|
123
123
|
width: 25px;
|
@@ -129,10 +129,6 @@
|
|
129
129
|
top: 6px;
|
130
130
|
}
|
131
131
|
|
132
|
-
.pdf:before{
|
133
|
-
background-position: -279px -502px;
|
134
|
-
}
|
135
|
-
|
136
132
|
.csv:before{
|
137
133
|
background-position: -101px -50px;
|
138
134
|
}
|
@@ -153,7 +149,7 @@
|
|
153
149
|
float: right;
|
154
150
|
margin-left: 10px;
|
155
151
|
font-size: 14px;
|
156
|
-
line-height: 25px;
|
152
|
+
line-height: 25px;
|
157
153
|
cursor: pointer;
|
158
154
|
}
|
159
155
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/********************* TABLE BASE
|
1
|
+
/********************* TABLE BASE STYLE ********************* START */
|
2
2
|
|
3
3
|
.carnival-table{
|
4
4
|
border-collapse: collapse;
|
@@ -86,7 +86,16 @@
|
|
86
86
|
|
87
87
|
}
|
88
88
|
|
89
|
-
/*********************** TABLE BASE
|
89
|
+
/*********************** TABLE BASE STYLE ********************* END */
|
90
|
+
|
91
|
+
/*********************** TABLE BATCHING ********************** START */
|
92
|
+
|
93
|
+
.batching {
|
94
|
+
padding-left: 10px !important;
|
95
|
+
width: 36px;
|
96
|
+
}
|
97
|
+
|
98
|
+
/*********************** TABLE BATCHING ********************* END */
|
90
99
|
|
91
100
|
/*********************** TABLE SORTABLES ********************** START */
|
92
101
|
|
@@ -101,4 +110,4 @@
|
|
101
110
|
#sortable > li > a {float: right; padding-right: 10px;}
|
102
111
|
#sortable > .ui-state-default {border: 0px; border-bottom: 1px solid lightGrey; background: transparent;}
|
103
112
|
|
104
|
-
/*********************** TABLE SORTABLES ********************** END */
|
113
|
+
/*********************** TABLE SORTABLES ********************** END */
|
@@ -97,6 +97,9 @@ display: block;
|
|
97
97
|
text-indent: -99999px !important;
|
98
98
|
}
|
99
99
|
|
100
|
+
ul.menu li.minify{
|
101
|
+
cursor: pointer;
|
102
|
+
}
|
100
103
|
|
101
104
|
ul.menu a.actived{
|
102
105
|
color: #0088CC !important;
|
@@ -329,6 +332,3 @@ ul.menu .dropdown_main_menu_sublevel li a{
|
|
329
332
|
background-repeat:no-repeat;
|
330
333
|
}
|
331
334
|
|
332
|
-
a.btn_usuario.sublevel.link{
|
333
|
-
display: none !important;
|
334
|
-
}
|
@@ -16,7 +16,6 @@
|
|
16
16
|
height: 25px;
|
17
17
|
background: url(image_path('carnival/sprites.png')) -375px 547px;
|
18
18
|
left: 0px;
|
19
|
-
top: 0px;
|
20
19
|
background-size: 400px;
|
21
20
|
}
|
22
21
|
|
@@ -46,7 +45,7 @@
|
|
46
45
|
display: none;
|
47
46
|
border: 1px solid #ccc;
|
48
47
|
padding: 20px;
|
49
|
-
margin-top:
|
48
|
+
margin-top: 87px;
|
50
49
|
float: left;
|
51
50
|
width: 270px;
|
52
51
|
box-sizing: border-box;
|
@@ -83,15 +82,15 @@
|
|
83
82
|
}
|
84
83
|
|
85
84
|
.advanced-search-tags.explode1:hover{
|
86
|
-
height: 61px;
|
85
|
+
height: 61px;
|
87
86
|
}
|
88
87
|
|
89
88
|
.advanced-search-tags.explode2:hover{
|
90
|
-
height: 122px;
|
89
|
+
height: 122px;
|
91
90
|
}
|
92
91
|
|
93
92
|
.advanced-search-tags.explode3:hover{
|
94
|
-
height: 183px;
|
93
|
+
height: 183px;
|
95
94
|
}
|
96
95
|
.advanced-search-tag{
|
97
96
|
font-size: 13px;
|
@@ -107,6 +106,10 @@
|
|
107
106
|
transition: all 0.3s ease;
|
108
107
|
}
|
109
108
|
|
109
|
+
.advanced-search-tag span{
|
110
|
+
float: left;
|
111
|
+
}
|
112
|
+
|
110
113
|
.advanced-search-tag a{
|
111
114
|
color: #555;
|
112
115
|
position: relative;
|
@@ -128,7 +131,7 @@
|
|
128
131
|
height: 15px;
|
129
132
|
width: 15px;
|
130
133
|
line-height: 15px;
|
131
|
-
top:
|
134
|
+
top: 6px;
|
132
135
|
color: #222;
|
133
136
|
border-radius: 100px;
|
134
137
|
text-align: center;
|
@@ -2,22 +2,22 @@
|
|
2
2
|
|
3
3
|
@font-face {
|
4
4
|
font-family: 'OpenSansRegular';
|
5
|
-
src: url(
|
6
|
-
src: url(
|
7
|
-
url(
|
8
|
-
url(
|
9
|
-
url(
|
5
|
+
src: url(font-path('carnival/opensans-regular-webfont.eot'));
|
6
|
+
src: url(font-path('carnival/opensans-regular-webfont.eot?#iefix')) format('embedded-opentype'),
|
7
|
+
url(font-path('carnival/opensans-regular-webfont.woff')) format('woff'),
|
8
|
+
url(font-path('carnival/opensans-regular-webfont.ttf')) format('truetype'),
|
9
|
+
url(font-path('carnival/opensans-regular-webfont.svg#OpenSansRegular')) format('svg');
|
10
10
|
font-weight: normal;
|
11
11
|
font-style: normal;
|
12
12
|
}
|
13
13
|
|
14
14
|
@font-face {
|
15
15
|
font-family: 'OpenSansSemibold';
|
16
|
-
src: url(
|
17
|
-
src: url(
|
18
|
-
url(
|
19
|
-
url(
|
20
|
-
url(
|
16
|
+
src: url(font-path('carnival/opensans-semibold-webfont.eot'));
|
17
|
+
src: url(font-path('carnival/opensans-semibold-webfont.eot?#iefix')) format('embedded-opentype'),
|
18
|
+
url(font-path('carnival/opensans-semibold-webfont.woff')) format('woff'),
|
19
|
+
url(font-path('carnival/opensans-semibold-webfont.ttf')) format('truetype'),
|
20
|
+
url(font-path('carnival/opensans-semibold-webfont.svg#OpenSansSemibold')) format('svg');
|
21
21
|
font-weight: normal;
|
22
22
|
font-style: normal;
|
23
23
|
}
|
@@ -1,88 +1,59 @@
|
|
1
1
|
module Carnival
|
2
2
|
class BaseAdminController < InheritedResources::Base
|
3
3
|
respond_to :html, :json
|
4
|
-
layout
|
4
|
+
layout 'carnival/admin'
|
5
5
|
before_action :instantiate_presenter
|
6
6
|
helper_method :back_or_model_path
|
7
7
|
|
8
|
-
def home
|
9
|
-
end
|
10
|
-
|
11
|
-
def table_items
|
12
|
-
nil
|
13
|
-
end
|
14
|
-
|
15
|
-
def render_inner_form
|
16
|
-
@presenter = presenter_name(params[:field]).new controller: self
|
17
|
-
model_class = params[:field].classify.constantize
|
18
|
-
@model_object = model_class.find(params[:id])
|
19
|
-
end
|
20
|
-
|
21
|
-
def presenter_name field
|
22
|
-
field_name = field.split('/').last
|
23
|
-
carnival_mount = Carnival::Config.mount_at
|
24
|
-
"#{carnival_mount}/#{field_name.singularize}_presenter".classify.constantize
|
25
|
-
end
|
26
|
-
|
27
8
|
def index
|
28
|
-
@query_form =
|
9
|
+
@query_form = QueryFormCreator.create(@presenter, params)
|
29
10
|
@model = @presenter.model_class
|
30
|
-
@query_service =
|
11
|
+
@query_service = QueryService.new(table_items, @presenter, @query_form)
|
12
|
+
@thead_renderer = TheadRenderer.new @presenter.fields_for_action(:index), @query_form.sort_column, @query_form.sort_direction
|
31
13
|
|
32
14
|
respond_to do |format|
|
33
15
|
format.html do
|
34
16
|
@records = @query_service.get_query
|
35
|
-
|
36
|
-
@paginator = Carnival::Paginator.new @query_form.page, last_page
|
37
|
-
@thead_renderer = Carnival::TheadRenderer.new @presenter.fields_for_action(:index), @query_form.sort_column, @query_form.sort_direction
|
17
|
+
@paginator = Paginator.new @query_form.page, @query_service.page_count
|
38
18
|
end
|
39
19
|
format.csv do
|
40
20
|
@records = @query_service.records_without_pagination
|
41
|
-
render :
|
42
|
-
end
|
43
|
-
format.pdf do
|
44
|
-
@records = @query_service.records_without_pagination
|
45
|
-
@thead_renderer = Carnival::TheadRenderer.new @presenter.fields_for_action(:index), @query_form.sort_column, @query_form.sort_direction
|
46
|
-
render :pdf => t("activerecord.attributes.#{@presenter.full_model_name}.pdf_name") , :template => 'carnival/base_admin/index.pdf.haml', :show_as_html => params[:debug].present?
|
21
|
+
render csv: @model.model_name.human
|
47
22
|
end
|
48
23
|
end
|
49
24
|
end
|
50
25
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
def new
|
58
|
-
new! do
|
59
|
-
instantiate_model
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def edit
|
64
|
-
edit! do
|
65
|
-
instantiate_model
|
26
|
+
[:show, :new, :edit].each do |action|
|
27
|
+
define_method action do
|
28
|
+
send("#{action}!") do
|
29
|
+
instantiate_model
|
30
|
+
end
|
66
31
|
end
|
67
32
|
end
|
68
33
|
|
69
34
|
def create
|
70
35
|
create! do |success, failure|
|
71
|
-
success.html { redirect_to back_or_model_path, :
|
72
|
-
failure.html { instantiate_model
|
36
|
+
success.html { redirect_to back_or_model_path, notice: I18n.t('messages.created') }
|
37
|
+
failure.html { instantiate_model && render('new') }
|
73
38
|
end
|
74
39
|
end
|
75
40
|
|
76
41
|
def update
|
77
42
|
update! do |success, failure|
|
78
|
-
success.html { redirect_to back_or_model_path, :
|
79
|
-
failure.html { instantiate_model
|
43
|
+
success.html { redirect_to back_or_model_path, notice: I18n.t('messages.updated') }
|
44
|
+
failure.html { instantiate_model && render('edit') }
|
80
45
|
end
|
81
46
|
end
|
82
47
|
|
48
|
+
def render_inner_form
|
49
|
+
@presenter = presenter_name(params[:field]).new controller: self
|
50
|
+
model_class = params[:field].classify.constantize
|
51
|
+
@model_object = model_class.find(params[:id])
|
52
|
+
end
|
53
|
+
|
83
54
|
def load_dependent_select_options
|
84
|
-
presenter = params[:presenter].constantize.send(:new, :
|
85
|
-
model = presenter.relation_model(params[:field].gsub(
|
55
|
+
presenter = params[:presenter].constantize.send(:new, controller: self)
|
56
|
+
model = presenter.relation_model(params[:field].gsub('_id', '').to_sym)
|
86
57
|
@options = model.list_for_select(add_empty_option: true, query: ["#{params[:dependency_field]} = ?", params[:dependency_value]])
|
87
58
|
render layout: nil
|
88
59
|
end
|
@@ -90,18 +61,28 @@ module Carnival
|
|
90
61
|
def load_select_options
|
91
62
|
model_name = params[:model_name]
|
92
63
|
search_field = params[:search_field]
|
93
|
-
presenter = params[:presenter_name].constantize.send(:new, :
|
64
|
+
presenter = params[:presenter_name].constantize.send(:new, controller: self)
|
94
65
|
model = presenter.relation_model(model_name.to_sym)
|
95
66
|
list = []
|
96
67
|
model.where("#{search_field} like '%#{params[:q]}%'").each do |elem|
|
97
|
-
list << {id: elem.id, text: elem.send(search_field.to_sym)}
|
68
|
+
list << { id: elem.id, text: elem.send(search_field.to_sym) }
|
98
69
|
end
|
99
70
|
|
100
|
-
render :
|
71
|
+
render json: list
|
101
72
|
end
|
102
73
|
|
103
74
|
protected
|
104
75
|
|
76
|
+
def presenter_name(field)
|
77
|
+
field_name = field.split('/').last
|
78
|
+
carnival_mount = Carnival::Config.mount_at
|
79
|
+
"#{carnival_mount}/#{field_name.singularize}_presenter".classify.constantize
|
80
|
+
end
|
81
|
+
|
82
|
+
def table_items
|
83
|
+
@presenter.model_class
|
84
|
+
end
|
85
|
+
|
105
86
|
def instantiate_model
|
106
87
|
@model = instance_variable_get("@#{resource_instance_name}")
|
107
88
|
end
|
@@ -120,7 +101,7 @@ module Carnival
|
|
120
101
|
end
|
121
102
|
|
122
103
|
def extract_namespace
|
123
|
-
module_class_split = self.class.to_s.split(
|
104
|
+
module_class_split = self.class.to_s.split('::')
|
124
105
|
if module_class_split.size > 1
|
125
106
|
module_class_split[0]
|
126
107
|
else
|
@@ -131,6 +112,5 @@ module Carnival
|
|
131
112
|
def back_or_model_path
|
132
113
|
params[:HTTP_REFERER] || @presenter.model_path(:index)
|
133
114
|
end
|
134
|
-
|
135
115
|
end
|
136
116
|
end
|