Update register() API to take an object with a builder function instead of expect static data
benjaminapetersen opened this issue · comments
Ben Petersen commented
- if directive doesn't provide
extension-args="{{someData}}"
should still work with whatever the user passes (meaning if user opts to just return static data, should be fine) - update to use the builder function
- test with a multi-tiered data structure in the demo to ensure that this is clean
- ensure directives will re-render when data changes. scope should be 2-way binding.
Examples of how this should generally work:
extensionInputProvider.register('main', {
name: 'endpoint1',
builder: function(args) {
// should return static, promise or undefined
// promise to allow async
return $q.when([
foo.get(),
bar.get()
])
.then(function(fooData, barData) {
return [
// structured data goes here, is defined by the user
];
});
}
});
The user then can return structured data as desired. This should be more or less consistent with what exists now. Example:
[
{
type: 'link',
displayName: 'I can now customize this',
href: 'customizable via context',
onClick: function() {
// instead of href
},
show: true // optional simple way to show/hide. user could also just not create this object...
}
]
The directive responsible for output also needs to provide the data arguments that will be given to the
builder function to render the content:
<div
extension-output
extension-name="main"
extension-types="text link sanitize select"
extension-args="{{items}}"></div>
Ben Petersen commented
Updated via 1.1.0