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

Commit

Permalink
v8.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
formly-bot committed Mar 10, 2016
2 parents 3b25b1e + e5ff572 commit 602cf76
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
15 changes: 7 additions & 8 deletions dist/formly.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-formly JavaScript Library v8.0.3
* angular-formly JavaScript Library v8.0.4
*
* @license MIT (http://license.angular-formly.com)
*
Expand Down Expand Up @@ -153,7 +153,7 @@ return /******/ (function(modules) { // webpackBootstrap

ngModule.constant('formlyApiCheck', _providersFormlyApiCheck2['default']);
ngModule.constant('formlyErrorAndWarningsUrlPrefix', _otherDocsBaseUrl2['default']);
ngModule.constant('formlyVersion', ("8.0.3")); // <-- webpack variable
ngModule.constant('formlyVersion', ("8.0.4")); // <-- webpack variable

ngModule.provider('formlyUsability', _providersFormlyUsability2['default']);
ngModule.provider('formlyConfig', _providersFormlyConfig2['default']);
Expand Down Expand Up @@ -430,7 +430,7 @@ return /******/ (function(modules) { // webpackBootstrap
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("8.0.3") + "/other/ERRORS_AND_WARNINGS.md#";
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("8.0.4") + "/other/ERRORS_AND_WARNINGS.md#";
module.exports = exports["default"];

/***/ },
Expand Down Expand Up @@ -2054,7 +2054,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (attrs.hasOwnProperty('isFieldGroup') && el.parent().parent().hasClass('formly')) {
parentFormAttributes = copyAttributes(el.parent().parent()[0].attributes);
}
return '\n <' + rootEl + ' class="formly"\n name="' + getFormName() + '"\n role="form" ' + parentFormAttributes + '>\n <' + fieldRootEl + ' formly-field\n ng-repeat="field in fields ' + getTrackBy() + '"\n ' + getHideDirective() + '="!field.hide"\n class="formly-field"\n options="field"\n model="field.model"\n original-model="model"\n fields="fields"\n form="theFormlyForm"\n form-id="' + getFormName() + '"\n form-state="options.formState"\n form-options="options"\n index="$index">\n </' + fieldRootEl + '>\n <div ng-transclude class="' + getTranscludeClass() + '"></div>\n </' + rootEl + '>\n ';
return '\n <' + rootEl + ' class="formly"\n name="' + getFormName() + '"\n role="form" ' + parentFormAttributes + '>\n <' + fieldRootEl + ' formly-field\n ng-repeat="field in fields ' + getTrackBy() + '"\n ' + getHideDirective() + '="!field.hide"\n class="formly-field"\n options="field"\n model="field.model || model"\n original-model="model"\n fields="fields"\n form="theFormlyForm"\n form-id="' + getFormName() + '"\n form-state="options.formState"\n form-options="options"\n index="$index">\n </' + fieldRootEl + '>\n <div ng-transclude class="' + getTranscludeClass() + '"></div>\n </' + rootEl + '>\n ';

function getRootEl() {
return attrs.rootEl || 'ng-form';
Expand Down Expand Up @@ -2144,7 +2144,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (field.hideExpression) {
// can't use hide with expressionProperties reliably
var val = model[field.key];
field.hide = evalCloseToFormlyExpression(field.hideExpression, val, field, index);
field.hide = evalCloseToFormlyExpression(field.hideExpression, val, field, index, { model: model });
}
if (field.extras && field.extras.validateOnModelChange && field.formControl) {
if (_angularFix2['default'].isArray(field.formControl)) {
Expand Down Expand Up @@ -2256,7 +2256,7 @@ return /******/ (function(modules) { // webpackBootstrap
var model = field.model || $scope.model;
$scope.$watch(function hideExpressionWatcher() {
var val = model[field.key];
return evalCloseToFormlyExpression(field.hideExpression, val, field, index);
return evalCloseToFormlyExpression(field.hideExpression, val, field, index, { model: model });
}, function (hide) {
return field.hide = hide;
}, true);
Expand All @@ -2281,9 +2281,8 @@ return /******/ (function(modules) { // webpackBootstrap
return field.model = model;
});
})();
} else if (!field.model) {
field.model = $scope.model;
}

return isNewModel;

function resolveStringModel(expression) {
Expand Down
6 changes: 3 additions & 3 deletions dist/formly.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/formly.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-formly",
"version": "8.0.3",
"version": "8.0.4",
"author": "Astrism <[email protected]>",
"contributors": [
"Astrism <[email protected]>",
Expand Down
9 changes: 4 additions & 5 deletions src/directives/formly-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function formlyForm(formlyUsability, formlyWarn, $parse, formlyConfig, $interpol
${getHideDirective()}="!field.hide"
class="formly-field"
options="field"
model="field.model"
model="field.model || model"
original-model="model"
fields="fields"
form="theFormlyForm"
Expand Down Expand Up @@ -140,7 +140,7 @@ function formlyForm(formlyUsability, formlyWarn, $parse, formlyConfig, $interpol
const promise = field.runExpressions && field.runExpressions()
if (field.hideExpression) { // can't use hide with expressionProperties reliably
const val = model[field.key]
field.hide = evalCloseToFormlyExpression(field.hideExpression, val, field, index)
field.hide = evalCloseToFormlyExpression(field.hideExpression, val, field, index, {model})
}
if (field.extras && field.extras.validateOnModelChange && field.formControl) {
if (angular.isArray(field.formControl)) {
Expand Down Expand Up @@ -261,7 +261,7 @@ function formlyForm(formlyUsability, formlyWarn, $parse, formlyConfig, $interpol
const model = field.model || $scope.model
$scope.$watch(function hideExpressionWatcher() {
const val = model[field.key]
return evalCloseToFormlyExpression(field.hideExpression, val, field, index)
return evalCloseToFormlyExpression(field.hideExpression, val, field, index, {model})
}, (hide) => field.hide = hide, true)
}
}
Expand All @@ -277,9 +277,8 @@ function formlyForm(formlyUsability, formlyWarn, $parse, formlyConfig, $interpol
field.model = resolveStringModel(expression)

$scope.$watch(() => resolveStringModel(expression), (model) => field.model = model)
} else if (!field.model) {
field.model = $scope.model
}

return isNewModel

function resolveStringModel(expression) {
Expand Down
20 changes: 19 additions & 1 deletion src/directives/formly-form.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ describe('formly-form', () => {
{template: input, key: 'foo', model: scope.fieldModel1},
{template: input, key: 'bar', model: scope.fieldModel1},
{template: input, key: 'zoo', model: scope.fieldModel1},
{template: input, key: 'test'},
]
})

Expand All @@ -462,6 +463,21 @@ describe('formly-form', () => {
expect(spy1).to.have.been.calledOnce
expect(spy2).to.have.been.calledOnce
})

it('should be updated when the reference to the model changes', () => {
scope.model = {test: 'bar'}
scope.fields[3].expressionProperties = {'data.test': 'model.test'}

compileAndDigest()
$timeout.flush()

scope.model = {test: 'baz'}

scope.$digest()
$timeout.flush()

expect(scope.fields[3].data.test).to.equal('baz')
})
})

describe('nested model as string', () => {
Expand Down Expand Up @@ -498,6 +514,7 @@ describe('formly-form', () => {
it('should be updated when the reference to the outer model changes', () => {
scope.model.nested.foo = 'bar'
scope.fields[0].model = 'model.nested'
scope.fields[0].expressionProperties = {'data.foo': 'model.foo'}

compileAndDigest()
$timeout.flush()
Expand All @@ -509,8 +526,9 @@ describe('formly-form', () => {
}

scope.$digest()
$timeout.flush()

expect(scope.fields[0].model.foo).to.equal('baz')
expect(scope.fields[0].data.foo).to.equal('baz')
})

function testModelAccessor(accessor) {
Expand Down

0 comments on commit 602cf76

Please sign in to comment.