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

Commit ee6dc72

Browse files
v8.0.2
2 parents 0dd0a04 + c72f803 commit ee6dc72

14 files changed

+735
-58
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text eol=lf
2+
*.png binary

.github/ISSUE_TEMPLATE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--
2+
3+
- STOP! Are you trying to get help? If so, read here:
4+
5+
Thanks for your interest in angular-formly. If you're
6+
filing this issue to get help, please follow the
7+
instructions at help.angular-formly.com
8+
9+
The GitHub issues on this project are reserved
10+
for feature requests and bug reports. So if you
11+
file an issue looking for help, it will be closed
12+
and you'll be invited to follow the instructions
13+
at help.angular-formly.com.
14+
It's nothing personal. It's just hard to manage
15+
the project otherwise!
16+
17+
18+
- Filing a bug or feature request?
19+
20+
If you'd like to report what you think is a bug or
21+
a feature request, please follow the instructions
22+
at issue.angular-formly.com to file your issue.
23+
24+
Thanks for your contribution!
25+
26+
-->
27+

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!--
2+
3+
Thanks for your contribution!
4+
5+
Unless this is a really small and insignificant change,
6+
please make sure that we've discussed it first in
7+
the issues.
8+
9+
-->
10+
11+
## What
12+
13+
<!-- explain what is being done here -->
14+
15+
## Why
16+
17+
<!-- explain why it's necessary -->
18+
19+
## How
20+
21+
<!-- explain how you did it -->
22+
23+
For issue # <!-- put your issue number here -->
24+
25+
Checklist:
26+
27+
* [ ] Follows the commit message [conventions](https://github.com/stevemao/conventional-changelog-angular/blob/master/convention.md)
28+
* [ ] 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)
29+
* [ ] Is [only one (maybe two) commits](https://egghead.io/lessons/javascript-how-to-squash-multiple-git-commits)
30+

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ with a link to a jsbin that demonstrates the issue with [issue.angular-formly.co
2929

3030
## Pull Requests
3131

32+
**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)
33+
3234
‼️‼️‼️ 👉**Please follow our commit message conventions** even if you're making a small change! This repository follows the
3335
[How to Write an Open Source JavaScript Library](https://egghead.io/series/how-to-write-an-open-source-javascript-library)
3436
series on egghead.io (by yours truly). See
3537
[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)
36-
and [this repo](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md)
38+
and [this repo](https://github.com/stevemao/conventional-changelog-angular/blob/master/convention.md)
3739
to learn more about the commit message conventions.
3840

3941
[Watch video](https://www.youtube.com/watch?v=QOchwBm9W-g&list=PLV5CVI1eNcJi7lVVIuNyRhEuck1Z007BH&index=1) (slightly out of date)
@@ -52,7 +54,7 @@ Please do the following:
5254
2. run `npm start` (if you're on a windows machine, see [this issue](https://github.com/formly-js/angular-formly/issues/305))
5355
3. write tests & code in ES6 goodness :-)
5456
4. run `git add src/`
55-
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)).
57+
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)).
5658
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 :-)
5759
7. push your changes
5860
8. create a PR with a link to the original issue

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

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

