From 4c426c2eb173c2b255003689791fa5583a2cbb40 Mon Sep 17 00:00:00 2001 From: Todd Jordan Date: Mon, 21 Mar 2016 01:30:35 -0400 Subject: [PATCH 1/3] give the ability to load custom renderers load alpaca renderer from its own file move alpaca renderer under forms dir add htmlbars compile to ember renderer --- addon/components/dynamic-form.js | 2 +- .../form-factories/ember-default.js | 12 ++++++++++++ addon/dynamic-forms/renderers/ember.js | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 addon/dynamic-forms/form-factories/ember-default.js create mode 100644 addon/dynamic-forms/renderers/ember.js diff --git a/addon/components/dynamic-form.js b/addon/components/dynamic-form.js index 523fd1d..817b640 100644 --- a/addon/components/dynamic-form.js +++ b/addon/components/dynamic-form.js @@ -31,7 +31,7 @@ const DynamicForm = Ember.Component.extend({ get(this, 'formRenderer').initLayout(this); }, - _render() { + __render() { Ember.Logger.debug('_render'); let renderer = get(this, 'formRenderer'); renderer.render(get(this, 'renderSchema'), this); diff --git a/addon/dynamic-forms/form-factories/ember-default.js b/addon/dynamic-forms/form-factories/ember-default.js new file mode 100644 index 0000000..fbd1588 --- /dev/null +++ b/addon/dynamic-forms/form-factories/ember-default.js @@ -0,0 +1,12 @@ +import Ember from 'ember'; + +const TYPE_MAP = { + text: '', + radio: '' +}; + +export default Ember.Object.extend({ + componentFor(type) { + + } +}); diff --git a/addon/dynamic-forms/renderers/ember.js b/addon/dynamic-forms/renderers/ember.js new file mode 100644 index 0000000..316b558 --- /dev/null +++ b/addon/dynamic-forms/renderers/ember.js @@ -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 + } +}); From c43f1568ecf27168d54cfb241420d749ef489cdf Mon Sep 17 00:00:00 2001 From: Todd Jordan Date: Tue, 2 Aug 2016 15:38:07 -0400 Subject: [PATCH 2/3] intermediate work on renderer --- addon/dynamic-forms/renderers/ember.js | 5 ++--- app/dynamic-forms/renderers/ember.js | 3 +++ tests/dummy/config/environment.js | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 app/dynamic-forms/renderers/ember.js diff --git a/addon/dynamic-forms/renderers/ember.js b/addon/dynamic-forms/renderers/ember.js index 316b558..8fdf1fa 100644 --- a/addon/dynamic-forms/renderers/ember.js +++ b/addon/dynamic-forms/renderers/ember.js @@ -2,11 +2,10 @@ import Ember from 'ember'; export default Ember.Object.extend({ render(schema, component) { + Ember.Logger.debug('render!'); component.set('layout', Ember.computed(function () { return Ember.HTMLBars.compile(` - {{#each fields as |field|}} - {{component field.type}} - {{/each}} + hello world `); })); // iterate fields in schema diff --git a/app/dynamic-forms/renderers/ember.js b/app/dynamic-forms/renderers/ember.js new file mode 100644 index 0000000..faccafd --- /dev/null +++ b/app/dynamic-forms/renderers/ember.js @@ -0,0 +1,3 @@ +import Ember from 'ember-cli-dynamic-forms/dynamic-forms/renderers/ember'; + +export default Ember; diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js index 86aadda..ff06f9f 100644 --- a/tests/dummy/config/environment.js +++ b/tests/dummy/config/environment.js @@ -45,5 +45,9 @@ module.exports = function(environment) { } + ENV.dynamicForms = { + renderer: 'ember' + }; + return ENV; }; From 90d1b4ee198eb09059e8763fbc36b89e5a56ce04 Mon Sep 17 00:00:00 2001 From: Todd Jordan Date: Fri, 19 Aug 2016 19:34:31 -0400 Subject: [PATCH 3/3] fix bad merge fix merge part duex --- addon/components/dynamic-form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/components/dynamic-form.js b/addon/components/dynamic-form.js index 817b640..523fd1d 100644 --- a/addon/components/dynamic-form.js +++ b/addon/components/dynamic-form.js @@ -31,7 +31,7 @@ const DynamicForm = Ember.Component.extend({ get(this, 'formRenderer').initLayout(this); }, - __render() { + _render() { Ember.Logger.debug('_render'); let renderer = get(this, 'formRenderer'); renderer.render(get(this, 'renderSchema'), this);