apostrophe-schema-widgets
Advanced tools
Comparing version 0.5.1 to 0.5.2
16
index.js
@@ -50,6 +50,16 @@ var _ = require('lodash'); | ||
}; | ||
widget.load = function(req, item, callback) { | ||
// TODO: carry out joins in the schema, including | ||
// those nested in arrays | ||
return callback(null); | ||
if (req.aposSchemaWidgetLoading) { | ||
// Refuse to do perform joins through two levels of schema widgets. | ||
// This prevents a number of infinite loop scenarios. For this to | ||
// work properly page loaders should continue to run in series | ||
// rather than in parallel. -Tom | ||
return setImmediate(callback()); | ||
} | ||
req.aposSchemaWidgetLoading = true; | ||
return self._schemas.join(req, options.schema, item, undefined, function(err) { | ||
req.aposSchemaWidgetLoading = false; | ||
return setImmediate(_.partial(callback, err)); | ||
}); | ||
}; | ||
@@ -56,0 +66,0 @@ apos.addWidgetType(widget.name, widget); |
{ | ||
"name": "apostrophe-schema-widgets", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "An easy form widget builder for the Apostrophe content management system", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -100,1 +100,11 @@ # apostrophe-schema-widgets | ||
``` | ||
## Joins in Schema Widgets | ||
They work exactly like joins in snippet schemas. | ||
If the current page contains a schema widget which results in a join with another page or snippet that also contains a schema widget, the second schema widget does *not* complete its joins. This is necessary to prevent infinite loops. | ||
If you need nested joins, consider adding your joins to the [schema of a fancy page](https://github.com/punkave/apostrophe-fancy-pages) rather than using schema widgets. If you take this approach you can [use the `withJoins` option](https://github.com/punkave/apostrophe-schemas#nested-joins-you-gotta-be-explicit). | ||
8976
101
110