caboose-cms 0.4.149 → 0.4.150
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/model/index_table.js +166 -58
- data/app/controllers/caboose/block_types_controller.rb +1 -1
- data/app/views/caboose/block_types/admin_edit.html.erb +8 -4
- data/app/views/caboose/block_types/admin_index.html.erb +27 -26
- data/app/views/caboose/pages/admin_new.html.erb +1 -2
- data/lib/caboose/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
ZGZlMDM5NDZkZTI0NjBkZmQyN2JkMmM0M2M5Mzc1YjQ0MzMxOGNjOA==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
M2QzNWNlYmY2YWJiZjY2OWNkMGU2YTc3M2FjMjg4OTczMDQxMjBmZg==
|
|
7
7
|
!binary "U0hBNTEy":
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
Y2EzYWExMDU3MzY4MjA4ZjdlZmIxYWU2MzY4ZTk5YmQyMDJjZTYyYWExYTA4
|
|
10
|
+
NTM5ODk1MDgzNjA0OGRkNjg3ZDMxY2Q0NTFkMTdmMDkzZGNiNzY1OTM1Yzc0
|
|
11
|
+
MzYxZTY2YTJlMjQ2Nzc4OWUwNjM4YTZkM2JkYWU2YTIzMDhhYTk=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
MmNiMzg1ZTIzMTkzZGE3ZTE1Y2E4NzRiYzg5MWUxYmU1NGQ0MmY2NjFkYWI5
|
|
14
|
+
OTI2YWUyZjdkOGYyOWNhMmIxYzFkMzk2YTdlMDk5MjdiODQyNDQ3NTQwMzcy
|
|
15
|
+
MDQ2ZWI3NTQ2MThmM2QwMzU3OWRiYmQ2MjJkZjYyZDI3ZjIxOWQ=
|
|
@@ -31,6 +31,9 @@ IndexTable.prototype = {
|
|
|
31
31
|
// Example: function(model_id) { return '/admin/models/' + model_id + '/duplicate' },
|
|
32
32
|
duplicate_url: false,
|
|
33
33
|
|
|
34
|
+
// Where to post new models
|
|
35
|
+
add_url: false,
|
|
36
|
+
|
|
34
37
|
// What to do when a row is clicked
|
|
35
38
|
// Example: function (model_id) { return '/admin/models/' + model_id; }
|
|
36
39
|
row_click_handler: false,
|
|
@@ -56,7 +59,13 @@ IndexTable.prototype = {
|
|
|
56
59
|
allow_bulk_edit: true,
|
|
57
60
|
allow_bulk_delete: true,
|
|
58
61
|
allow_duplicate: true,
|
|
59
|
-
|
|
62
|
+
|
|
63
|
+
no_models_text: "There are no models right now.",
|
|
64
|
+
new_model_text: 'New',
|
|
65
|
+
new_model_fields: [
|
|
66
|
+
{ name: 'name', nice_name: 'Name', type: 'text', width: 400 }
|
|
67
|
+
],
|
|
68
|
+
|
|
60
69
|
//============================================================================
|
|
61
70
|
// End of required parameters
|
|
62
71
|
//============================================================================
|
|
@@ -64,15 +73,10 @@ IndexTable.prototype = {
|
|
|
64
73
|
models: [],
|
|
65
74
|
model_ids: [],
|
|
66
75
|
quick_edit_field: false, // The field currently being edited
|
|
67
|
-
refresh_count: 0,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
//sort: '',
|
|
72
|
-
//desc: false,
|
|
73
|
-
//item_count: 0,
|
|
74
|
-
//items_per_page: 4,
|
|
75
|
-
//page: 1
|
|
76
|
+
refresh_count: 0,
|
|
77
|
+
pager: {
|
|
78
|
+
options: { page: 1 },
|
|
79
|
+
params: {}
|
|
76
80
|
},
|
|
77
81
|
|
|
78
82
|
init: function(params) {
|
|
@@ -82,7 +86,8 @@ IndexTable.prototype = {
|
|
|
82
86
|
var that = this;
|
|
83
87
|
if (!this.refresh_url ) this.refresh_url = this.base_url + '/json';
|
|
84
88
|
if (!this.bulk_update_url ) this.bulk_update_url = this.base_url + '/bulk';
|
|
85
|
-
if (!this.bulk_delete_url ) this.bulk_delete_url = this.base_url + '/bulk';
|
|
89
|
+
if (!this.bulk_delete_url ) this.bulk_delete_url = this.base_url + '/bulk';
|
|
90
|
+
if (!this.add_url ) this.add_url = this.base_url;
|
|
86
91
|
if (!this.update_url ) this.update_url = function(model_id) { return this.base_url + '/' + model_id; };
|
|
87
92
|
if (!this.duplicate_url ) this.duplicate_url = function(model_id) { return this.base_url + '/' + model_id + '/duplicate'; };
|
|
88
93
|
if (!this.row_click_handler ) this.row_click_handler = function(model_id) { window.location = this.base_url + '/' + model_id; };
|
|
@@ -122,8 +127,13 @@ IndexTable.prototype = {
|
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
// Set both hash and querystring values in the pager
|
|
125
|
-
for (var i in b)
|
|
126
|
-
|
|
130
|
+
for (var i in b)
|
|
131
|
+
{
|
|
132
|
+
if (i == 'sort' || i == 'desc' || i == 'page')
|
|
133
|
+
this.pager.options[i] = b[i];
|
|
134
|
+
else
|
|
135
|
+
this.pager.params[i] = b[i];
|
|
136
|
+
}
|
|
127
137
|
|
|
128
138
|
// If there's a querystring, then redirect to hash
|
|
129
139
|
//if (window.location.search.length > 0)
|
|
@@ -134,25 +144,26 @@ IndexTable.prototype = {
|
|
|
134
144
|
},
|
|
135
145
|
|
|
136
146
|
refresh: function()
|
|
137
|
-
{
|
|
147
|
+
{
|
|
148
|
+
this.pager = { options: { page: 1 }, params: {}};
|
|
138
149
|
this.parse_querystring();
|
|
139
150
|
|
|
140
151
|
var that = this;
|
|
141
|
-
var $el = $('#
|
|
142
|
-
$el.html("<p class='loading'>Refreshing...</p>");
|
|
152
|
+
var $el = $('#' + this.container + '_columns').length > 0 ? $('#' + this.container + '_table_container') : $('#' + this.container);
|
|
153
|
+
$el.html("<p class='loading'>Refreshing...</p>");
|
|
143
154
|
$.ajax({
|
|
144
155
|
url: that.refresh_url,
|
|
145
156
|
type: 'get',
|
|
146
|
-
data: that.pager_params
|
|
147
|
-
success: function(resp) {
|
|
157
|
+
data: that.pager_params(),
|
|
158
|
+
success: function(resp) {
|
|
148
159
|
for (var thing in resp['pager'])
|
|
149
|
-
that.
|
|
160
|
+
that.pager[thing] = resp['pager'][thing];
|
|
150
161
|
that.models = resp['models'];
|
|
151
162
|
for (var i=0; i<that.models.length; i++)
|
|
152
163
|
{
|
|
153
164
|
var m = that.models[i];
|
|
154
165
|
m.id = parseInt(m.id);
|
|
155
|
-
}
|
|
166
|
+
}
|
|
156
167
|
that.print();
|
|
157
168
|
|
|
158
169
|
// Set the history state
|
|
@@ -172,34 +183,48 @@ IndexTable.prototype = {
|
|
|
172
183
|
{
|
|
173
184
|
var that = this;
|
|
174
185
|
|
|
186
|
+
if (that.models == null || that.models.length == 0)
|
|
187
|
+
{
|
|
188
|
+
$('#' + that.container).empty()
|
|
189
|
+
.append($('<p/>').append(that.new_model_link()))
|
|
190
|
+
.append($('<div/>').attr('id', that.container + '_new_form_container'))
|
|
191
|
+
.append($('<p/>').append(that.no_models_text));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
175
195
|
var tbody = $('<tbody/>').append(this.table_headers());
|
|
176
196
|
$.each(that.models, function(i, m) {
|
|
177
197
|
tbody.append(that.table_row(m));
|
|
178
198
|
});
|
|
179
199
|
var table = $('<table/>').addClass('data').css('margin-bottom', '10px').append(tbody);
|
|
180
|
-
var
|
|
200
|
+
var pager_div = this.pager_div();
|
|
181
201
|
|
|
182
|
-
if ($('#
|
|
202
|
+
if ($('#' + this.container + '_columns').length > 0)
|
|
183
203
|
{
|
|
184
|
-
$('#
|
|
185
|
-
$('#
|
|
204
|
+
$('#' + this.container + '_table_container').empty().append(table);
|
|
205
|
+
$('#' + this.container + '_pager').empty().append(pager_div);
|
|
206
|
+
$('#' + this.container + '_new_form_container').empty();
|
|
186
207
|
}
|
|
187
208
|
else
|
|
188
209
|
{
|
|
189
210
|
var columns = this.column_checkboxes();
|
|
190
211
|
var controls = $('<p/>');
|
|
191
|
-
if (this.allow_bulk_edit ) controls.append($('<input/>').attr('type', 'button').attr('id', '
|
|
192
|
-
if (this.allow_bulk_delete ) controls.append($('<input/>').attr('type', 'button').attr('id', '
|
|
193
|
-
if (this.allow_duplicate ) controls.append($('<input/>').attr('type', 'button').attr('id', '
|
|
212
|
+
if (this.allow_bulk_edit ) controls.append($('<input/>').attr('type', 'button').attr('id', this.container + '_bulk_edit' ).val('Bulk Edit' ).click(function(e) { that.bulk_edit(); })).append(' ');
|
|
213
|
+
if (this.allow_bulk_delete ) controls.append($('<input/>').attr('type', 'button').attr('id', this.container + '_bulk_delete').val('Bulk Delete').click(function(e) { that.bulk_delete(); })).append(' ');
|
|
214
|
+
if (this.allow_duplicate ) controls.append($('<input/>').attr('type', 'button').attr('id', this.container + '_duplicate' ).val('Duplicate' ).click(function(e) { that.duplicate(); }));
|
|
194
215
|
|
|
195
216
|
$('#' + that.container).empty()
|
|
196
|
-
.append($('<
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
.append($('<div/>').attr('id', '
|
|
217
|
+
.append($('<p/>')
|
|
218
|
+
.append(that.new_model_link()).append(' | ')
|
|
219
|
+
.append($('<a/>').attr('href', '#').html('Show/Hide Columns').click(function(e) { e.preventDefault(); $('#' + that.container + '_columns').slideToggle(); }))
|
|
220
|
+
)
|
|
221
|
+
.append($('<div/>').attr('id', that.container + '_new_form_container'))
|
|
222
|
+
.append($('<div/>').attr('id', that.container + '_columns').append(columns))
|
|
223
|
+
.append($('<div/>').attr('id', that.container + '_table_container').append(table))
|
|
224
|
+
.append($('<div/>').attr('id', that.container + '_pager').append(pager_div))
|
|
225
|
+
.append($('<div/>').attr('id', that.container + '_message'))
|
|
201
226
|
.append(controls);
|
|
202
|
-
$('#
|
|
227
|
+
$('#' + that.container + '_columns').hide();
|
|
203
228
|
}
|
|
204
229
|
|
|
205
230
|
if (that.quick_edit_field)
|
|
@@ -238,10 +263,14 @@ IndexTable.prototype = {
|
|
|
238
263
|
if (field.show)
|
|
239
264
|
{
|
|
240
265
|
var s = field.sort ? field.sort : field.name;
|
|
241
|
-
|
|
266
|
+
console.log("field.name = " + field.name);
|
|
267
|
+
console.log("that.pager.options.sort = " + that.pager.options.sort);
|
|
268
|
+
console.log("that.pager.options.desc = " + that.pager.options.desc);
|
|
269
|
+
console.log("------------------------------");
|
|
270
|
+
var arrow = that.pager.options.sort == s ? (parseInt(that.pager.options.desc) == 1 ? ' ↑' : ' ↓') : '';
|
|
242
271
|
var link = that.pager_hash({
|
|
243
272
|
sort: s,
|
|
244
|
-
desc: (that.
|
|
273
|
+
desc: (that.pager.options.sort == s ? (parseInt(that.pager.options.desc) == 1 ? '0' : '1') : '0')
|
|
245
274
|
});
|
|
246
275
|
|
|
247
276
|
var input = $('<input/>').attr('type', 'checkbox').attr('id', 'quick_edit_' + field.name).val(field.name)
|
|
@@ -326,7 +355,7 @@ IndexTable.prototype = {
|
|
|
326
355
|
column_checkboxes: function()
|
|
327
356
|
{
|
|
328
357
|
var that = this;
|
|
329
|
-
var div = $('<div/>').attr('id', '
|
|
358
|
+
var div = $('<div/>').attr('id', that.container + '_columns');
|
|
330
359
|
$.each(this.fields, function(i, field) {
|
|
331
360
|
var input = $('<input/>')
|
|
332
361
|
.attr('type', 'checkbox')
|
|
@@ -471,22 +500,22 @@ IndexTable.prototype = {
|
|
|
471
500
|
});
|
|
472
501
|
},
|
|
473
502
|
|
|
474
|
-
|
|
503
|
+
pager_div: function(summary)
|
|
475
504
|
{
|
|
476
505
|
var that = this;
|
|
477
|
-
var
|
|
506
|
+
var p = this.pager;
|
|
478
507
|
|
|
479
|
-
// Set default parameter values if not present
|
|
480
|
-
if (!
|
|
481
|
-
if (!
|
|
508
|
+
// Set default parameter values if not present
|
|
509
|
+
if (!p.options.items_per_page) p.options.items_per_page = 10
|
|
510
|
+
if (!p.options.page) p.options.page = 1
|
|
482
511
|
|
|
483
|
-
var page = parseInt(
|
|
512
|
+
var page = parseInt(p.options.page);
|
|
484
513
|
|
|
485
514
|
// Max links to show (must be odd)
|
|
486
515
|
var total_links = 5;
|
|
487
516
|
var prev_page = page - 1;
|
|
488
517
|
var next_page = page + 1;
|
|
489
|
-
var total_pages = Math.ceil(parseFloat(
|
|
518
|
+
var total_pages = Math.ceil(parseFloat(p.options.item_count)/parseFloat(p.options.items_per_page));
|
|
490
519
|
var start = 1;
|
|
491
520
|
var stop = 1;
|
|
492
521
|
|
|
@@ -517,35 +546,114 @@ IndexTable.prototype = {
|
|
|
517
546
|
{
|
|
518
547
|
var div2 = $('<div/>').addClass('page_links');
|
|
519
548
|
if (page > 1)
|
|
520
|
-
div2.append($('<a/>').attr('href', this.pager_hash({ page: prev_page })).html('Previous'));
|
|
549
|
+
div2.append($('<a/>').attr('href', this.pager_hash({ page: prev_page })).html('Previous').click(function(e) { that.hash_click(e, this); }));
|
|
521
550
|
for (i=start; i<=stop; i++)
|
|
522
551
|
{
|
|
523
552
|
if (page != i)
|
|
524
|
-
div2.append($('<a/>').attr('href', this.pager_hash({ page: i })).html(i));
|
|
553
|
+
div2.append($('<a/>').attr('href', this.pager_hash({ page: i })).html(i).click(function(e) { that.hash_click(e, this); }));
|
|
525
554
|
else
|
|
526
555
|
div2.append($('<span/>').addClass('current_page').html(i));
|
|
527
556
|
}
|
|
528
557
|
if (page < total_pages)
|
|
529
|
-
div2.append($('<a/>').attr('href', this.pager_hash({ page: next_page })).html('Next'));
|
|
558
|
+
div2.append($('<a/>').attr('href', this.pager_hash({ page: next_page })).html('Next').click(function(e) { that.hash_click(e, this); }));
|
|
530
559
|
div.append(div2);
|
|
531
560
|
}
|
|
532
561
|
return div;
|
|
533
562
|
},
|
|
534
563
|
|
|
535
|
-
|
|
564
|
+
hash_click: function(e, el) {
|
|
565
|
+
e.preventDefault();
|
|
566
|
+
e.stopPropagation();
|
|
567
|
+
window.location.hash = $(el).attr('href').substr(1);
|
|
568
|
+
this.refresh();
|
|
569
|
+
},
|
|
570
|
+
|
|
571
|
+
pager_params: function(h)
|
|
536
572
|
{
|
|
537
|
-
var that = this;
|
|
538
|
-
var
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
573
|
+
var that = this;
|
|
574
|
+
var p = $.extend({}, this.pager.params);
|
|
575
|
+
if (this.pager.options)
|
|
576
|
+
{
|
|
577
|
+
if (this.pager.options.sort) p.sort = this.pager.options.sort;
|
|
578
|
+
if (this.pager.options.desc) p.desc = this.pager.options.desc ? 1 : 0;
|
|
579
|
+
if (this.pager.options.page) p.page = this.pager.options.page;
|
|
580
|
+
}
|
|
581
|
+
if (h)
|
|
582
|
+
{
|
|
583
|
+
for (var i in h)
|
|
584
|
+
{
|
|
585
|
+
//console.log('' + i + ' = ' + h[i]);
|
|
586
|
+
//console.log(typeof(h[i]));
|
|
587
|
+
//console.log('-------------------');
|
|
588
|
+
if (typeof(h[i]) == 'boolean')
|
|
589
|
+
p[i] = h[i] ? 1 : 0;
|
|
590
|
+
else
|
|
591
|
+
p[i] = h[i];
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return p;
|
|
595
|
+
},
|
|
596
|
+
|
|
597
|
+
pager_hash: function(h)
|
|
598
|
+
{
|
|
599
|
+
var p = this.pager_params(h);
|
|
542
600
|
var qs = [];
|
|
543
|
-
$.each(
|
|
544
|
-
if (k == 'base_url' || k == 'item_count' || k == 'items_per_page' || k == 'use_url_params')
|
|
545
|
-
return;
|
|
546
|
-
qs.push('' + k + '=' + encodeURIComponent(v));
|
|
547
|
-
});
|
|
601
|
+
$.each(p, function(k,v) { qs.push('' + k + '=' + encodeURIComponent(v)); });
|
|
548
602
|
return '#' + qs.join('&');
|
|
549
|
-
}
|
|
603
|
+
},
|
|
604
|
+
|
|
605
|
+
/****************************************************************************/
|
|
606
|
+
|
|
607
|
+
new_model_link: function()
|
|
608
|
+
{
|
|
609
|
+
var that = this;
|
|
610
|
+
return $('<a/>').attr('href', '#').html(that.new_model_text).click(function(e) { e.preventDefault(); that.new_form(); });
|
|
611
|
+
},
|
|
612
|
+
|
|
613
|
+
new_form: function()
|
|
614
|
+
{
|
|
615
|
+
var that = this;
|
|
616
|
+
if (!$('#' + that.container + '_new_form_container').is(':empty'))
|
|
617
|
+
{
|
|
618
|
+
$('#' + that.container + '_new_form_container').slideUp(function() {
|
|
619
|
+
$('#' + that.container + '_new_form_container').empty();
|
|
620
|
+
});
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
var form = $('<form/>').attr('id', 'new_form')
|
|
625
|
+
.append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(that.form_authenticity_token));
|
|
626
|
+
$.each(this.new_model_fields, function(i, f) {
|
|
627
|
+
form.append($('<p/>').append($('<input/>').attr('type', 'text').attr('name', f.name).attr('placeholder', f.nice_name).css('width', '' + f.width + 'px')));
|
|
628
|
+
});
|
|
629
|
+
form
|
|
630
|
+
.append($('<div/>').attr('id', 'new_message'))
|
|
631
|
+
.append($('<p>')
|
|
632
|
+
.append($('<input/>').attr('type', 'button').val('Cancel').click(function(e) { $('#' + that.container + '_new_form_container').empty(); }))
|
|
633
|
+
.append(' ')
|
|
634
|
+
.append($('<input/>').attr('type', 'submit').val('Add').click(function(e) { that.add_model(); return false; }))
|
|
635
|
+
);
|
|
636
|
+
$('#' + that.container + '_new_form_container').hide().empty().append(
|
|
637
|
+
$('<div/>').addClass('note').css('margin-bottom', '10px')
|
|
638
|
+
.append($('<h2/>').css('margin-top', 0).css('padding-top', 0).html(that.new_model_text))
|
|
639
|
+
.append(form)
|
|
640
|
+
).slideDown();
|
|
641
|
+
},
|
|
642
|
+
|
|
643
|
+
add_model: function()
|
|
644
|
+
{
|
|
645
|
+
var that = this;
|
|
646
|
+
$('#new_message').html("<p class='loading'>Adding...</p>");
|
|
647
|
+
$.ajax({
|
|
648
|
+
url: this.add_url,
|
|
649
|
+
type: 'post',
|
|
650
|
+
data: $('#new_form').serialize(),
|
|
651
|
+
success: function(resp) {
|
|
652
|
+
if (resp.error) $('#new_message').html("<p class='note error'>" + resp.error + "</p>");
|
|
653
|
+
if (resp.redirect || resp.refresh) that.refresh();
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
},
|
|
657
|
+
|
|
550
658
|
|
|
551
659
|
};
|
|
@@ -12,7 +12,6 @@ bt = @block_type
|
|
|
12
12
|
<p><div id='blocktype_<%= bt.id %>_description' ></div></p>
|
|
13
13
|
|
|
14
14
|
<h2>Children</h2>
|
|
15
|
-
<p><a href='/admin/block-types/<%= @block_type.id %>/new'>New Child Block</a></p>
|
|
16
15
|
<div id='block_types'></div>
|
|
17
16
|
|
|
18
17
|
<h2>Advanced</h2>
|
|
@@ -82,9 +81,10 @@ $(document).ready(function() {
|
|
|
82
81
|
container: 'block_types',
|
|
83
82
|
base_url: '/admin/block-types',
|
|
84
83
|
refresh_url: '/admin/block-types/json?parent_id=<%= @block_type.id %>',
|
|
84
|
+
add_url: '/admin/block-types?parent_id=<%= @block_type.id %>',
|
|
85
85
|
allow_bulk_edit: false,
|
|
86
86
|
allow_bulk_delete: false,
|
|
87
|
-
allow_duplicate: false,
|
|
87
|
+
allow_duplicate: false,
|
|
88
88
|
fields: [
|
|
89
89
|
{ name: 'parent_id' , sort: 'parent_id' , show: false , bulk_edit: false, nice_name: 'Parent' , type: 'select' , value: function(bt) { return bt.parent_id; }, width: 400, options_url: '/admin/block-types/tree-options' },
|
|
90
90
|
{ name: 'name' , sort: 'name' , show: true , bulk_edit: false, nice_name: 'Name' , type: 'text' , value: function(bt) { return bt.name; }, width: 400 },
|
|
@@ -104,14 +104,18 @@ $(document).ready(function() {
|
|
|
104
104
|
{ name: 'options_url' , sort: 'options_url' , show: false , bulk_edit: false, nice_name: 'Options URL' , type: 'text' , value: function(bt) { return bt.options_url; }, width: 400 },
|
|
105
105
|
{ name: 'options_function' , sort: 'options_function' , show: false , bulk_edit: false, nice_name: 'Options Function' , type: 'textarea' , value: function(bt) { return bt.options_function; }, width: 400, height: 100 },
|
|
106
106
|
{ name: 'options' , sort: 'options' , show: false , bulk_edit: false, nice_name: 'Options' , type: 'textarea' , value: function(bt) { return bt.options; }, width: 400, height: 100 }
|
|
107
|
-
]
|
|
107
|
+
],
|
|
108
|
+
new_model_text: 'New Child Block',
|
|
109
|
+
new_model_fields: [
|
|
110
|
+
{ name: 'name', nice_name: 'Name', type: 'text', width: 400 }
|
|
111
|
+
],
|
|
108
112
|
});
|
|
109
113
|
|
|
110
114
|
m = new ModelBinder({
|
|
111
115
|
name: 'BlockType',
|
|
112
116
|
id: <%= @block_type.id %>,
|
|
113
117
|
update_url: '/admin/block-types/<%= @block_type.id %>',
|
|
114
|
-
authenticity_token: '<%= form_authenticity_token %>',
|
|
118
|
+
authenticity_token: '<%= form_authenticity_token %>',
|
|
115
119
|
attributes: [
|
|
116
120
|
{ name: 'parent_id' , nice_name: 'Parent' , type: 'select' , value: <%= raw Caboose.json(bt.parent_id) %>, width: 400, options_url: '/admin/block-types/tree-options' },
|
|
117
121
|
{ name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(bt.name) %>, width: 400 },
|
|
@@ -4,12 +4,9 @@
|
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
6
|
<h1>Block Types</h1>
|
|
7
|
-
|
|
8
|
-
<p>
|
|
9
|
-
<a href='/admin/block-types/store'>Block Type Store</a> |
|
|
10
|
-
<a href='/admin/block-types/new'>New Block Type</a>
|
|
11
|
-
</p>
|
|
7
|
+
<p><a href='/admin/block-types/store'>Block Type Store</a></p>
|
|
12
8
|
<div id='block_types'></div>
|
|
9
|
+
<% (0..100).each do |i| %><p> </p><% end %>
|
|
13
10
|
|
|
14
11
|
<% content_for :caboose_js do %>
|
|
15
12
|
<%= javascript_include_tag 'caboose/model/all' %>
|
|
@@ -21,27 +18,31 @@ $(document).ready(function() {
|
|
|
21
18
|
form_authenticity_token: '<%= form_authenticity_token %>',
|
|
22
19
|
container: 'block_types',
|
|
23
20
|
base_url: '/admin/block-types',
|
|
24
|
-
fields: [
|
|
25
|
-
{ name: '
|
|
26
|
-
{ name: '
|
|
27
|
-
{ name: '
|
|
28
|
-
{ name: 'site_id' , sort: 'site_id' , show:
|
|
29
|
-
{ name: '
|
|
30
|
-
{ name: '
|
|
31
|
-
{ name: '
|
|
32
|
-
{ name: '
|
|
33
|
-
{ name: '
|
|
34
|
-
{ name: '
|
|
35
|
-
{ name: '
|
|
36
|
-
{ name: '
|
|
37
|
-
{ name: 'default' , sort: 'default' , show: false , bulk_edit: false, nice_name: 'Default value' , type: 'text' , value: function(bt) { return bt.default;
|
|
38
|
-
{ name: 'width' , sort: 'width' , show: false , bulk_edit: false, nice_name: 'Width' , type: 'text' , value: function(bt) { return bt.width;
|
|
39
|
-
{ name: 'height' , sort: 'height' , show: false , bulk_edit: false, nice_name: 'Height' , type: 'text' , value: function(bt) { return bt.height;
|
|
40
|
-
{ name: 'fixed_placeholder' , sort: 'fixed_placeholder' , show: false , bulk_edit: false, nice_name: 'Fixed placeholder' , type: 'checkbox' , value: function(bt) { return bt.fixed_placeholder;
|
|
41
|
-
{ name: 'options_url' , sort: 'options_url' , show: false , bulk_edit: false, nice_name: 'Options URL' , type: 'text' , value: function(bt) { return bt.options_url;
|
|
42
|
-
{ name: 'options_function' , sort: 'options_function' , show: false , bulk_edit: false, nice_name: 'Options Function' , type: 'textarea' , value: function(bt) { return bt.options_function;
|
|
43
|
-
{ name: 'options' , sort: 'options' , show: false , bulk_edit: false, nice_name: 'Options' , type: 'textarea' , value: function(bt) { return bt.options;
|
|
44
|
-
]
|
|
21
|
+
fields: [
|
|
22
|
+
{ name: 'name' , sort: 'name' , show: true , bulk_edit: false, nice_name: 'Name' , type: 'text' , value: function(bt) { return bt.name; }, width: 400 },
|
|
23
|
+
{ name: 'description' , sort: 'description' , show: false , bulk_edit: false, nice_name: 'Description' , type: 'text' , value: function(bt) { return bt.description; }, width: 400 },
|
|
24
|
+
{ name: 'field_type' , sort: 'field_type' , show: true , bulk_edit: false, nice_name: 'Field type' , type: 'select' , value: function(bt) { return bt.field_type; }, width: 400, options_url: '/admin/block-types/field-type-options' },
|
|
25
|
+
{ name: 'site_id' , sort: 'site_id' , show: false , bulk_edit: false, nice_name: 'Site' , type: 'checkbox-multiple' , value: function(bt) { return bt.sites ? bt.sites.map(function(s) { return s.id }) : []; }, text: function(bt) { return bt.sites ? bt.sites.map(function(s) { return s.description }).join(', ') : ''; }, width: 400, height: 200, options_url: '/admin/block-types/site-options' },
|
|
26
|
+
{ name: 'parent_id' , sort: 'parent_id' , show: false , bulk_edit: false, nice_name: 'Parent' , type: 'select' , value: function(bt) { return bt.parent_id; }, width: 400, options_url: '/admin/block-types/tree-options' },
|
|
27
|
+
{ name: 'block_type_category_id' , sort: 'block_type_category_id' , show: false , bulk_edit: false, nice_name: 'Category' , type: 'select' , value: function(bt) { return bt.block_type_category_id; }, width: 400, options_url: '/admin/block-type-categories/tree-options' },
|
|
28
|
+
{ name: 'is_global' , sort: 'is_global' , show: false , bulk_edit: false, nice_name: 'Global' , type: 'checkbox' , value: function(bt) { return bt.is_global ? 'Yes' : 'No'; }, width: 20 },
|
|
29
|
+
{ name: 'use_render_function' , sort: 'use_render_function' , show: true , bulk_edit: false, nice_name: 'Use Render Function' , type: 'checkbox' , value: function(bt) { return bt.use_render_function ? 'Yes' : 'No' }, width: 20 },
|
|
30
|
+
{ name: 'use_render_function_for_layout' , sort: 'use_render_function_for_layout' , show: true , bulk_edit: false, nice_name: 'Use Render Function for Layout' , type: 'checkbox' , value: function(bt) { return bt.use_render_function_for_layout ? 'Yes' : 'No' }, width: 20 },
|
|
31
|
+
{ name: 'allow_child_blocks' , sort: 'allow_child_blocks' , show: true , bulk_edit: false, nice_name: 'Allow Child Blocks' , type: 'checkbox' , value: function(bt) { return bt.allow_child_blocks ? 'Yes' : 'No' }, width: 20 },
|
|
32
|
+
{ name: 'default_child_block_type_id' , sort: 'default_child_block_type_id' , show: false , bulk_edit: false, nice_name: 'Default Child Block Type' , type: 'select' , value: function(bt) { return bt.default_child_block_type_id; }, width: 400, options_url: '/admin/block-types/options' },
|
|
33
|
+
{ name: 'render_function' , sort: 'render_function' , show: false , bulk_edit: false, nice_name: 'Render Function' , type: 'textarea' , value: function(bt) { return bt.render_function; }, width: 800, height: 200 },
|
|
34
|
+
{ name: 'default' , sort: 'default' , show: false , bulk_edit: false, nice_name: 'Default value' , type: 'text' , value: function(bt) { return bt.default; }, width: 400 },
|
|
35
|
+
{ name: 'width' , sort: 'width' , show: false , bulk_edit: false, nice_name: 'Width' , type: 'text' , value: function(bt) { return bt.width; }, width: 400 },
|
|
36
|
+
{ name: 'height' , sort: 'height' , show: false , bulk_edit: false, nice_name: 'Height' , type: 'text' , value: function(bt) { return bt.height; }, width: 400 },
|
|
37
|
+
{ name: 'fixed_placeholder' , sort: 'fixed_placeholder' , show: false , bulk_edit: false, nice_name: 'Fixed placeholder' , type: 'checkbox' , value: function(bt) { return bt.fixed_placeholder ? 'Yes' : 'No'; }, width: 400 },
|
|
38
|
+
{ name: 'options_url' , sort: 'options_url' , show: false , bulk_edit: false, nice_name: 'Options URL' , type: 'text' , value: function(bt) { return bt.options_url; }, width: 400 },
|
|
39
|
+
{ name: 'options_function' , sort: 'options_function' , show: false , bulk_edit: false, nice_name: 'Options Function' , type: 'textarea' , value: function(bt) { return bt.options_function; }, width: 400, height: 100 },
|
|
40
|
+
{ name: 'options' , sort: 'options' , show: false , bulk_edit: false, nice_name: 'Options' , type: 'textarea' , value: function(bt) { return bt.options; }, width: 400, height: 100 }
|
|
41
|
+
],
|
|
42
|
+
new_model_text: 'New Block Type',
|
|
43
|
+
new_model_fields: [
|
|
44
|
+
{ name: 'name', nice_name: 'Name', type: 'text', width: 400 }
|
|
45
|
+
],
|
|
45
46
|
});
|
|
46
47
|
});
|
|
47
48
|
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
<p><select name='block_type_id'>
|
|
9
9
|
<option value=''>-- Select a layout --</option>
|
|
10
10
|
<% cat_ids = Caboose::BlockTypeCategory.layouts.collect{ |cat| cat.id } %>
|
|
11
|
-
<% Caboose::BlockType.where("block_type_category_id in (?)", cat_ids).reorder(:description).all.each do |bt| %>
|
|
12
|
-
<% next if bt.site_id && bt.site_id != @site.id %>
|
|
11
|
+
<% Caboose::BlockType.includes(:block_type_site_memberships).where("block_type_category_id in (?) and block_type_site_memberships.site_id = ?", cat_ids, @site.id).reorder(:description).all.each do |bt| %>
|
|
13
12
|
<option value="<%= bt.id %>"><%= bt.description %></option>
|
|
14
13
|
<% end %>
|
|
15
14
|
</select></p>
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: caboose-cms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.150
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- William Barry
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-10-
|
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|