caboose-cms 0.4.138 → 0.4.139
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjBjMzNkMmZmODk2YWQxOWNmNDFjZTAzZjU3NTY3ZDk3ZDBjNjA5NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzYxNjM1NzYzMDgwM2QyNWE3YzYzZWYxMzUzNGU5YTc4ODBhYzg4MQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGE5NmE5YThkOWY5ODkyOTY4Y2U2NWY1YjgxYjAwNTg5MDgyYTg4YjI4Yjc1
|
10
|
+
NzBiNDQyNTQ3NTQ2NGJjMjQ0OWU0MzkwMTY3OTU1YmM4ZDM4ODhjNzI2OWNk
|
11
|
+
NWIzZGVjNjMwNWFjMDI2YzhiMzE4NTE0MmZjODgzZjYzNTVlZTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzAzMmMxOTI5YmJlM2U3NGIwZmZlNjc3NWUwZTEwM2Y3ZWEzYWU3NGUyM2Jj
|
14
|
+
YmQzNWFjOWM4ZjE0NGZjMTQ1NTBmOGNlOGZjYjBjODc4ODIwZGFlNmM2NWQ2
|
15
|
+
M2RjY2M4Mjg1ODllMTE3ZWYzNzNhMDg5ZGQ3ODExODZlODg0ZDg=
|
@@ -27,7 +27,11 @@ BoundCheckboxMultiple = BoundControl.extend({
|
|
27
27
|
div.css('height', '' + this.attribute.height + 'px').css('overflow-y', 'scroll');
|
28
28
|
$('#'+this.el).wrap(div);
|
29
29
|
$('#'+this.el+'_container').empty();
|
30
|
-
|
30
|
+
if (this.attribute.value == null || this.attribute.value == false)
|
31
|
+
this.attribute.value = [];
|
32
|
+
if (typeof(this.attribute.value) == 'string')
|
33
|
+
this.attribute.value = this.attribute.value.split('|');
|
34
|
+
|
31
35
|
if (this.attribute.options_url)
|
32
36
|
{
|
33
37
|
ModelBinder.wait_for_options(this.attribute.options_url, function(options) {
|
@@ -45,7 +49,7 @@ BoundCheckboxMultiple = BoundControl.extend({
|
|
45
49
|
{
|
46
50
|
var all_checked = true
|
47
51
|
$.each(this.attribute.options, function(i, option) {
|
48
|
-
if (that.attribute.value.indexOf(option.value) == -1)
|
52
|
+
if (!that.attribute.value || that.attribute.value.indexOf(option.value) == -1)
|
49
53
|
{
|
50
54
|
all_checked = false;
|
51
55
|
return;
|
@@ -71,7 +75,7 @@ BoundCheckboxMultiple = BoundControl.extend({
|
|
71
75
|
);
|
72
76
|
}
|
73
77
|
$.each(that.attribute.options, function(i, option) {
|
74
|
-
var checked = that.attribute.value.indexOf(option.value) > -1;
|
78
|
+
var checked = that.attribute.value != false && that.attribute.value != null && that.attribute.value.indexOf(option.value) > -1;
|
75
79
|
tbody.append($('<tr/>')
|
76
80
|
.append($('<td/>')
|
77
81
|
.append($('<input/>')
|
@@ -96,7 +100,7 @@ BoundCheckboxMultiple = BoundControl.extend({
|
|
96
100
|
.append($('<td/>').append($('<label/>').attr('for', that.el + '_' + i).html(option.text)))
|
97
101
|
);
|
98
102
|
});
|
99
|
-
$('#'+this.el+'_container').append($('<table/>').addClass('data').append(tbody));
|
103
|
+
$('#'+this.el+'_container').append($('<table/>').addClass('data').addClass('checkbox_multiple').append(tbody));
|
100
104
|
},
|
101
105
|
|
102
106
|
edit: function() {
|
@@ -104,7 +108,12 @@ BoundCheckboxMultiple = BoundControl.extend({
|
|
104
108
|
},
|
105
109
|
|
106
110
|
save: function(value, checked) {
|
107
|
-
|
111
|
+
|
112
|
+
if (this.attribute.value == null || this.attribute.value == false)
|
113
|
+
this.attribute.value = [];
|
114
|
+
if (typeof(this.attribute.value) == 'string')
|
115
|
+
this.attribute.value = this.attribute.value.split('|');
|
116
|
+
|
108
117
|
var that = this;
|
109
118
|
var i = this.attribute.value.indexOf(value);
|
110
119
|
if (checked && i == -1) this.attribute.value.push(value);
|
@@ -267,14 +267,22 @@ module Caboose
|
|
267
267
|
when 'name' then b.name = v
|
268
268
|
when 'value' then
|
269
269
|
|
270
|
-
if b.block_type.is_global
|
271
|
-
b.
|
272
|
-
|
270
|
+
if b.block_type.is_global
|
271
|
+
if b.block_type.field_type == 'checkbox_multiple'
|
272
|
+
b.value = Block.parse_checkbox_multiple_value(b, v)
|
273
|
+
else
|
274
|
+
b.value = v
|
275
|
+
end
|
276
|
+
b.update_global_value(b.value, @site.id)
|
273
277
|
else
|
274
278
|
if Caboose::parse_richtext_blocks == true && b.block_type.field_type == 'richtext' && (b.name.nil? || b.name.strip.length == 0) && (b.block_type.name != 'richtext2')
|
275
279
|
b = RichTextBlockParser.parse(b, v, request.host_with_port)
|
276
|
-
else
|
277
|
-
b.
|
280
|
+
else
|
281
|
+
if b.block_type.field_type == 'checkbox_multiple'
|
282
|
+
b.value = Block.parse_checkbox_multiple_value(b, v)
|
283
|
+
else
|
284
|
+
b.value = v
|
285
|
+
end
|
278
286
|
end
|
279
287
|
end
|
280
288
|
end
|
data/app/models/caboose/block.rb
CHANGED
@@ -339,5 +339,18 @@ class Caboose::Block < ActiveRecord::Base
|
|
339
339
|
)", value, self.id, self.block_type_id, site_id]
|
340
340
|
ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, sql))
|
341
341
|
end
|
342
|
+
|
343
|
+
# Parses the value given for a checkbox multiple block
|
344
|
+
def self.parse_checkbox_multiple_value(b, arr)
|
345
|
+
current_value = b.value ? b.value.split('|') : []
|
346
|
+
v = arr[0]
|
347
|
+
checked = arr[1].to_i == 1
|
348
|
+
if checked && !current_value.include?(v)
|
349
|
+
current_value << v
|
350
|
+
elsif !checked && current_value.include?(v)
|
351
|
+
current_value.delete(v)
|
352
|
+
end
|
353
|
+
return current_value.join('|')
|
354
|
+
end
|
342
355
|
|
343
356
|
end
|
@@ -90,6 +90,7 @@ end
|
|
90
90
|
<style type='text/css'>
|
91
91
|
.block { border: #ccc 1px dotted; }
|
92
92
|
#block_<%= @block.id %>_block_type_id_container { }
|
93
|
+
#modal_content .checkbox_multiple input[type=checkbox] { position: relative !important; }
|
93
94
|
</style>
|
94
95
|
<% end %>
|
95
96
|
<% content_for :caboose_js do %>
|
data/lib/caboose/version.rb
CHANGED