Skip to content

Commit

Permalink
Merge branch 'master' into replace-renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
toddjordan committed Sep 8, 2016
2 parents 7117474 + 9cbfdbf commit ddfec4f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 22 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ For more details component usage and asset generation, see the [ember-cli-dynami

The schema variable can be in string or object form, but needs to be a valid json-schema alpaca form definition. See the [alpacajs website](http://alpacajs.org) for more information about building valid schemas.

## Excluding Assets
By default ember-cli-dynamic-forms imports bootstrap and alpaca assets to the broccoli tree. If you wish to disable this behaviour and use your own assets, simply specify it in your ember-cli-build.js.

```js
var app = new EmberApp({
'ember-cli-dynamic-forms': {
includeAssets: false, // disables the includion of all assets
includeBootstrapAssets: false // disables just the inclusion of bootstrap assets whilst leaving the rest inplace
}
});
```

## Development

### Setup
Expand Down
3 changes: 2 additions & 1 deletion addon/components/dynamic-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ const DynamicForm = Ember.Component.extend({
} else {
set(this, 'formRenderer', container.lookup('alpaca:dynamic-forms.renderers'));
}
get(this, 'formRenderer').initLayout(this);
},

_render() {
Ember.Logger.debug('_render');
let renderer = get(this, 'formRenderer');
renderer.render(get(this, 'renderSchema'), this.$());
renderer.render(get(this, 'renderSchema'), this);
},

didInsertElement() {
Expand Down
10 changes: 8 additions & 2 deletions addon/dynamic-forms/renderers/alpaca.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import Ember from 'ember';

export default Ember.Object.extend({

initLayout(/*component*/) {
// no template for alpaca
},

render(schema, component) {
component.$().empty();
component.$().alpaca(schema);
let element = component.$();
element.empty();
element.alpaca(schema);
}
});
48 changes: 30 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,42 @@ module.exports = {
name: 'ember-cli-dynamic-forms',
included: function (app) {
this._super.included(app);

app.options = app.options || {}; // ensure options is actually set to prevent undefined errors
var options = app.options['ember-cli-dynamic-forms'] || {}; // ensure we have an options object at the very least

// opt out early if we don't want any assets
if('includeAssets' in options && !options.includeAssets) {
return;
}

app.import(app.bowerDirectory + '/handlebars/handlebars.js');
app.import(app.bowerDirectory + '/bootstrap/dist/js/bootstrap.js');
app.import(app.bowerDirectory + '/bootstrap/dist/css/bootstrap.css');
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2', {
destDir: 'fonts'
});

// include bootstrap assets unless explicitly told otherwise
if(!('includeBootstrapAssets' in options) || options.includeBootstrapAssets) {
app.import(app.bowerDirectory + '/bootstrap/dist/js/bootstrap.js');
app.import(app.bowerDirectory + '/bootstrap/dist/css/bootstrap.css');
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2', {
destDir: 'fonts'
});
}

app.import(app.bowerDirectory + '/alpaca/dist/alpaca/bootstrap/alpaca.js');
app.import(app.bowerDirectory + '/alpaca/dist/alpaca/bootstrap/alpaca.css');
app.import(app.bowerDirectory + '/lodash/lodash.js');


},
isDevelopingAddon: function () {
return true;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-cli-dynamic-forms",
"version": "0.1.3",
"version": "0.2.0",
"description": "An Ember addon for creating dynamic forms",
"directories": {
"doc": "doc",
Expand Down

0 comments on commit ddfec4f

Please sign in to comment.