apostrophe-schemas
Advanced tools
Comparing version 0.5.41 to 0.5.42
{ | ||
"version": "0.5.41", | ||
"version": "0.5.42", | ||
"name": "apostrophe-schemas", | ||
@@ -4,0 +4,0 @@ "description": "Schemas for easy editing of properties in Apostrophe objects", |
function AposSchemas() { | ||
var self = this; | ||
// Populate form elements corresponding to a set of fields as specified in a schema | ||
// (the schema argument). The inverse of self.convertSomeFields | ||
// Populate form elements corresponding to a set of fields as | ||
// specified in a schema (the schema argument). The inverse of | ||
// self.convertSomeFields | ||
self.populateFields = function($el, schema, snippet, callback) { | ||
// This is a workaround for the lack of async.each client side. | ||
// Think about bringing that into the browser. | ||
function populateField(i) { | ||
if (i >= schema.length) { | ||
return afterPopulateFields(callback); | ||
// return callback(null); | ||
} | ||
var field = schema[i]; | ||
return async.eachSeries(schema, function(field, callback) { | ||
@@ -20,14 +14,9 @@ // Utilized by simple displayers that use a simple HTML | ||
// If this field maps to a plain HTML element set the | ||
// required attribute when appropriate. See: | ||
// http://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript | ||
// for why I do it this way. | ||
if (field.contextual) { | ||
return apos.afterYield(callback); | ||
} | ||
// if (field.required && $field[0]) { | ||
// $field[0].required = true; | ||
// } | ||
var displayer = self.displayers[field.type]; | ||
// This is a hack to implement async.eachSeries. TODO: think about putting | ||
// the async module in the browser | ||
return self.displayers[field.type](snippet, field.name, $field, $el, field, function() { | ||
return displayer(snippet, field.name, $field, $el, field, function() { | ||
if (field.autocomplete === false) { | ||
@@ -37,13 +26,14 @@ $field.attr('autocomplete', 'off'); | ||
if(field.required === true) { | ||
self.addError($el, field.name, field.required); | ||
self.addError($el, field.name, true); | ||
} | ||
return populateField(i + 1); | ||
return apos.afterYield(callback); | ||
}); | ||
} | ||
function afterPopulateFields(callback) { | ||
}, afterPopulateFields); | ||
function afterPopulateFields() { | ||
// This function actually toggles the things based on data-show-fields of options in select | ||
function toggleHiddenFields($select){ | ||
var $hideFieldOptions = $select.find('option:not(:selected)'); | ||
@@ -64,3 +54,2 @@ | ||
var showFields = $select.find('option:selected').data('show-fields'); | ||
@@ -75,4 +64,2 @@ if (showFields && showFields.length > 0) { | ||
} | ||
} | ||
@@ -93,9 +80,6 @@ | ||
} | ||
}) | ||
}); | ||
callback(null); | ||
} | ||
return populateField(0); | ||
}; | ||
@@ -102,0 +86,0 @@ |
@@ -109,3 +109,3 @@ # apostrophe-schemas | ||
The `select` type accepts a `choices` option which should contain an array of objects with `value` and `label` properties. | ||
The `select` type accepts a `choices` option which should contain an array of objects with `value` and `label` properties. In addition to `value` and `label`, each choice option can include a `showFields` option, which can be used to toggle visibility of other fields when being edited. | ||
@@ -112,0 +112,0 @@ The `date` type pops up a jQuery UI datepicker when clicked on, and the `time` type tolerates many different ways of entering the time, like "1pm" or "1:00pm" and "13:00". |
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
0
103560
1398