caboose-cms 0.9.133 → 0.9.134
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/caboose/admin_block_edit.js +1 -1
- data/app/assets/javascripts/caboose/block_content_controller.js +11 -3
- data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +126 -6
- data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +5 -5
- data/app/assets/javascripts/caboose/block_modal_controllers/block_modal_controller.js +9 -4
- data/app/assets/javascripts/caboose/model/attribute.js +1 -1
- data/app/assets/javascripts/caboose/model/model_binder.js +3 -1
- data/app/assets/stylesheets/caboose/admin_edit_page_content.scss +69 -14
- data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +101 -11
- data/app/controllers/caboose/application_controller.rb +1 -1
- data/app/controllers/caboose/blocks_controller.rb +209 -74
- data/app/controllers/caboose/pages_controller.rb +34 -0
- data/app/controllers/caboose/posts_controller.rb +27 -0
- data/app/models/caboose/block.rb +134 -30
- data/app/models/caboose/page.rb +42 -1
- data/app/models/caboose/post.rb +42 -1
- data/app/models/caboose/schema.rb +10 -3
- data/app/views/caboose/admin/index.html.erb +0 -1
- data/app/views/caboose/pages/admin_edit_content.html.erb +19 -2
- data/app/views/caboose/pages/admin_preview.html.erb +1 -0
- data/app/views/caboose/posts/admin_edit_content.html.erb +18 -3
- data/app/views/caboose/posts/admin_preview_post.html.erb +1 -0
- data/app/views/layouts/caboose/admin.html.erb +1 -1
- data/lib/caboose/version.rb +1 -1
- metadata +3 -1
@@ -81,6 +81,10 @@
|
|
81
81
|
}
|
82
82
|
}
|
83
83
|
|
84
|
+
#cboxTopLeft, #cboxTopRight, #cboxBottomLeft, #cboxBottomRight, #cboxMiddleLeft, #cboxMiddleRight, #cboxTopCenter, #cboxBottomCenter, #cboxClose {
|
85
|
+
background: #fff !important;
|
86
|
+
}
|
87
|
+
|
84
88
|
#the_modal #modal_content .mb_container {
|
85
89
|
input {
|
86
90
|
border: #ccc 1px solid;
|
@@ -111,6 +115,20 @@
|
|
111
115
|
}
|
112
116
|
}
|
113
117
|
|
118
|
+
.cke_editable:focus {
|
119
|
+
outline-color: #c0dcff;
|
120
|
+
outline-offset: 7px;
|
121
|
+
outline-style: solid;
|
122
|
+
outline-width: 2px;
|
123
|
+
}
|
124
|
+
|
125
|
+
.richtext-block {
|
126
|
+
z-index: 6;
|
127
|
+
}
|
128
|
+
#colorbox, #cboxOverlay, #cboxWrapper {
|
129
|
+
z-index: 10000000;
|
130
|
+
}
|
131
|
+
|
114
132
|
body > .ui-draggable-dragging {
|
115
133
|
width: 95px;
|
116
134
|
height: auto;
|
@@ -134,7 +152,7 @@ p.caboose_note.delete {
|
|
134
152
|
padding: 20px;
|
135
153
|
text-align: center;
|
136
154
|
position: relative;
|
137
|
-
z-index:
|
155
|
+
z-index: 15;
|
138
156
|
font-family: 'Roboto';
|
139
157
|
font-weight: 300;
|
140
158
|
input[type="button"] {
|
@@ -200,6 +218,8 @@ body > .container, body > .mm-page > .container {
|
|
200
218
|
width: 95%;
|
201
219
|
width: calc(100vw - 200px);
|
202
220
|
float: right;
|
221
|
+
position: relative;
|
222
|
+
top: 40px;
|
203
223
|
}
|
204
224
|
#colorbox:focus {
|
205
225
|
outline-width: 0 !important;
|
@@ -213,32 +233,71 @@ body > .container, body > .mm-page > .container {
|
|
213
233
|
#tiny_header {
|
214
234
|
display: block;
|
215
235
|
color: #fff;
|
216
|
-
// background-image: url(/assets/caboose/caboose_logo_small.png);
|
217
236
|
background-color: #353535;
|
218
|
-
|
219
|
-
// background-position: right 0;
|
220
|
-
position: absolute;
|
237
|
+
position: fixed;
|
221
238
|
top: 0;
|
222
239
|
right: 0;
|
223
240
|
z-index: 100000;
|
224
|
-
|
225
|
-
|
241
|
+
width: calc(100% - 200px);
|
242
|
+
height: 40px;
|
243
|
+
padding: 0 2%;
|
244
|
+
line-height: 37px;
|
245
|
+
text-align: right;
|
246
|
+
transition: background-color 300ms ease;
|
247
|
+
#m-pub, #m-unpub {
|
248
|
+
float: left;
|
249
|
+
font-family: 'Roboto';
|
250
|
+
font-weight: 300;
|
251
|
+
font-size: 13px;
|
252
|
+
position: relative;
|
253
|
+
top: 1px;
|
254
|
+
font-style: italic;
|
255
|
+
color: #9e9e9e;
|
256
|
+
}
|
257
|
+
#m-unpub {
|
258
|
+
color: #fff;
|
259
|
+
}
|
226
260
|
a {
|
227
261
|
display: inline-block;
|
228
262
|
color: #fff;
|
229
263
|
padding: 0 10px;
|
230
264
|
font-family: 'Roboto';
|
231
265
|
font-weight: 300;
|
232
|
-
font-size:
|
266
|
+
font-size: 12px;
|
233
267
|
text-decoration: none;
|
234
|
-
|
268
|
+
background: #5a5a5a;
|
269
|
+
margin-left: 8px;
|
270
|
+
text-transform: uppercase;
|
271
|
+
border-radius: 3px;
|
272
|
+
line-height: 24px;
|
273
|
+
&[href*="revert"] {
|
274
|
+
background: #903b3b;
|
275
|
+
}
|
276
|
+
&[href*="preview"] {
|
277
|
+
background: #404088;
|
278
|
+
}
|
279
|
+
&[href*="publish"] {
|
280
|
+
background: #3b753b;
|
281
|
+
}
|
235
282
|
&:hover {
|
236
|
-
|
283
|
+
background: #c3c3c3;
|
284
|
+
color: #353535;
|
237
285
|
}
|
238
286
|
&:focus {
|
239
287
|
outline-width: 0;
|
240
288
|
}
|
241
289
|
}
|
290
|
+
&.published {
|
291
|
+
background-color: #353535;
|
292
|
+
#m-unpub { display: none; }
|
293
|
+
a[href*="revert"], a[href*="publish"] {
|
294
|
+
display: none;
|
295
|
+
}
|
296
|
+
}
|
297
|
+
&.unpublished {
|
298
|
+
background-color: #7da4a9;
|
299
|
+
#m-pub { display: none; }
|
300
|
+
}
|
242
301
|
}
|
243
302
|
|
244
303
|
// .block_over { background: #e3e3e3; }
|
@@ -248,13 +307,16 @@ body > .container, body > .mm-page > .container {
|
|
248
307
|
.delete_handle { display: none; }
|
249
308
|
.duplicate_handle { display: none; }
|
250
309
|
.drag_handle { display: none; }
|
310
|
+
.settings_handle { display: none; }
|
251
311
|
.block_over > .drag_handle { display: block; position: relative; z-index: 3; }
|
252
312
|
.block_over > .select_handle { display: block; position: relative; z-index: 3; }
|
253
313
|
// .block_over > .move_up_handle { display: block; position: relative; z-index: 3; }
|
254
314
|
// .block_over > .move_down_handle { display: block; position: relative; z-index: 3; }
|
255
315
|
.block_over > .delete_handle { display: block; position: relative; z-index: 3; }
|
256
316
|
.block_over > .duplicate_handle { display: block; position: relative; z-index: 3; }
|
317
|
+
.block_over > .settings_handle { display: block; position: relative; z-index: 3; }
|
257
318
|
.block_over > .drag_handle span { position: absolute; top: 0; right: 54px; width: 18px; height: 18px; background-color: #fff; border: #ccc 1px solid; }
|
319
|
+
.block_over > .settings_handle span { position: absolute; top: 0; right: 72px; width: 18px; height: 18px; background-color: #fff; border: #ccc 1px solid; }
|
258
320
|
.block_over > .select_handle span { position: absolute; top: 0; right: 18px; width: 18px; height: 18px; background-color: #fff; border: #ccc 1px solid; }
|
259
321
|
// .block_over > .move_up_handle span { position: absolute; top: 0; right: 36px; width: 18px; height: 18px; background-color: #fff; border: #ccc 1px solid; }
|
260
322
|
// .block_over > .move_down_handle span { position: absolute; top: 0; right: 18px; width: 18px; height: 18px; background-color: #fff; border: #ccc 1px solid; }
|
@@ -265,11 +327,13 @@ body > .container, body > .mm-page > .container {
|
|
265
327
|
.flex-grid-unit.block_over > .duplicate_handle span { right: auto; left: 18px; background-color: #f1e9e9; }
|
266
328
|
.flex-grid-unit.block_over > .select_handle span { right: auto; left: 36px; background-color: #f1e9e9; }
|
267
329
|
.flex-grid-unit.block_over > .drag_handle span { right: auto; left: 0; background-color: #f1e9e9; }
|
330
|
+
.flex-grid-unit.block_over > .settings_handle span { right: auto; left: 72px; background-color: #f1e9e9; }
|
268
331
|
|
269
332
|
.unslider-block-wrapper > .delete_handle,
|
270
333
|
.unslider-block-wrapper > .drag_handle,
|
271
334
|
.unslider-block-wrapper > .select_handle,
|
272
|
-
.unslider-block-wrapper > .duplicate_handle
|
335
|
+
.unslider-block-wrapper > .duplicate_handle,
|
336
|
+
.unslider-block-wrapper > .settings_handle {
|
273
337
|
z-index: 20;
|
274
338
|
}
|
275
339
|
|
@@ -279,6 +343,32 @@ body > .container, body > .mm-page > .container {
|
|
279
343
|
}
|
280
344
|
}
|
281
345
|
|
346
|
+
#caboose-notice {
|
347
|
+
position: fixed;
|
348
|
+
top: 40px;
|
349
|
+
right: 0;
|
350
|
+
width: 300px;
|
351
|
+
z-index: 1000;
|
352
|
+
background: #51883b;
|
353
|
+
color: white;
|
354
|
+
padding: 10px 12px 11px 12px;
|
355
|
+
font-size: 13px;
|
356
|
+
text-align: center;
|
357
|
+
font-family: 'Roboto';
|
358
|
+
font-weight: 300;
|
359
|
+
a {
|
360
|
+
position: absolute;
|
361
|
+
top: 1px;
|
362
|
+
right: 5px;
|
363
|
+
text-decoration: none;
|
364
|
+
color: #fff;
|
365
|
+
display: inline-block;
|
366
|
+
&:hover {
|
367
|
+
color: red;
|
368
|
+
}
|
369
|
+
}
|
370
|
+
}
|
371
|
+
|
282
372
|
.new_block_link {
|
283
373
|
position: relative;
|
284
374
|
width: 100%;
|
@@ -57,7 +57,7 @@ module Caboose
|
|
57
57
|
# Sets an instance variable of the logged in user
|
58
58
|
@logged_in_user = logged_in_user
|
59
59
|
|
60
|
-
|
60
|
+
# @nav = Caboose.plugin_hook('admin_nav', [], @logged_in_user, @page, @site) if request.fullpath.include?('/admin')
|
61
61
|
|
62
62
|
# Initialize the card
|
63
63
|
init_cart if @site && @site.use_store && !@domain.under_construction
|
@@ -47,9 +47,10 @@ module Caboose
|
|
47
47
|
end
|
48
48
|
b.parent_id = params[:id]
|
49
49
|
b.block_type_id = block_type_id
|
50
|
+
b.status = 'added'
|
50
51
|
b.sort_order = Block.where(:parent_id => params[:id]).count
|
51
52
|
b.save
|
52
|
-
b.create_children
|
53
|
+
b.create_children(status: 'added')
|
53
54
|
if params[:page_id]
|
54
55
|
redirect_to "/admin/pages/#{b.page_id}/blocks/#{b.id}/edit"
|
55
56
|
else
|
@@ -59,8 +60,16 @@ module Caboose
|
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
62
|
-
@page = Page.find(params[:page_id]) if params[:page_id]
|
63
|
-
|
63
|
+
@page = Page.find(params[:page_id]) if params[:page_id]
|
64
|
+
if @page
|
65
|
+
@page.status = 'edited'
|
66
|
+
@page.save
|
67
|
+
end
|
68
|
+
@post = Post.find(params[:post_id]) if params[:post_id]
|
69
|
+
if @post
|
70
|
+
@post.status = 'edited'
|
71
|
+
@post.save
|
72
|
+
end
|
64
73
|
@block = params[:id] ? Block.find(params[:id]) : (params[:page_id] ? Block.new(:page_id => params[:page_id]) : Block.new(:post_id => params[:post_id]))
|
65
74
|
@after_id = params[:after_id] ? params[:after_id] : nil
|
66
75
|
@before_id = params[:before_id] ? params[:before_id] : nil
|
@@ -77,15 +86,15 @@ module Caboose
|
|
77
86
|
blocks = []
|
78
87
|
if params[:id]
|
79
88
|
b = Block.find(params[:id])
|
80
|
-
b.create_children
|
89
|
+
b.create_children(status: 'added') if Caboose::Block.where(:parent_id => b.id).count == 0
|
81
90
|
bt = b.block_type
|
82
91
|
blocks << {
|
83
92
|
'id' => b.id,
|
84
|
-
'parent_id' => b.parent_id,
|
93
|
+
'parent_id' => (b.new_parent_id.blank? ? b.parent_id : b.new_parent_id),
|
85
94
|
'page_id' => b.page_id,
|
86
95
|
'post_id' => b.post_id,
|
87
96
|
'name' => b.name,
|
88
|
-
'value' => b.value,
|
97
|
+
'value' => (b.new_value.blank? ? b.value : (b.new_value == 'EMPTY' ? nil : b.new_value)),
|
89
98
|
'constrain' => b.constrain,
|
90
99
|
'full_width' => b.full_width,
|
91
100
|
'block_type' => bt,
|
@@ -98,15 +107,15 @@ module Caboose
|
|
98
107
|
}
|
99
108
|
else
|
100
109
|
q = params[:page_id] ? ["parent_id is null and page_id = ?", params[:page_id]] : ["parent_id is null and post_id = ?", params[:post_id]]
|
101
|
-
Block.where(q).reorder(:
|
110
|
+
Block.where(q).reorder(:new_sort_order).all.each do |b|
|
102
111
|
bt = b.block_type
|
103
112
|
blocks << {
|
104
113
|
'id' => b.id,
|
105
|
-
'parent_id' => b.parent_id,
|
114
|
+
'parent_id' => (b.new_parent_id.blank? ? b.parent_id : b.new_parent_id),
|
106
115
|
'page_id' => b.page_id,
|
107
116
|
'post_id' => b.post_id,
|
108
117
|
'name' => b.name,
|
109
|
-
'value' => b.value,
|
118
|
+
'value' => (b.new_value.blank? ? b.value : (b.new_value == 'EMPTY' ? nil : b.new_value)),
|
110
119
|
'constrain' => b.constrain,
|
111
120
|
'full_width' => b.full_width,
|
112
121
|
'block_type' => bt,
|
@@ -118,6 +127,7 @@ module Caboose
|
|
118
127
|
}
|
119
128
|
end
|
120
129
|
end
|
130
|
+
# Caboose.log(blocks)
|
121
131
|
render :json => blocks
|
122
132
|
end
|
123
133
|
|
@@ -138,15 +148,15 @@ module Caboose
|
|
138
148
|
|
139
149
|
def admin_tree_helper(b)
|
140
150
|
arr = []
|
141
|
-
b.
|
151
|
+
b.filtered_children(true,true).order(:block_type_id).each do |b2|
|
142
152
|
bt = b2.block_type
|
143
153
|
arr << {
|
144
154
|
'id' => b2.id,
|
145
|
-
'parent_id' => b2.parent_id,
|
155
|
+
'parent_id' => (b2.new_parent_id.blank? ? b2.parent_id : b2.new_parent_id),
|
146
156
|
'page_id' => b2.page_id,
|
147
157
|
'post_id' => b2.post_id,
|
148
158
|
'name' => b2.name,
|
149
|
-
'value' => b2.value,
|
159
|
+
'value' => (b2.new_value.blank? ? b2.value : (b2.new_value == 'EMPTY' ? nil : b2.new_value)),
|
150
160
|
'constrain' => b2.constrain,
|
151
161
|
'full_width' => b2.full_width,
|
152
162
|
'block_type' => bt,
|
@@ -166,7 +176,12 @@ module Caboose
|
|
166
176
|
return unless user_is_allowed("#{page_or_post}s", 'edit')
|
167
177
|
resp = Caboose::StdClass.new
|
168
178
|
b = Block.find(params[:id])
|
169
|
-
b.
|
179
|
+
b.new_media_id = 0
|
180
|
+
b.image_file_name = nil
|
181
|
+
b.image_file_size = nil
|
182
|
+
b.image_content_type = nil
|
183
|
+
b.image_updated_at = nil
|
184
|
+
b.status = 'edited' if b.status == 'published'
|
170
185
|
resp.success = b.save
|
171
186
|
render :json => resp
|
172
187
|
end
|
@@ -196,9 +211,10 @@ module Caboose
|
|
196
211
|
:site => @site,
|
197
212
|
:page => params[:page_id] ? @p : nil,
|
198
213
|
:post => params[:post_id] ? @p : nil,
|
199
|
-
:request => request
|
214
|
+
:request => request,
|
215
|
+
:is_new => (params[:is_new].blank? ? false : true)
|
200
216
|
})
|
201
|
-
render :inline => html
|
217
|
+
render :inline => html
|
202
218
|
end
|
203
219
|
|
204
220
|
# @route GET /admin/pages/:page_id/blocks/render
|
@@ -236,7 +252,7 @@ module Caboose
|
|
236
252
|
def admin_render_second_level
|
237
253
|
return unless user_is_allowed("#{page_or_post}s", 'edit')
|
238
254
|
view = ActionView::Base.new(ActionController::Base.view_paths)
|
239
|
-
blocks = @p.block.
|
255
|
+
blocks = @p.block.filtered_children(true,true).collect do |b|
|
240
256
|
{
|
241
257
|
:id => b.id,
|
242
258
|
:block_type_id => b.block_type.id,
|
@@ -321,7 +337,8 @@ module Caboose
|
|
321
337
|
|
322
338
|
resp = Caboose::StdClass.new
|
323
339
|
|
324
|
-
b = Block.new
|
340
|
+
b = Block.new
|
341
|
+
b.status = 'added'
|
325
342
|
if params[:page_id]
|
326
343
|
b.page_id = params[:page_id].to_i
|
327
344
|
else
|
@@ -331,51 +348,62 @@ module Caboose
|
|
331
348
|
b.block_type_id = params[:block_type_id]
|
332
349
|
|
333
350
|
if !params[:index].nil?
|
334
|
-
b.
|
351
|
+
b.new_sort_order = params[:index].to_i
|
335
352
|
|
336
353
|
i = 1
|
337
|
-
b.parent.
|
338
|
-
b3.
|
354
|
+
b.parent.filtered_children(true).where('new_sort_order >= ?', b.new_sort_order).order('new_sort_order,id').all.each do |b3|
|
355
|
+
b3.new_sort_order = b.new_sort_order + i
|
356
|
+
b3.status = 'edited' if b3.status == 'published'
|
339
357
|
b3.save
|
340
358
|
i = i + 1
|
341
359
|
end
|
342
360
|
|
343
361
|
elsif params[:before_id] && !params[:before_id].blank?
|
344
362
|
b2 = Block.find(params[:before_id].to_i)
|
345
|
-
b.
|
363
|
+
b.new_sort_order = b2.new_sort_order
|
346
364
|
|
347
365
|
i = 1
|
348
|
-
b2.parent.
|
349
|
-
b3.
|
366
|
+
b2.parent.filtered_children(true).where('new_sort_order >= ?', b.new_sort_order).order('new_sort_order,id').all.each do |b3|
|
367
|
+
b3.new_sort_order = b.new_sort_order + i
|
368
|
+
b3.status = 'edited' if b3.status == 'published'
|
350
369
|
b3.save
|
351
370
|
i = i + 1
|
352
371
|
end
|
353
372
|
|
354
373
|
elsif params[:after_id] && !params[:after_id].blank?
|
355
374
|
b2 = Block.find(params[:after_id].to_i)
|
356
|
-
b.
|
357
|
-
|
375
|
+
b.new_sort_order = b2.new_sort_order + 1
|
376
|
+
|
358
377
|
i = 1
|
359
|
-
b2.parent.
|
360
|
-
b3.
|
378
|
+
b2.parent.filtered_children(true).where('new_sort_order >= ?', b.new_sort_order).order('new_sort_order,id').all.each do |b3|
|
379
|
+
b3.new_sort_order = b.new_sort_order + i
|
380
|
+
b3.status = 'edited' if b3.status == 'published'
|
361
381
|
b3.save
|
362
382
|
i = i + 1
|
363
383
|
end
|
364
384
|
|
365
385
|
elsif params[:id]
|
366
|
-
b.
|
386
|
+
b.new_sort_order = Block.where(:name => nil).where("(new_parent_id is null and parent_id = ? and status != ?) OR (new_parent_id = ? and status != ?)",params[:id],'deleted',params[:id],'deleted').count
|
367
387
|
end
|
368
388
|
|
369
389
|
# Save the block
|
370
390
|
b.save
|
371
391
|
|
392
|
+
# if b.page
|
393
|
+
# b.page.status = 'edited'
|
394
|
+
# b.page.save
|
395
|
+
# elsif b.post
|
396
|
+
# b.post.status = 'edited'
|
397
|
+
# b.post.save
|
398
|
+
# end
|
399
|
+
|
372
400
|
if !b.block_type.default.blank?
|
373
401
|
b.value = b.block_type.default
|
374
402
|
b.save
|
375
403
|
end
|
376
404
|
|
377
405
|
# Ensure that all the children are created for the block
|
378
|
-
b.create_children
|
406
|
+
b.create_children(status: 'added')
|
379
407
|
|
380
408
|
# Default child block count
|
381
409
|
if !params[:child_count].blank? && params[:child_count].to_i > 0
|
@@ -388,9 +416,12 @@ module Caboose
|
|
388
416
|
end
|
389
417
|
b1.parent_id = b.id
|
390
418
|
b1.sort_order = ind
|
419
|
+
b1.new_sort_order = ind
|
420
|
+
# b1.new_parent_id = b.id
|
421
|
+
b1.status = 'added'
|
391
422
|
b1.block_type_id = b.block_type.default_child_block_type_id
|
392
423
|
b1.save
|
393
|
-
b1.create_children
|
424
|
+
b1.create_children(status: 'added')
|
394
425
|
bw = b1.child('width')
|
395
426
|
if bw
|
396
427
|
bw.value = 'auto' # (100.0 / params[:child_count].to_f).to_i.to_s + '%'
|
@@ -427,12 +458,17 @@ module Caboose
|
|
427
458
|
#when 'page_id' then b.page_id = v
|
428
459
|
when 'parent_id' then
|
429
460
|
b.parent_id = v
|
430
|
-
b.
|
461
|
+
b.new_sort_order = Block.where("(parent_id = ? and status = ?) or (new_parent_id = ? and (status = ? or status = ?))",v,'published',v,'edited','added').count
|
462
|
+
b.status = 'edited' if b.status == 'published'
|
431
463
|
when 'block_type_id' then b.block_type_id = v
|
432
|
-
when 'sort_order' then
|
464
|
+
when 'sort_order' then
|
465
|
+
b.new_sort_order = v
|
466
|
+
b.status = 'edited' if b.status == 'published'
|
433
467
|
when 'constrain' then b.constrain = v
|
434
468
|
when 'full_width' then b.full_width = v
|
435
|
-
when 'media_id' then
|
469
|
+
when 'media_id' then
|
470
|
+
b.new_media_id = v
|
471
|
+
b.status = 'edited' if b.status == 'published'
|
436
472
|
when 'name' then b.name = v
|
437
473
|
when 'value' then
|
438
474
|
|
@@ -448,31 +484,54 @@ module Caboose
|
|
448
484
|
b = RichTextBlockParser.parse(b, v, request.host_with_port)
|
449
485
|
else
|
450
486
|
if b.block_type.field_type == 'checkbox_multiple'
|
451
|
-
b.
|
487
|
+
b.new_value = Block.parse_checkbox_multiple_value(b, v)
|
452
488
|
else
|
453
|
-
b.
|
489
|
+
b.new_value = (v.blank? ? 'EMPTY' : v)
|
490
|
+
b.status = 'edited' if b.status == 'published'
|
454
491
|
end
|
455
492
|
end
|
456
493
|
end
|
457
494
|
end
|
458
495
|
end
|
459
|
-
|
460
|
-
#
|
461
|
-
#
|
462
|
-
#
|
463
|
-
#
|
464
|
-
#
|
465
|
-
#
|
466
|
-
# PageCacher.delay(:queue => 'caboose_cache').refresh
|
467
|
-
# else
|
468
|
-
# PageCacher.delay(:queue => 'caboose_cache').cache(b.page_id)
|
469
|
-
# end
|
496
|
+
|
497
|
+
# if b.page
|
498
|
+
# b.page.status = 'edited'
|
499
|
+
# b.page.save
|
500
|
+
# elsif b.post
|
501
|
+
# b.post.status = 'edited'
|
502
|
+
# b.post.save
|
470
503
|
# end
|
471
504
|
|
472
505
|
resp.success = save && b.save
|
473
|
-
b.create_children
|
506
|
+
b.create_children(status: 'added')
|
474
507
|
render :json => resp
|
475
508
|
end
|
509
|
+
|
510
|
+
# @route PUT /admin/pages/:page_id/blocks/:id/value
|
511
|
+
# @route PUT /admin/posts/:post_id/blocks/:id/value
|
512
|
+
def admin_update_value
|
513
|
+
return unless user_is_allowed('pages', 'edit')
|
514
|
+
resp = StdClass.new({'attributes' => {}})
|
515
|
+
b = Block.find(params[:id])
|
516
|
+
# if b.block_type_id == 309 # Richtext
|
517
|
+
b.new_value = params[:value]
|
518
|
+
b.status = 'edited' if b.status == 'published'
|
519
|
+
# if b.page
|
520
|
+
# b.page.status = 'edited'
|
521
|
+
# b.page.save
|
522
|
+
# elsif b.post
|
523
|
+
# b.post.status = 'edited'
|
524
|
+
# b.post.save
|
525
|
+
# end
|
526
|
+
|
527
|
+
# elsif b.block_type_id == 1 # Heading
|
528
|
+
# b1 = b.child('heading_text')
|
529
|
+
# b1.value = params[:value]
|
530
|
+
# b1.save
|
531
|
+
# end
|
532
|
+
resp.success = b.save
|
533
|
+
render :json => resp
|
534
|
+
end
|
476
535
|
|
477
536
|
# @route POST /admin/pages/:page_id/blocks/:id/image
|
478
537
|
# @route POST /admin/posts/:post_id/blocks/:id/image
|
@@ -525,6 +584,7 @@ module Caboose
|
|
525
584
|
|
526
585
|
resp = StdClass.new
|
527
586
|
b = Block.find(params[:id])
|
587
|
+
# sibs = b.siblings
|
528
588
|
parent_id = b.parent_id
|
529
589
|
if b.parent_id
|
530
590
|
if params[:page_id]
|
@@ -535,15 +595,43 @@ module Caboose
|
|
535
595
|
else
|
536
596
|
resp.close = true
|
537
597
|
end
|
538
|
-
|
598
|
+
|
599
|
+
# if b.page
|
600
|
+
# b.page.status = 'edited'
|
601
|
+
# b.page.save
|
602
|
+
# elsif b.post
|
603
|
+
# b.post.status = 'edited'
|
604
|
+
# b.post.save
|
605
|
+
# end
|
606
|
+
|
607
|
+
|
608
|
+
child_ids = b.filtered_children(true).pluck(:id)
|
609
|
+
cids = child_ids.blank? ? 0 : child_ids
|
610
|
+
|
611
|
+
|
612
|
+
bid1 = Block.where("id = ? or id in (?)",b.id,cids).where('status = ? or status = ?','edited','published')
|
613
|
+
# Caboose.log("marking as deleted: #{bid1.pluck(:id)}")
|
614
|
+
bid1.update_all(:status => 'deleted')
|
615
|
+
bid2 = Block.where("id = ? or id in (?)",b.id,cids).where(:status => 'added')
|
616
|
+
bid2.destroy_all
|
617
|
+
# Caboose.log("destroying: #{bid2.pluck(:id)}")
|
618
|
+
|
539
619
|
|
540
620
|
if parent_id
|
541
|
-
i = 0
|
542
|
-
Block.where(:parent_id => parent_id).
|
543
|
-
|
621
|
+
# i = 0
|
622
|
+
# Block.where(:parent_id => parent_id).where('status != ?', 'deleted').order(:new_sort_order).all.each do |b2|
|
623
|
+
# b2.new_sort_order = i
|
624
|
+
# b2.status = 'edited' if b2.status == 'published'
|
625
|
+
# b2.save
|
626
|
+
# i = i + 1
|
627
|
+
# end
|
628
|
+
sibs = Caboose::Block.where(:name => nil).where("(new_parent_id is null and parent_id = ? and status != ?) OR (new_parent_id = ? and status != ?)",parent_id,'deleted',parent_id,'deleted').order(:new_sort_order, :id).all
|
629
|
+
sibs.each_with_index do |b2, i|
|
630
|
+
b2.new_sort_order = i
|
631
|
+
b2.status = 'edited' if b2.status == 'published'
|
544
632
|
b2.save
|
545
|
-
|
546
|
-
|
633
|
+
end
|
634
|
+
|
547
635
|
end
|
548
636
|
|
549
637
|
render :json => resp
|
@@ -555,11 +643,32 @@ module Caboose
|
|
555
643
|
return unless user_is_allowed("#{page_or_post}s", 'edit')
|
556
644
|
resp = StdClass.new
|
557
645
|
b = Block.find(params[:id])
|
558
|
-
|
646
|
+
# if b.page
|
647
|
+
# b.page.status = 'edited'
|
648
|
+
# b.page.save
|
649
|
+
# elsif b.post
|
650
|
+
# b.post.status = 'edited'
|
651
|
+
# b.post.save
|
652
|
+
# end
|
653
|
+
resp.new_id = b.duplicate_block(@site.id, params[:page_id], params[:post_id], b.block_type_id, (b.new_parent_id.blank? ? b.parent_id : b.new_parent_id))
|
559
654
|
resp.success = true
|
560
655
|
render :json => resp
|
561
656
|
end
|
562
657
|
|
658
|
+
# @route GET /admin/pages/:page_id/blocks/:id/new-child-blocks
|
659
|
+
# @route GET /admin/posts/:post_id/blocks/:id/new-child-blocks
|
660
|
+
# def admin_new_child_blocks
|
661
|
+
# return unless user_is_allowed('pages', 'edit')
|
662
|
+
# resp = StdClass.new
|
663
|
+
# resp.blocks = []
|
664
|
+
|
665
|
+
# Block.where(:new_parent_id => params[:id]).all.each do |b|
|
666
|
+
# resp.blocks << b
|
667
|
+
# end
|
668
|
+
|
669
|
+
# render :json => resp
|
670
|
+
# end
|
671
|
+
|
563
672
|
# @route GET /admin/pages/:page_id/blocks/:id/api-info
|
564
673
|
# @route GET /admin/posts/:post_id/blocks/:id/api-info
|
565
674
|
def admin_block_info
|
@@ -580,8 +689,10 @@ module Caboose
|
|
580
689
|
return unless user_is_allowed("#{page_or_post}s", 'edit')
|
581
690
|
resp = StdClass.new
|
582
691
|
b = Block.find(params[:id])
|
583
|
-
|
584
|
-
resp.
|
692
|
+
par = Block.where(:name => nil).where(:id => (b.new_parent_id.blank? ? b.parent_id : b.new_parent_id)).first
|
693
|
+
resp.parent_id = par ? par.id : nil
|
694
|
+
gp = par ? Block.where(:name => nil).where(:id => (par.new_parent_id.blank? ? par.parent_id : par.new_parent_id)).first : nil
|
695
|
+
resp.grandparent_id = gp ? gp.id : nil
|
585
696
|
render :json => resp
|
586
697
|
end
|
587
698
|
|
@@ -591,28 +702,42 @@ module Caboose
|
|
591
702
|
return unless user_is_allowed("#{page_or_post}s", 'edit')
|
592
703
|
resp = StdClass.new
|
593
704
|
b = Block.find(params[:id])
|
594
|
-
if
|
705
|
+
if !params[:before_id].blank?
|
595
706
|
b2 = Block.find(params[:before_id].to_i)
|
596
|
-
b.
|
707
|
+
b.new_sort_order = (b2.new_sort_order.blank? ? b2.sort_order : b2.new_sort_order)
|
597
708
|
i = 1
|
598
|
-
b2.
|
599
|
-
|
709
|
+
sibs = b2.siblings(b.new_sort_order)
|
710
|
+
# Caboose.log("updating #{sibs.count} siblings")
|
711
|
+
sibs.each do |b3|
|
712
|
+
b3.new_sort_order = b.new_sort_order + i
|
713
|
+
b3.status = 'edited' if b3.status == 'published'
|
600
714
|
b3.save
|
601
715
|
i = i + 1
|
602
716
|
end
|
603
|
-
elsif
|
717
|
+
elsif !params[:after_id].blank?
|
604
718
|
b2 = Block.find(params[:after_id].to_i)
|
605
|
-
b.
|
719
|
+
b.new_sort_order = (b2.new_sort_order.blank? ? (b2.sort_order + 1) : (b2.new_sort_order + 1))
|
606
720
|
i = 1
|
607
|
-
b2.
|
608
|
-
|
721
|
+
sibs = b2.siblings(b.new_sort_order)
|
722
|
+
# Caboose.log("updating #{sibs.count} siblings")
|
723
|
+
sibs.each do |b3|
|
724
|
+
b3.new_sort_order = b.new_sort_order + i
|
725
|
+
b3.status = 'edited' if b3.status == 'published'
|
609
726
|
b3.save
|
610
|
-
i = i + 1
|
727
|
+
i = i + 1
|
611
728
|
end
|
612
729
|
elsif params[:parent_id]
|
613
|
-
b.
|
730
|
+
b.new_sort_order = b.siblings.count
|
614
731
|
end
|
615
|
-
b.
|
732
|
+
b.new_parent_id = params[:parent_id] # if params[:parent_id] != b.parent_id.to_s
|
733
|
+
b.status = 'edited' if b.status == 'published'
|
734
|
+
# if b.page
|
735
|
+
# b.page.status = 'edited'
|
736
|
+
# b.page.save
|
737
|
+
# elsif b.post
|
738
|
+
# b.post.status = 'edited'
|
739
|
+
# b.post.save
|
740
|
+
# end
|
616
741
|
resp.success = true
|
617
742
|
b.save
|
618
743
|
render :json => resp
|
@@ -631,6 +756,13 @@ module Caboose
|
|
631
756
|
else
|
632
757
|
resp.success = "The block has been moved up successfully."
|
633
758
|
end
|
759
|
+
# if b.page
|
760
|
+
# b.page.status = 'edited'
|
761
|
+
# b.page.save
|
762
|
+
# elsif b.post
|
763
|
+
# b.post.status = 'edited'
|
764
|
+
# b.post.save
|
765
|
+
# end
|
634
766
|
render :json => resp
|
635
767
|
end
|
636
768
|
|
@@ -641,16 +773,19 @@ module Caboose
|
|
641
773
|
|
642
774
|
resp = StdClass.new
|
643
775
|
b = Block.find(params[:id])
|
644
|
-
|
645
|
-
if
|
776
|
+
changed = b.move_down
|
777
|
+
if !changed
|
646
778
|
resp.error = "The block is already at the bottom."
|
647
|
-
else
|
648
|
-
b2.sort_order = b.sort_order
|
649
|
-
b2.save
|
650
|
-
b.sort_order = b.sort_order + 1
|
651
|
-
b.save
|
779
|
+
else
|
652
780
|
resp.success = "The block has been moved down successfully."
|
653
781
|
end
|
782
|
+
# if b.page
|
783
|
+
# b.page.status = 'edited'
|
784
|
+
# b.page.save
|
785
|
+
# elsif b.post
|
786
|
+
# b.post.status = 'edited'
|
787
|
+
# b.post.save
|
788
|
+
# end
|
654
789
|
|
655
790
|
render :json => resp
|
656
791
|
end
|