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

add htmlbars compile to ember renderer
  • Loading branch information
toddjordan committed May 9, 2016
1 parent 24f2c65 commit bbd2028
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
6 changes: 3 additions & 3 deletions addon/components/dynamic-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ 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.$());
renderer.render(this.get('renderSchema'), this);
},

didReceiveAttrs() {
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) {

}
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';

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

export default Ember.Object.extend({
render(schema, component) {
component.set('layout', Ember.computed(function () {
return Ember.HTMLBars.compile(`
{{#each fields as |field|}}
{{component field.type}}
{{/each}}
`);
}));
// iterate fields in schema
//let fields = schema.schema.properties;

// 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 bbd2028

Please sign in to comment.