Skip to content

Commit ddfec4f

Browse files
committed
Merge branch 'master' into replace-renderer
2 parents 7117474 + 9cbfdbf commit ddfec4f

File tree

5 files changed

+53
-22
lines changed

5 files changed

+53
-22
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ For more details component usage and asset generation, see the [ember-cli-dynami
3838

3939
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.
4040

41+
## Excluding Assets
42+
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.
43+
44+
```js
45+
var app = new EmberApp({
46+
'ember-cli-dynamic-forms': {
47+
includeAssets: false, // disables the includion of all assets
48+
includeBootstrapAssets: false // disables just the inclusion of bootstrap assets whilst leaving the rest inplace
49+
}
50+
});
51+
```
52+
4153
## Development
4254

4355
### Setup

addon/components/dynamic-form.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ const DynamicForm = Ember.Component.extend({
2727
} else {
2828
set(this, 'formRenderer', container.lookup('alpaca:dynamic-forms.renderers'));
2929
}
30+
get(this, 'formRenderer').initLayout(this);
3031
},
3132

3233
_render() {
3334
Ember.Logger.debug('_render');
3435
let renderer = get(this, 'formRenderer');
35-
renderer.render(get(this, 'renderSchema'), this.$());
36+
renderer.render(get(this, 'renderSchema'), this);
3637
},
3738

3839
didInsertElement() {
+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import Ember from 'ember';
22

33
export default Ember.Object.extend({
4+
5+
initLayout(/*component*/) {
6+
// no template for alpaca
7+
},
8+
49
render(schema, component) {
5-
component.$().empty();
6-
component.$().alpaca(schema);
10+
let element = component.$();
11+
element.empty();
12+
element.alpaca(schema);
713
}
814
});

index.js

+30-18
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,42 @@ module.exports = {
55
name: 'ember-cli-dynamic-forms',
66
included: function (app) {
77
this._super.included(app);
8+
9+
app.options = app.options || {}; // ensure options is actually set to prevent undefined errors
10+
var options = app.options['ember-cli-dynamic-forms'] || {}; // ensure we have an options object at the very least
11+
12+
// opt out early if we don't want any assets
13+
if('includeAssets' in options && !options.includeAssets) {
14+
return;
15+
}
16+
817
app.import(app.bowerDirectory + '/handlebars/handlebars.js');
9-
app.import(app.bowerDirectory + '/bootstrap/dist/js/bootstrap.js');
10-
app.import(app.bowerDirectory + '/bootstrap/dist/css/bootstrap.css');
11-
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff', {
12-
destDir: 'fonts'
13-
});
14-
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', {
15-
destDir: 'fonts'
16-
});
17-
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg', {
18-
destDir: 'fonts'
19-
});
20-
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf', {
21-
destDir: 'fonts'
22-
});
23-
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2', {
24-
destDir: 'fonts'
25-
});
18+
19+
// include bootstrap assets unless explicitly told otherwise
20+
if(!('includeBootstrapAssets' in options) || options.includeBootstrapAssets) {
21+
app.import(app.bowerDirectory + '/bootstrap/dist/js/bootstrap.js');
22+
app.import(app.bowerDirectory + '/bootstrap/dist/css/bootstrap.css');
23+
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff', {
24+
destDir: 'fonts'
25+
});
26+
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', {
27+
destDir: 'fonts'
28+
});
29+
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg', {
30+
destDir: 'fonts'
31+
});
32+
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf', {
33+
destDir: 'fonts'
34+
});
35+
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2', {
36+
destDir: 'fonts'
37+
});
38+
}
2639

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

31-
3244
},
3345
isDevelopingAddon: function () {
3446
return true;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-cli-dynamic-forms",
3-
"version": "0.1.3",
3+
"version": "0.2.0",
44
"description": "An Ember addon for creating dynamic forms",
55
"directories": {
66
"doc": "doc",

0 commit comments

Comments
 (0)