5+
[THIS PROJECT NEEDS A MAINTAINER](https://github.com/formly-js/angular-formly/issues/638)
6+
57
Status:
68
[![npm version](https://img.shields.io/npm/v/angular-formly.svg?style=flat-square)](https://www.npmjs.org/package/angular-formly)
79
[![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)
@@ -14,6 +16,8 @@ Links:
1416
[![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)
1517
[![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)
1618
[![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)
19+
[![PRs Welcome](https://img.shields.io/badge/prs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
20+
1721

1822
angular-formly is an AngularJS module which has a directive to help customize and render JavaScript/JSON configured forms.
1923
The `formly-form` directive and the `formlyConfig` service are very powerful and bring unmatched maintainability to your

gulpfile.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const gulp = require('gulp')
2+
const replace = require('gulp-replace')
3+
4+
// bump npm package version into package.js
5+
gulp.task('meteor', function() {
6+
const pkg = require('./package.json')
7+
const versionRegex = /(version\:\s*\')([^\']+)\'/gi
8+
9+
return gulp.src('package.js')
10+
.pipe(replace(versionRegex, '$1' + pkg.version + "'"))
11+
.pipe(gulp.dest('./'))
12+
})

package.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* global Package:false */
2+
// package metadata file for AtmosphereJS
3+
4+
try {
5+
Package.describe({
6+
name: 'formly:angular-formly',
7+
summary: 'angular-formly (official): forms for AngularJS',
8+
version: '0.0.0-semantically-released.0',
9+
git: 'https://github.com/formly-js/angular-formly.git',
10+
})
11+
12+
Package.onUse(function(api) {
13+
api.versionsFrom(['[email protected]'])
14+
// api-check
15+
api.use('wieldo:[email protected]')
16+
api.imply('wieldo:api-check')
17+
// angular
18+
api.use('angular:[email protected]')
19+
api.addFiles('dist/formly.js', 'client')
20+
})
21+
} catch (e) {
22+
//
23+
}

src/directives/formly-field.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
3535

3636
// @ngInject
3737
function FormlyFieldController($scope, $timeout, $parse, $controller, formlyValidationMessages) {
38-
/* eslint max-statements:[2, 32] */
38+
/* eslint max-statements:[2, 34] */
3939
if ($scope.options.fieldGroup) {
4040
setupFieldGroup()
4141
return
@@ -53,6 +53,7 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
5353
setDefaultValue()
5454
setInitialValue()
5555
runExpressions()
56+
watchExpressions()
5657
addValidationMessages($scope.options)
5758
invokeControllers($scope, $scope.options, fieldType)
5859

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

76+
function watchExpressions() {
77+
if ($scope.formOptions.watchAllExpressions) {
78+
const field = $scope.options
79+
const currentValue = valueGetterSetter()
80+
angular.forEach(field.expressionProperties, function watchExpression(expression, prop) {
81+
const setter = $parse(prop).assign
82+
$scope.$watch(function expressionPropertyWatcher() {
83+
return formlyUtil.formlyEval($scope, expression, currentValue, currentValue)
84+
}, function expressionPropertyListener(value) {
85+
setter(field, value)
86+
}, true)
87+
})
88+
}
89+
}
90+
7591
function valueGetterSetter(newVal) {
7692
if (!$scope.model || !$scope.options.key) {
7793
return undefined

src/directives/formly-field.test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,56 @@ describe('formly-field', function() {
19331933
$timeout.flush()
19341934
expect($validateSpy).to.have.been.calledOnce
19351935
})
1936+
1937+
it(`should cope when field.formControl has been upgraded to an array`, () => {
1938+
scope.model = {
1939+
multiNgModel: {
1940+
start: 'start',
1941+
stop: 'stop',
1942+
},
1943+
}
1944+
const field = getNewField({
1945+
key: 'multiNgModel',
1946+
template: multiNgModelField,
1947+
extras: {
1948+
validateOnModelChange: true,
1949+
},
1950+
})
1951+
scope.fields = [field]
1952+
compileAndDigest()
1953+
const $validateSpy0 = sinon.spy(field.formControl[0], '$validate')
1954+
const $validateSpy1 = sinon.spy(field.formControl[1], '$validate')
1955+
scope.model.foo = 'bar'
1956+
scope.$digest()
1957+
$timeout.flush()
1958+
expect($validateSpy0).to.have.been.calledOnce
1959+
expect($validateSpy1).to.have.been.calledOnce
1960+
})
1961+
1962+
it.skip(`should run field expressions when form is initialised`, () => {
1963+
scope.model = {email: ''}
1964+
scope.fields = [getNewField({
1965+
key: 'email',
1966+
templateOptions: {
1967+
required: true,
1968+
},
1969+
extras: {validateOnModelChange: true},
1970+
}),
1971+
getNewField({
1972+
key: 'firstName',
1973+
templateOptions: {
1974+
required: true,
1975+
},
1976+
extras: {validateOnModelChange: true},
1977+
hideExpression: 'form.email.$invalid',
1978+
})]
1979+
1980+
compileAndDigest()
1981+
$timeout.flush()
1982+
scope.$digest()
1983+
expect(scope.fields[1].formControl).to.exist
1984+
expect(scope.fields[1].hide).to.equal(true)
1985+
})
19361986
})
19371987
})
19381988

0 commit comments

Comments
 (0)