angular-formly-siren-action is an angular-formly plugin that will enable to forward Siren action payloads directly to angular-formly.
The usage is extremely simple:
//Import the function
import sirenFieldTransformer from 'angular-formly-siren-action'
//Pass it into the fieldTransform parameter
{
fieldTransform: sirenFieldTransformer
}
The actual mapping is very simple
export default function mapSirenToFormly(action) {
return action.fields.map(field => {
return {
type: action.name + '.' + field.type,
key: field.name,
defaultValue: field.value,
templateOptions: {
label: field.title || field.name
}
}
})
}
The default require
statement will take the ES5 version, traspiled used Babel. You can grab the original ES6 source requiring index.js
file from the npm package.
require('angular-formly-siren-action/index')
And it is based on Siren fields specification
Feel free to file an issue or a Pull request if something can be improved!