Skip to content

Commit

Permalink
give the ability to load custom renderers
Browse files Browse the repository at this point in the history
load alpaca renderer from its own file

move alpaca renderer under forms dir
  • Loading branch information
toddjordan committed Apr 14, 2016
1 parent 24f2c65 commit f890166
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addon/components/dynamic-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const DynamicForm = Ember.Component.extend({
let renderer;
let config = container.resolveRegistration('config:environment');
if (config.dynamicForms && config.dynamicForms.renderer) {
renderer = container.lookup(`${config.dynamicForms.renderer}:renderers`);
renderer = container.lookup(`${config.dynamicForms.renderer}:dynamic-forms.renderers`);
} else {
renderer = container.lookup('alpaca:renderers');
renderer = container.lookup('alpaca:dynamic-forms.renderers');
}
renderer.render(this.get('renderSchema'), this.$());
},
Expand Down
12 changes: 12 additions & 0 deletions addon/dynamic-forms/form-factories/ember-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Ember from 'ember';

const TYPE_MAP = {
text: '',
radio: ''
};

export default Ember.Object.extend({
componentFor(type) {

}
});
7 changes: 7 additions & 0 deletions addon/dynamic-forms/renderers/alpaca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Ember from 'ember';

export default Ember.Object.extend({
render(schema, element) {
element.alpaca(schema);
}
})
11 changes: 11 additions & 0 deletions addon/dynamic-forms/renderers/ember.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Ember from 'ember';

export default Ember.Object.extend({
render(schema, element) {
// iterate fields in schema

// load component equivs from factory

// attach to DOM or parent component
}
});
3 changes: 3 additions & 0 deletions app/dynamic-forms/renderers/alpaca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Alpaca from 'ember-cli-dynamic-forms/dynamic-forms/renderers/alpaca';

export default Alpaca;

0 comments on commit f890166

Please sign in to comment.