apostrophe-schema-widgets
Advanced tools
Comparing version 0.5.7 to 0.5.8
@@ -14,2 +14,3 @@ var _ = require('lodash'); | ||
var self = this; | ||
self.widgets = {}; | ||
self._apos = apos; | ||
@@ -19,2 +20,3 @@ self._app = app; | ||
self._options = options; | ||
self._pages = options.pages; | ||
self._apos.mixinModuleAssets(self, 'schema-widgets', __dirname, options); | ||
@@ -68,5 +70,6 @@ | ||
apos.addWidgetType(widget.name, widget); | ||
self.widgets[widget.name] = widget; | ||
}); | ||
return setImmediate(function() { return callback(null); }); | ||
return setImmediate(function() { return callback && callback(null); }); | ||
} |
{ | ||
"name": "apostrophe-schema-widgets", | ||
"version": "0.5.7", | ||
"version": "0.5.8", | ||
"description": "An easy form widget builder for the Apostrophe content management system", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -109,2 +109,38 @@ # apostrophe-schema-widgets | ||
## Extending Schema Widgets | ||
If you need a custom loader to fetch more data, just subclass the module in `lib/modules/apostrophe-schema-widgets/index.js`. Here's an example in which we want to do extra work for the schema widget named `menuBuilder`: | ||
```javascript | ||
module.exports = schemaWidgets; | ||
function schemaWidgets(options, callback) { | ||
return new schemaWidgets.SchemaWidgets(options, callback); | ||
} | ||
schemaWidgets.SchemaWidgets = function(options, callback) { | ||
var self = this; | ||
module.exports.Super.call(this, options, null); | ||
var superLoad = self.widgets.menuBuilder.load; | ||
self.widgets.menuBuilder.load = function(req, item, callback) { | ||
return superLoad(req, item, function(err) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
// Do your custom work here, add properties | ||
// to the item, then... | ||
return callback(null); | ||
}); | ||
}; | ||
if (callback) { | ||
process.nextTick(function() { return callback(null); }); | ||
} | ||
}; | ||
``` | ||
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
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
10052
102
146