apostrophe-schemas
Advanced tools
Comparing version 0.5.22 to 0.5.23
34
index.js
@@ -237,2 +237,16 @@ var async = require('async'); | ||
}, | ||
checkboxes: function(req, data, name, object, field, callback) { | ||
data[name] = self._apos.sanitizeString(data[name]).split(','); | ||
if (!typeof(data[name]) == 'array') { | ||
object[name] = []; | ||
return setImmediate(callback); | ||
} | ||
object[name] = _.filter(data[name], function(choice) { | ||
return _.contains(_.pluck(field.choices, 'value'), choice); | ||
}); | ||
return setImmediate(callback); | ||
}, | ||
select: function(req, data, name, snippet, field, callback) { | ||
@@ -353,3 +367,2 @@ snippet[name] = self._apos.sanitizeSelect(data[name], field.choices, field.def); | ||
} else if (attr.type === 'select') { | ||
validatedRelationship[attr.name] = self._apos.sanitizeSelect(e[attr.name], attr.choices); | ||
@@ -362,3 +375,3 @@ } else { | ||
}); | ||
return setImmediate(callback); | ||
return setImmediate(callback) | ||
}; | ||
@@ -376,2 +389,15 @@ | ||
self.converters.form.checkboxes = function(req, data, name, object, field, callback) { | ||
if (!typeof(data[name]) == 'array') { | ||
object[name] = []; | ||
return setImmediate(callback); | ||
} | ||
object[name] = _.filter(data[name], function(choice) { | ||
return _.contains(_.pluck(field.choices, 'value'), choice); | ||
}); | ||
return setImmediate(callback); | ||
}; | ||
// END CONVERTERS | ||
@@ -395,2 +421,6 @@ | ||
}, | ||
checkboxes: function(value, field, texts) { | ||
var silent = (field.silent === undefined) ? true : field.silent; | ||
texts.push({ weight: field.weight || 15, text: (value || []).join(' '), silent: silent }); | ||
}, | ||
select: function(value, field, texts) { | ||
@@ -397,0 +427,0 @@ var silent = (field.silent === undefined) ? true : field.silent; |
{ | ||
"version": "0.5.22", | ||
"version": "0.5.23", | ||
"name": "apostrophe-schemas", | ||
@@ -4,0 +4,0 @@ "description": "Schemas for easy editing of properties in Apostrophe objects", |
@@ -301,2 +301,17 @@ function AposSchemas() { | ||
}, | ||
checkboxes: function(data, name, $field, $el, field, callback) { | ||
var values = []; | ||
for (var c in field.choices) { | ||
var val = field.choices[c].value; | ||
var checked = $field.filter('[value="'+val+'"]').prop('checked'); | ||
if (checked) { | ||
values.push(val); | ||
} | ||
} | ||
data[name] = values; | ||
if (field.required && !data[name]) { | ||
return apos.afterYield(_.partial(callback, 'required')); | ||
} | ||
return apos.afterYield(callback); | ||
}, | ||
select: function(data, name, $field, $el, field, callback) { | ||
@@ -446,2 +461,8 @@ data[name] = $field.val(); | ||
}, | ||
checkboxes: function(data, name, $field, $el, field, callback) { | ||
for(var c in data[name]) { | ||
$el.find('input[name="'+name+'"][value="'+data[name][c]+'"]').prop('checked', true); | ||
} | ||
return apos.afterYield(callback); | ||
}, | ||
select: function(data, name, $field, $el, field, callback) { | ||
@@ -448,0 +469,0 @@ var $options = $field.find('option'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97835
30
1265
1