Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

Commit

Permalink
v8.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BarryThePenguin committed Mar 9, 2016
2 parents 0dd0a04 + c72f803 commit ee6dc72
Show file tree
Hide file tree
Showing 14 changed files with 735 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text eol=lf
*.png binary
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
- STOP! Are you trying to get help? If so, read here:
Thanks for your interest in angular-formly. If you're
filing this issue to get help, please follow the
instructions at help.angular-formly.com
The GitHub issues on this project are reserved
for feature requests and bug reports. So if you
file an issue looking for help, it will be closed
and you'll be invited to follow the instructions
at help.angular-formly.com.
It's nothing personal. It's just hard to manage
the project otherwise!
- Filing a bug or feature request?
If you'd like to report what you think is a bug or
a feature request, please follow the instructions
at issue.angular-formly.com to file your issue.
Thanks for your contribution!
-->

30 changes: 30 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
Thanks for your contribution!
Unless this is a really small and insignificant change,
please make sure that we've discussed it first in
the issues.
-->

## What

<!-- explain what is being done here -->

## Why

<!-- explain why it's necessary -->

## How

<!-- explain how you did it -->

For issue # <!-- put your issue number here -->

Checklist:

* [ ] Follows the commit message [conventions](https://github.com/stevemao/conventional-changelog-angular/blob/master/convention.md)
* [ ] Is [rebased with master](https://egghead.io/lessons/javascript-how-to-rebase-a-git-pull-request-branch?series=how-to-contribute-to-an-open-source-project-on-github)
* [ ] Is [only one (maybe two) commits](https://egghead.io/lessons/javascript-how-to-squash-multiple-git-commits)

6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ with a link to a jsbin that demonstrates the issue with [issue.angular-formly.co

## Pull Requests

**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)

‼️‼️‼️ 👉**Please follow our commit message conventions** even if you're making a small change! This repository follows the
[How to Write an Open Source JavaScript Library](https://egghead.io/series/how-to-write-an-open-source-javascript-library)
series on egghead.io (by yours truly). See
[this lesson](https://egghead.io/lessons/javascript-how-to-write-a-javascript-library-writing-conventional-commits-with-commitizen?series=how-to-write-an-open-source-javascript-library)
and [this repo](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md)
and [this repo](https://github.com/stevemao/conventional-changelog-angular/blob/master/convention.md)
to learn more about the commit message conventions.

[Watch video](https://www.youtube.com/watch?v=QOchwBm9W-g&list=PLV5CVI1eNcJi7lVVIuNyRhEuck1Z007BH&index=1) (slightly out of date)
Expand All @@ -52,7 +54,7 @@ Please do the following:
2. run `npm start` (if you're on a windows machine, see [this issue](https://github.com/formly-js/angular-formly/issues/305))
3. write tests & code in ES6 goodness :-)
4. run `git add src/`
5. run `npm run commit` and follow the prompt (this ensures that your commit message follows [our conventions](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md)).
5. run `npm run commit` and follow the prompt (this ensures that your commit message follows [our conventions](https://github.com/stevemao/conventional-changelog-angular/blob/master/convention.md)).
6. notice that there's a pre-commit hook that runs to ensure tests pass and coverage doesn't drop to prevent the build from breaking :-)
7. push your changes
8. create a PR with a link to the original issue
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [angular-formly](http://docs.angular-formly.com)

[THIS PROJECT NEEDS A MAINTAINER](https://github.com/formly-js/angular-formly/issues/638)

Status:
[![npm version](https://img.shields.io/npm/v/angular-formly.svg?style=flat-square)](https://www.npmjs.org/package/angular-formly)
[![npm downloads](https://img.shields.io/npm/dm/angular-formly.svg?style=flat-square)](http://npm-stat.com/charts.html?package=angular-formly&from=2015-01-01)
Expand All @@ -14,6 +16,8 @@ Links:
[![egghead.io lessons](https://img.shields.io/badge/egghead-lessons-blue.svg?style=flat-square)](https://egghead.io/playlists/advanced-angular-forms-with-angular-formly)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/formly-js/angular-formly?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/formly-js/angular-formly/releases)
[![PRs Welcome](https://img.shields.io/badge/prs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)


angular-formly is an AngularJS module which has a directive to help customize and render JavaScript/JSON configured forms.
The `formly-form` directive and the `formlyConfig` service are very powerful and bring unmatched maintainability to your
Expand Down
12 changes: 12 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const gulp = require('gulp')
const replace = require('gulp-replace')

// bump npm package version into package.js
gulp.task('meteor', function() {
const pkg = require('./package.json')
const versionRegex = /(version\:\s*\')([^\']+)\'/gi

return gulp.src('package.js')
.pipe(replace(versionRegex, '$1' + pkg.version + "'"))
.pipe(gulp.dest('./'))
})
23 changes: 23 additions & 0 deletions package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* global Package:false */
// package metadata file for AtmosphereJS

try {
Package.describe({
name: 'formly:angular-formly',
summary: 'angular-formly (official): forms for AngularJS',
version: '0.0.0-semantically-released.0',
git: 'https://github.com/formly-js/angular-formly.git',
})

Package.onUse(function(api) {
api.versionsFrom(['METEOR@1.0'])
// api-check
api.use('wieldo:api-check@7.5.5')
api.imply('wieldo:api-check')
// angular
api.use('angular:angular@1.4.0')
api.addFiles('dist/formly.js', 'client')
})
} catch (e) {
//
}
18 changes: 17 additions & 1 deletion src/directives/formly-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo

// @ngInject
function FormlyFieldController($scope, $timeout, $parse, $controller, formlyValidationMessages) {
/* eslint max-statements:[2, 32] */
/* eslint max-statements:[2, 34] */
if ($scope.options.fieldGroup) {
setupFieldGroup()
return
Expand All @@ -53,6 +53,7 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
setDefaultValue()
setInitialValue()
runExpressions()
watchExpressions()
addValidationMessages($scope.options)
invokeControllers($scope, $scope.options, fieldType)

Expand All @@ -72,6 +73,21 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
}, 0, false)
}

function watchExpressions() {
if ($scope.formOptions.watchAllExpressions) {
const field = $scope.options
const currentValue = valueGetterSetter()
angular.forEach(field.expressionProperties, function watchExpression(expression, prop) {
const setter = $parse(prop).assign
$scope.$watch(function expressionPropertyWatcher() {
return formlyUtil.formlyEval($scope, expression, currentValue, currentValue)
}, function expressionPropertyListener(value) {
setter(field, value)
}, true)
})
}
}

function valueGetterSetter(newVal) {
if (!$scope.model || !$scope.options.key) {
return undefined
Expand Down
50 changes: 50 additions & 0 deletions src/directives/formly-field.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,56 @@ describe('formly-field', function() {
$timeout.flush()
expect($validateSpy).to.have.been.calledOnce
})

it(`should cope when field.formControl has been upgraded to an array`, () => {
scope.model = {
multiNgModel: {
start: 'start',
stop: 'stop',
},
}
const field = getNewField({
key: 'multiNgModel',
template: multiNgModelField,
extras: {
validateOnModelChange: true,
},
})
scope.fields = [field]
compileAndDigest()
const $validateSpy0 = sinon.spy(field.formControl[0], '$validate')
const $validateSpy1 = sinon.spy(field.formControl[1], '$validate')
scope.model.foo = 'bar'
scope.$digest()
$timeout.flush()
expect($validateSpy0).to.have.been.calledOnce
expect($validateSpy1).to.have.been.calledOnce
})

it.skip(`should run field expressions when form is initialised`, () => {
scope.model = {email: ''}
scope.fields = [getNewField({
key: 'email',
templateOptions: {
required: true,
},
extras: {validateOnModelChange: true},
}),
getNewField({
key: 'firstName',
templateOptions: {
required: true,
},
extras: {validateOnModelChange: true},
hideExpression: 'form.email.$invalid',
})]

compileAndDigest()
$timeout.flush()
scope.$digest()
expect(scope.fields[1].formControl).to.exist
expect(scope.fields[1].hide).to.equal(true)
})
})
})

Expand Down
Loading

0 comments on commit ee6dc72

Please sign in to comment.