Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should allow ember components as custom form widgets. #23

Open
toddjordan opened this issue Feb 9, 2016 · 9 comments
Open

Should allow ember components as custom form widgets. #23

toddjordan opened this issue Feb 9, 2016 · 9 comments
Assignees

Comments

@toddjordan
Copy link
Owner

Currently alpaca allows you to "register" new form field widget types by extending their field objects. This issue is to explore what it might take to get it to use ember components as a widget.

Start here: http://www.alpacajs.org/docs/api/custom-fields.html

@toddjordan
Copy link
Owner Author

cc @jschilli

@jschilli
Copy link

@toddjordan have conversations queued up with my team to discuss - will advise

@toddjordan
Copy link
Owner Author

👍

@toddjordan
Copy link
Owner Author

I've started work on giving the addon the ability to render ember components. I started by giving it the concept of a renderer, currently with the default of alpaca. Second step is to take alpaca and its dependencies (including bootstrap) out of the mix.

@toddjordan
Copy link
Owner Author

toddjordan commented Aug 24, 2016

Update:
I'm back at this after some time off and I'm taking the following approach

A renderer will provide 2 functions:

  • initLayout(component) - should set the template for the dynamic form component
  • render(schema, component) - sets the values for the template based on the provided json schema
    I plan to update master this week with the hooks and cut a release if you want to play with your own components.

I'm Writing an ember-paper renderer and adding an example usage to the documentation examples. This will come in the next few weeks, but I'll try to update this periodically.

cc: @k3n @jschilli
Do you guys use open source components that we can try this approach out on?

@toddjordan
Copy link
Owner Author

toddjordan commented Aug 25, 2016

I've checked in updates to master that will allow a developer to hook in a custom renderer.

Custom renderer could be inserted as follows:
1.add a renderer object file to app/dynamic-forms/renderers/my-renderer.js

import Ember from 'ember';

export default Ember.Object.extend({
  initLayout(component) {
    //set the component's template via layout and layoutName
  },
  render(schema, component) {
    //set properties/actions for the template based on the schema
  }
}

2 implement renderer to render you components

3.set the new renderer as the current renderer in environment.js:

ENV.dynamicForms = {
  renderer: 'my-renderer'
}

@k3n
Copy link

k3n commented Sep 1, 2016

1.add a renderer object file to app/dynamic-forms/renderers/my-renderer.js

One note: I had to place the file in app/renderers for it to be found.

@toddjordan
Copy link
Owner Author

hmmm. will make an update to fix. Thanks

@toddjordan
Copy link
Owner Author

@k3n I've released version 0.2.0, which has the same functionality, but now wants you to load any custom renderer through the /dynamic-forms/renderers/ directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants