This repository has been archived by the owner. It is now read-only.
angular-formly plugin for siren action
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
.editorconfig
.eslintrc
.gitignore
LICENSE
README.md
apiary.apib
index.js
package.json

README.md

angular-formly-siren-action

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!