caboose-cms 0.5.9 → 0.5.10
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
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTY2ZTViY2Y3MTJiMzBlNmJkYzJjOWEzNDZlMWVmNzg3ZmJlMjYxYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWE3MmZkZDFmOWNjYjFmMjdkYmQxMzFiYWE0Y2I0ODlhODQ0NmUxNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTE4YWY0NzRjMjVkY2E3MThmNzgzNDZhNmJlNDMzOGZhNTNjNDZjZTVkMGEw
|
10
|
+
MzYwNzc0ZjI5ZjkzODkxOGNjZjM4MzMzMTAwODcyNWZkNDQyMjEzOTEyZTQ4
|
11
|
+
NzI0MzFkMjU2ZDQzYTdhNmUxYmU0M2E0YmZmNWE2OWYwYjRkNDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmI0YjE3ZGYzYzkwN2RkYmY4MmI3NGNmZWIwMDI0ZWJlMjk5ZTY3YzdhYjI0
|
14
|
+
N2ZmNGM5YmZhZDZmNmZjODkyNzg2YTFhYTYxNmEwOTc4NjA3NTkxY2M3NGZj
|
15
|
+
YjlhZmI0ZmQxNjg1OTQ3Zjk4MDAxNzcyZmM4MDY4N2U0ZGY0Y2Q=
|
@@ -8,37 +8,21 @@ IndexTable.prototype = {
|
|
8
8
|
|
9
9
|
form_authenticity_token: false,
|
10
10
|
|
11
|
-
// Container for the table
|
12
|
-
container: 'models',
|
13
|
-
|
14
11
|
// Base URL used for default refresh/update/delete/bulk URLs
|
15
12
|
base_url: false,
|
16
13
|
|
17
|
-
// Where to get
|
18
|
-
refresh_url: false,
|
19
|
-
refresh_single_url: false,
|
14
|
+
// Where to get json data for all the models
|
15
|
+
refresh_url: false,
|
20
16
|
|
21
17
|
// Where to send bulk updates
|
22
18
|
bulk_update_url: false,
|
23
19
|
|
24
20
|
// Where to send bulk deletes
|
25
21
|
bulk_delete_url: false,
|
26
|
-
|
27
|
-
// Where to send normal updates
|
28
|
-
// Example: function(model_id) { return '/admin/models/' + model_id; }
|
29
|
-
update_url: false,
|
30
|
-
|
31
|
-
// Where to send duplicate calls
|
32
|
-
// Example: function(model_id) { return '/admin/models/' + model_id + '/duplicate' },
|
33
|
-
duplicate_url: false,
|
34
22
|
|
35
23
|
// Where to post new models
|
36
24
|
add_url: false,
|
37
25
|
|
38
|
-
// What to do when a row is clicked
|
39
|
-
// Example: function (model_id) { return '/admin/models/' + model_id; }
|
40
|
-
row_click_handler: false,
|
41
|
-
|
42
26
|
// Array of fields you want to show in the table (given as model binder attributes with additional text and value functions)
|
43
27
|
// [{
|
44
28
|
// show: true,
|
@@ -54,68 +38,76 @@ IndexTable.prototype = {
|
|
54
38
|
// }]
|
55
39
|
fields: [],
|
56
40
|
|
57
|
-
|
58
|
-
|
41
|
+
//============================================================================
|
42
|
+
// Additional parameters
|
43
|
+
//============================================================================
|
44
|
+
|
45
|
+
// Container for the table
|
46
|
+
container: 'models',
|
47
|
+
|
48
|
+
// Where to get json data for a single model
|
49
|
+
refresh_single_url: function(model_id, it) { return it.base_url + '/' + model_id + '/json'; },
|
50
|
+
|
51
|
+
// Where to send normal updates
|
52
|
+
update_url: function(model_id, it) { return it.base_url + '/' + model_id; },
|
53
|
+
|
54
|
+
// Where to send duplicate calls
|
55
|
+
duplicate_url: function(model_id, it) { return it.base_url + '/' + model_id + '/duplicate'; },
|
56
|
+
|
57
|
+
// What to do when the edit button is clicked for a model
|
58
|
+
edit_click_handler: function(model_id, it) { window.location = it.base_url + '/' + model_id; },
|
59
|
+
|
60
|
+
// What to do when a row is click. Default is quick edit mode.
|
61
|
+
row_click_handler: function(model_id, it, e) {
|
62
|
+
if (it.quick_edit_model_id == model_id)
|
63
|
+
{
|
64
|
+
if ($(e.target).prop('tagName') == 'TD')
|
65
|
+
it.quick_edit_model_id = false;
|
66
|
+
else
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
else
|
70
|
+
it.quick_edit_model_id = model_id;
|
71
|
+
it.print();
|
72
|
+
},
|
59
73
|
|
60
74
|
allow_bulk_edit: true,
|
61
75
|
allow_bulk_delete: true,
|
62
76
|
allow_duplicate: true,
|
63
|
-
|
77
|
+
allow_advanced_edit: true,
|
64
78
|
no_models_text: "There are no models right now.",
|
65
79
|
new_model_text: 'New',
|
66
|
-
new_model_fields: [
|
67
|
-
{ name: 'name', nice_name: 'Name', type: 'text', width: 400 }
|
68
|
-
],
|
80
|
+
new_model_fields: [{ name: 'name', nice_name: 'Name', type: 'text', width: 400 }],
|
69
81
|
|
70
82
|
//============================================================================
|
71
|
-
// End of
|
83
|
+
// End of parameters
|
72
84
|
//============================================================================
|
73
85
|
|
74
|
-
models: [],
|
75
|
-
model_ids: [],
|
76
|
-
quick_edit_model_id: false, // The id of the model currently being edited
|
77
|
-
|
78
|
-
|
79
|
-
options: { page: 1 },
|
86
|
+
models: [], // The models we get from the server
|
87
|
+
model_ids: [], // IDs of currently selected models
|
88
|
+
quick_edit_model_id: false, // The id of the model currently being edited
|
89
|
+
pager: {
|
90
|
+
options: { page: 1 },
|
80
91
|
params: {}
|
81
92
|
},
|
82
93
|
|
94
|
+
// Constructor
|
83
95
|
init: function(params) {
|
84
96
|
for (var thing in params)
|
85
97
|
this[thing] = params[thing];
|
86
98
|
|
87
99
|
var that = this;
|
88
|
-
if (!this.refresh_url
|
89
|
-
if (!this.bulk_update_url
|
90
|
-
if (!this.bulk_delete_url
|
91
|
-
if (!this.add_url
|
92
|
-
|
93
|
-
if (!this.duplicate_url ) this.duplicate_url = function(model_id) { return that.base_url + '/' + model_id + '/duplicate'; };
|
94
|
-
if (!this.refresh_single_url) this.refresh_single_url = function(model_id) { return that.base_url + '/' + model_id + '/json'; };
|
95
|
-
if (!this.row_click_handler ) this.row_click_handler = function(model_id, e) {
|
96
|
-
if (that.quick_edit_model_id == model_id)
|
97
|
-
{
|
98
|
-
if ($(e.target).prop('tagName') == 'TD')
|
99
|
-
that.quick_edit_model_id = false;
|
100
|
-
else
|
101
|
-
return;
|
102
|
-
}
|
103
|
-
else
|
104
|
-
that.quick_edit_model_id = model_id;
|
105
|
-
that.print();
|
106
|
-
};
|
107
|
-
this.init_fields();
|
108
|
-
|
109
|
-
$(window).on('hashchange', function() { that.refresh(); });
|
110
|
-
this.refresh();
|
111
|
-
},
|
112
|
-
|
113
|
-
init_fields: function()
|
114
|
-
{
|
115
|
-
var that = this;
|
100
|
+
if (!this.refresh_url ) this.refresh_url = this.base_url + '/json';
|
101
|
+
if (!this.bulk_update_url ) this.bulk_update_url = this.base_url + '/bulk';
|
102
|
+
if (!this.bulk_delete_url ) this.bulk_delete_url = this.base_url + '/bulk';
|
103
|
+
if (!this.add_url ) this.add_url = this.base_url;
|
104
|
+
|
116
105
|
$.each(this.fields, function(i, f) {
|
117
106
|
if (f.editable == null) f.editable = true;
|
118
107
|
});
|
108
|
+
|
109
|
+
$(window).on('hashchange', function() { that.refresh(); });
|
110
|
+
this.refresh();
|
119
111
|
},
|
120
112
|
|
121
113
|
parse_querystring: function()
|
@@ -173,11 +165,11 @@ IndexTable.prototype = {
|
|
173
165
|
var that = this;
|
174
166
|
var $el = $('#' + this.container + '_columns').length > 0 ? $('#' + this.container + '_table_container') : $('#' + this.container);
|
175
167
|
$el.html("<p class='loading'>Refreshing...</p>");
|
176
|
-
$.ajax({
|
168
|
+
$.ajax({
|
177
169
|
url: that.refresh_url,
|
178
170
|
type: 'get',
|
179
171
|
data: that.pager_params(),
|
180
|
-
success: function(resp) {
|
172
|
+
success: function(resp) {
|
181
173
|
for (var thing in resp['pager'])
|
182
174
|
that.pager[thing] = resp['pager'][thing];
|
183
175
|
that.models = resp['models'];
|
@@ -186,16 +178,7 @@ IndexTable.prototype = {
|
|
186
178
|
var m = that.models[i];
|
187
179
|
m.id = parseInt(m.id);
|
188
180
|
}
|
189
|
-
that.print();
|
190
|
-
|
191
|
-
// Set the history state
|
192
|
-
//var qs = that.pager_querystring();
|
193
|
-
//if (that.refresh_count > 0 && qs != window.location.hash)
|
194
|
-
//{
|
195
|
-
// if(history.pushState) history.pushState(null, null, '#' + qs);
|
196
|
-
// else location.hash = '#' + qs;
|
197
|
-
//}
|
198
|
-
that.refresh_count += 1;
|
181
|
+
that.print();
|
199
182
|
},
|
200
183
|
error: function() { $('#' + this.container).html("<p class='note error'>Error retrieving data.</p>"); }
|
201
184
|
});
|
@@ -205,7 +188,7 @@ IndexTable.prototype = {
|
|
205
188
|
{
|
206
189
|
var that = this;
|
207
190
|
$.ajax({
|
208
|
-
url: that.refresh_single_url(model_id),
|
191
|
+
url: that.refresh_single_url(model_id, that),
|
209
192
|
type: 'get',
|
210
193
|
success: function(resp) {
|
211
194
|
for (var i=0; i<that.models.length; i++)
|
@@ -281,7 +264,7 @@ IndexTable.prototype = {
|
|
281
264
|
new ModelBinder({
|
282
265
|
name: 'Model',
|
283
266
|
id: m.id,
|
284
|
-
update_url: that.update_url(m.id),
|
267
|
+
update_url: that.update_url(m.id, that),
|
285
268
|
authenticity_token: that.form_authenticity_token,
|
286
269
|
attributes: [attrib]
|
287
270
|
});
|
@@ -290,13 +273,41 @@ IndexTable.prototype = {
|
|
290
273
|
}
|
291
274
|
},
|
292
275
|
|
276
|
+
all_models_selected: function()
|
277
|
+
{
|
278
|
+
var that = this;
|
279
|
+
var all_checked = true;
|
280
|
+
$.each(that.models, function(i, m) {
|
281
|
+
if (that.model_ids.indexOf(m.id) == -1)
|
282
|
+
{
|
283
|
+
all_checked = false;
|
284
|
+
return false;
|
285
|
+
}
|
286
|
+
});
|
287
|
+
return all_checked;
|
288
|
+
},
|
289
|
+
|
293
290
|
table_headers: function()
|
294
291
|
{
|
295
292
|
var that = this;
|
296
293
|
var tr = $('<tr/>');
|
297
294
|
|
298
|
-
if (this.allow_bulk_edit || this.allow_bulk_delete || this.allow_duplicate)
|
299
|
-
|
295
|
+
if (this.allow_bulk_edit || this.allow_bulk_delete || this.allow_duplicate)
|
296
|
+
{
|
297
|
+
var input = $('<input/>').attr('type', 'checkbox').attr('id', that.container + '_check_all').val(1)
|
298
|
+
.change(function() {
|
299
|
+
var checked = $(this).prop('checked');
|
300
|
+
that.model_ids = [];
|
301
|
+
$.each(that.models, function(i, m) {
|
302
|
+
$('#model_' + m.id).prop('checked', checked);
|
303
|
+
if (checked) that.model_ids.push(m.id);
|
304
|
+
});
|
305
|
+
});
|
306
|
+
input.prop('checked', that.all_models_selected());
|
307
|
+
tr.append($('<th/>').append(input));
|
308
|
+
}
|
309
|
+
if (this.allow_advanced_edit)
|
310
|
+
tr.append($('<th/>').html(' '));
|
300
311
|
|
301
312
|
$.each(this.fields, function(i, field) {
|
302
313
|
if (field.show)
|
@@ -351,14 +362,25 @@ IndexTable.prototype = {
|
|
351
362
|
if (checked && i == -1) that.model_ids.push(model_id);
|
352
363
|
if (!checked && i > -1) that.model_ids.splice(i, 1);
|
353
364
|
}
|
365
|
+
$('#' + that.container + '_check_all').prop('checked', that.all_models_selected());
|
354
366
|
});
|
355
367
|
if (that.model_ids.indexOf(m.id) > -1)
|
356
368
|
checkbox.prop('checked', 'true');
|
357
369
|
tr.append($('<td/>').append(checkbox));
|
358
|
-
}
|
370
|
+
}
|
371
|
+
if (this.allow_advanced_edit)
|
372
|
+
{
|
373
|
+
tr.append($('<td/>')
|
374
|
+
.addClass('edit_button')
|
375
|
+
.mouseover(function() { $(this).addClass('edit_button_over'); })
|
376
|
+
.mouseout( function() { $(this).removeClass('edit_button_over'); })
|
377
|
+
.click(function(e) { e.stopPropagation(); that.edit_click_handler(m.id, that, e); })
|
378
|
+
.append($('<span/>').addClass('ui-icon ui-icon-pencil'))
|
379
|
+
);
|
380
|
+
}
|
359
381
|
tr.click(function(e) {
|
360
382
|
var model_id = $(this).attr('id').replace('model_row_', '');
|
361
|
-
that.row_click_handler(model_id, e);
|
383
|
+
that.row_click_handler(model_id, that, e);
|
362
384
|
});
|
363
385
|
|
364
386
|
$.each(that.fields, function(j, field) {
|
@@ -513,7 +535,7 @@ IndexTable.prototype = {
|
|
513
535
|
}
|
514
536
|
$('#message').html("<p class='loading'>Duplicating...</p>");
|
515
537
|
$.ajax({
|
516
|
-
url: that.duplicate_url(that.model_ids[0]),
|
538
|
+
url: that.duplicate_url(that.model_ids[0], that),
|
517
539
|
type: 'post',
|
518
540
|
data: { count: count },
|
519
541
|
success: function(resp) {
|
@@ -291,6 +291,14 @@ select.fake option {
|
|
291
291
|
padding: 8px 12px;
|
292
292
|
}
|
293
293
|
|
294
|
+
#content table.data td.edit_button {
|
295
|
+
|
296
|
+
}
|
297
|
+
|
298
|
+
#content table.data td.edit_button_over {
|
299
|
+
background: #f9ad81 !important;
|
300
|
+
}
|
301
|
+
|
294
302
|
#content table.data tr:nth-child(even) td {
|
295
303
|
background-color: #efefef;
|
296
304
|
}
|
@@ -26,8 +26,9 @@ $(document).ready(function() {
|
|
26
26
|
container: 'products',
|
27
27
|
base_url: '/admin/products',
|
28
28
|
allow_bulk_edit: false,
|
29
|
-
allow_bulk_delete:
|
29
|
+
allow_bulk_delete: true,
|
30
30
|
allow_duplicate: false,
|
31
|
+
allow_advanced_edit: true,
|
31
32
|
fields: [
|
32
33
|
{ show: true , name: 'id' , nice_name: 'ID' , sort: 'id' , type: 'text' , value: function(p) { return p.id }, width: 500, editable: false },
|
33
34
|
{ show: true , name: 'title' , nice_name: 'Title' , sort: 'title' , type: 'text' , value: function(p) { return p.title }, width: 200 },
|
data/lib/caboose/version.rb
CHANGED