Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
simonihmig committed Jun 22, 2016
0 parents commit c9dfae7
Show file tree
Hide file tree
Showing 50 changed files with 752 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "bower_components",
"analytics": false
}
34 changes: 34 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

[*.css]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions .ember-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
/**
Ember CLI sends analytics information by default. The data is completely
anonymous, but there are times when you might want to disable this behavior.

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false
}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp

# dependencies
/node_modules
/bower_components

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
/.idea
32 changes: 32 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"predef": [
"document",
"window",
"-Promise"
],
"browser": true,
"boss": true,
"curly": true,
"debug": false,
"devel": true,
"eqeqeq": true,
"evil": true,
"forin": false,
"immed": false,
"laxbreak": false,
"newcap": true,
"noarg": true,
"noempty": false,
"nonew": false,
"nomen": false,
"onevar": false,
"plusplus": false,
"regexp": false,
"undef": true,
"sub": true,
"strict": false,
"white": false,
"eqnull": true,
"esnext": true,
"unused": true
}
16 changes: 16 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/bower_components
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.gitignore
.jshintrc
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
language: node_js
node_js:
- "0.12"

sudo: false

cache:
directories:
- node_modules

before_install:
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
- "npm config set spin false"
- "npm install -g npm@^2"

install:
- npm install -g bower
- npm install
- bower install

script:
- npm test
3 changes: 3 additions & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
}
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Ember-bootstrap-validations

[![Build Status](https://travis-ci.org/kaliber5/ember-bootstrap-validations.svg?branch=master)](https://travis-ci.org/kaliber5/ember-bootstrap-validations)

This Ember addon adds support for validations based on [ember-validations](https://github.com/DockYard/ember-validations) to [ember-bootstrap](http://kaliber5.github.io/ember-bootstrap/) forms.
ember-bootstrap versions before 0.7.0 came with built-in support for ember-validations, all versions starting at 0.7.0
need an additional addon that implements validation support for the particular validation library. This addon delivers support for ember-validations.

## Installation

`ember install ember-bootstrap-validations`

You should have installed the ember-bootstrap and ember-validations addons already. If not install them:

```
ember install ember-bootstrap
ember install ember-validations
```

## Usage

Add validations to your model:

```js
import DS from 'ember-data';
import EmberValidations from 'ember-validations';

export default DS.Model.extend(EmberValidations, {
username: DS.attr('string'),
email: DS.attr('string'),
password: DS.attr('string'),

validations: {
'username': {
presence: true,
length: { minimum: 6 }
},
'email': {
presence: true
},
'password': {
presence: true,
length: { minimum: 8 }
}
}
});
```

Then assign the model to your form:

```hbs
{{#bs-form model=model}}
{{bs-form-element label="Username" controlType="text" property="username" required=true}}
{{bs-form-element label="Email" controlType="email" property="email" required=true}}
{{bs-form-element label="Password" controlType="password" property="password" required=true}}
{{bs-button defaultText="Submit" type="primary" buttonType="submit"}}
{{/bs-form}}
```

## Authors

[Simon Ihmig](https://github.com/simonihmig) @ [kaliber5](http://www.kaliber5.de)

## Copyright and license

Code and documentation copyright 2016 kaliber5 GmbH. Code released under [the MIT license](LICENSE.md).
Empty file added addon/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions addon/components/bs-form-element.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Ember from 'ember';
import BsFormElement from 'ember-bootstrap/components/bs-form-element';

const { computed, defineProperty, A } = Ember;

export default BsFormElement.extend({
setupValidations() {
let key = `model.error.${this.get('property')}.validation`;
defineProperty(this, 'errors', computed(`${key}[]`, function() {
return A(this.get(key));
}));
}
});
22 changes: 22 additions & 0 deletions addon/components/bs-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Ember from 'ember';
import BsForm from 'ember-bootstrap/components/bs-form';

const { computed, RSVP, on, observer } = Ember;

export default BsForm.extend({

hasValidator: computed.notEmpty('model.validate'),

validate(model) {
let m = model;

Ember.assert('Model must be a Changeset instance', m && typeof m.validate === 'function');
return m.get('isValid') ? RSVP.resolve() : RSVP.reject();
},

_initValidation: on('init', observer('model', function() {
if (this.get('hasValidator')) {
this.get('model').validate();
}
}))
});
Empty file added app/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions app/components/bs-form-element.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-bootstrap-changeset-validations/components/bs-form-element';
1 change: 1 addition & 0 deletions app/components/bs-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-bootstrap-changeset-validations/components/bs-form';
10 changes: 10 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "ember-bootstrap-changeset-validations",
"dependencies": {
"ember": "~2.4.3",
"ember-cli-shims": "0.1.1",
"ember-cli-test-loader": "0.2.2",
"ember-qunit-notifications": "0.1.0",
"bootstrap": "~3.3.5"
}
}
3 changes: 3 additions & 0 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*jshint node:true*/
module.exports = {
};
6 changes: 6 additions & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*jshint node:true*/
'use strict';

module.exports = function(/* environment, appConfig */) {
return { };
};
18 changes: 18 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*jshint node:true*/
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
// Add options here
});

/*
This build file specifies the options for the dummy test app of this
addon, located in `/tests/dummy`
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
*/

return app.toTree();
};
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* jshint node: true */
'use strict';

module.exports = {
name: 'ember-bootstrap-changeset-validations',
isDevelopingAddon: function() {
return true;
}
};
60 changes: 60 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "ember-bootstrap-changeset-validations",
"version": "0.1.0",
"description": "This Ember addon adds support for validations based on ember-changeset to ember-bootstrap",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember try:each"
},
"repository": {
"type": "git",
"url": "http://github.com/kaliber5/ember-bootstrap-changeset-validations.git"
},
"engines": {
"node": ">= 0.10.0"
},
"author": "Simon Ihmig <[email protected]>",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.4.2",
"ember-ajax": "0.7.1",
"ember-bootstrap": "0.7.0",
"ember-changeset": "0.10.1",
"ember-changeset-validations": "0.6.1",
"ember-cli": "2.4.3",
"ember-cli-app-version": "^1.0.0",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-htmlbars": "^1.0.3",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.4.0",
"ember-cli-qunit": "^1.4.0",
"ember-cli-release": "0.2.8",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "^2.4.2",
"ember-disable-prototype-extensions": "^1.1.0",
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"ember-try": "^0.2.2",
"loader.js": "^4.0.1"
},
"keywords": [
"ember-addon"
],
"dependencies": {
"ember-cli-babel": "^5.1.6"
},
"ember-addon": {
"configPath": "tests/dummy/config",
"after": "ember-bootstrap",
"versionCompatibility": {
"ember": ">=1.13.0"
}
}
}
13 changes: 13 additions & 0 deletions testem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*jshint node:true*/
module.exports = {
"framework": "qunit",
"test_page": "tests/index.html?hidepassed",
"disable_watching": true,
"launch_in_ci": [
"PhantomJS"
],
"launch_in_dev": [
"PhantomJS",
"Chrome"
]
};
Loading

0 comments on commit c9dfae7

Please sign in to comment.