Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

formly-js/angular-formly-siren-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

angular-formly plugin for siren action

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published