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

Commit ec8e49e

Browse files
committed
v7.1.0
2 parents 63ffd5a + 1aaa92c commit ec8e49e

File tree

12 files changed

+122
-54
lines changed

12 files changed

+122
-54
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ There are a lot of questions from people as they get started using angular-forml
7070

7171
#### Contributing to community
7272

73-
- Write blog posts! Like [this one](https://scotch.io/tutorials/easy-angularjs-forms-with-angular-formly) or [this one](http://www.erwan-datin.com/tips/how-do-I-store-angular-formly-fields-model-into-database)
73+
- Create plugins! [ideas](http://docs.angular-formly.com/v7.0.1/page/plugins)
74+
- Write blog posts! Like [these](http://docs.angular-formly.com/docs/tips#blog-articles)
7475
- Record screencasts
7576
- Write examples. The website is driven by examples. [Watch video](https://www.youtube.com/watch?v=4dsXXTPET4A&list=PLV5CVI1eNcJi7lVVIuNyRhEuck1Z007BH&index=3)
7677

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Find more resources at [learn.angular-formly.com](http://learn.angular-formly.co
5252

5353
Find all the documentation at [docs.angular-formly.com](http://docs.angular-formly.com).
5454

55+
## Plugins
56+
57+
Find all the plugins at [docs.angular-formly.com/page/plugins](http://docs.angular-formly.com/page/plugins)
58+
5559
## Getting Help
5660

5761
Please don't file an issue unless you feel like you've found a bug or have a feature request. Instead, go to [help.angular-formly.com](http://help.angular-formly.com) and follow the instructions.

dist/formly.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! angular-formly version 7.0.1 built with ♥ by Astrism <[email protected]>, Kent C. Dodds <[email protected]> (ó ì_í)=óò=(ì_í ò)
1+
//! angular-formly version 7.1.0 built with ♥ by Astrism <[email protected]>, Kent C. Dodds <[email protected]> (ó ì_í)=óò=(ì_í ò)
22

33
(function webpackUniversalModuleDefinition(root, factory) {
44
if(typeof exports === 'object' && typeof module === 'object')
@@ -147,7 +147,7 @@ return /******/ (function(modules) { // webpackBootstrap
147147

148148
ngModule.constant('formlyApiCheck', _providersFormlyApiCheck2['default']);
149149
ngModule.constant('formlyErrorAndWarningsUrlPrefix', _otherDocsBaseUrl2['default']);
150-
ngModule.constant('formlyVersion', ("7.0.1")); // <-- webpack variable
150+
ngModule.constant('formlyVersion', ("7.1.0")); // <-- webpack variable
151151

152152
ngModule.provider('formlyUsability', _providersFormlyUsability2['default']);
153153
ngModule.provider('formlyConfig', _providersFormlyConfig2['default']);
@@ -355,7 +355,7 @@ return /******/ (function(modules) { // webpackBootstrap
355355
removeChromeAutoComplete: apiCheck.bool.optional,
356356
templateManipulators: templateManipulators.optional,
357357
wrapper: specifyWrapperType.optional,
358-
fieldTransform: apiCheck.func.optional,
358+
fieldTransform: apiCheck.oneOfType([apiCheck.func, apiCheck.array]).optional,
359359
data: apiCheck.object.optional
360360
}).strict;
361361

@@ -416,7 +416,7 @@ return /******/ (function(modules) { // webpackBootstrap
416416
Object.defineProperty(exports, "__esModule", {
417417
value: true
418418
});
419-
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("7.0.1") + "/other/ERRORS_AND_WARNINGS.md#";
419+
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("7.1.0") + "/other/ERRORS_AND_WARNINGS.md#";
420420
module.exports = exports["default"];
421421

422422
/***/ },
@@ -2047,21 +2047,38 @@ return /******/ (function(modules) { // webpackBootstrap
20472047

20482048
function setupFields() {
20492049
$scope.fields = $scope.fields || [];
2050-
var fieldTransform = $scope.options.fieldTransform || formlyConfig.extras.fieldTransform;
20512050

2052-
if (fieldTransform) {
2053-
$scope.fields = fieldTransform($scope.fields, $scope.model, $scope.options, $scope.form);
2054-
if (!$scope.fields) {
2055-
throw formlyUsability.getFormlyError('fieldTransform must return an array of fields');
2056-
}
2051+
checkDeprecatedOptions($scope.options);
2052+
2053+
var fieldTransforms = $scope.options.fieldTransform || formlyConfig.extras.fieldTransform;
2054+
2055+
if (!_angularFix2['default'].isArray(fieldTransforms)) {
2056+
fieldTransforms = [fieldTransforms];
20572057
}
20582058

2059+
_angularFix2['default'].forEach(fieldTransforms, function transformFields(fieldTransform) {
2060+
if (fieldTransform) {
2061+
$scope.fields = fieldTransform($scope.fields, $scope.model, $scope.options, $scope.form);
2062+
if (!$scope.fields) {
2063+
throw formlyUsability.getFormlyError('fieldTransform must return an array of fields');
2064+
}
2065+
}
2066+
});
2067+
20592068
setupModels();
20602069

20612070
_angularFix2['default'].forEach($scope.fields, attachKey); // attaches a key based on the index if a key isn't specified
20622071
_angularFix2['default'].forEach($scope.fields, setupWatchers); // setup watchers for all fields
20632072
}
20642073

2074+
function checkDeprecatedOptions(options) {
2075+
if (formlyConfig.extras.fieldTransform && _angularFix2['default'].isFunction(formlyConfig.extras.fieldTransform)) {
2076+
formlyWarn('fieldtransform-as-a-function-deprecated', 'fieldTransform as a function has been deprecated.', 'Attempted for formlyConfig.extras: ' + formlyConfig.extras.fieldTransform.name, formlyConfig.extras);
2077+
} else if (options.fieldTransform && _angularFix2['default'].isFunction(options.fieldTransform)) {
2078+
formlyWarn('fieldtransform-as-a-function-deprecated', 'fieldTransform as a function has been deprecated.', 'Attempted for form', options);
2079+
}
2080+
}
2081+
20652082
function setupOptions() {
20662083
formlyApiCheck['throw']([formlyApiCheck.formOptionsApi.optional], [$scope.options], { prefix: 'formly-form options check' });
20672084
$scope.options = $scope.options || {};

dist/formly.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formly.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

other/ERRORS_AND_WARNINGS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ of the expression, the scope you're passed wont have all the properties you may
127127
See documentation [here](http://docs.angular-formly.com/docs/field-configuration-object#hideexpression-string--function)
128128
and an example [here](http://angular-formly.com/#/example/field-options/hide-fields)
129129

130+
# FieldTransform as a function deprecated
131+
132+
To allow for plugin like functionality, `fieldTransform` functions on `formlyConfig.extras` and `formly-form.options`
133+
are now deprecated. Moving forward fieldTransform will accept an array of `fieldTransform` functions. This makes it possible
134+
to have multiple fieldTransforms. Note, `fieldTransform` functions will be removed in a major release.
135+
130136
# Notes
131137

132138
It is recommended to disable warnings in production using `formlyConfigProvider.disableWarnings = true`. Note: This will

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-formly",
3-
"version": "7.0.1",
3+
"version": "7.1.0",
44
"author": "Astrism <[email protected]>",
55
"contributors": [
66
"Astrism <[email protected]>",

scripts/pre-commit-git-check.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/directives/formly-form.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,47 @@ function formlyForm(formlyUsability, formlyWarn, $parse, formlyConfig, $interpol
133133

134134
function setupFields() {
135135
$scope.fields = $scope.fields || [];
136-
const fieldTransform = $scope.options.fieldTransform || formlyConfig.extras.fieldTransform;
137136

138-
if (fieldTransform) {
139-
$scope.fields = fieldTransform($scope.fields, $scope.model, $scope.options, $scope.form);
140-
if (!$scope.fields) {
141-
throw formlyUsability.getFormlyError('fieldTransform must return an array of fields');
142-
}
137+
checkDeprecatedOptions($scope.options);
138+
139+
let fieldTransforms = $scope.options.fieldTransform || formlyConfig.extras.fieldTransform;
140+
141+
if (!angular.isArray(fieldTransforms)) {
142+
fieldTransforms = [fieldTransforms];
143143
}
144144

145+
angular.forEach(fieldTransforms, function transformFields(fieldTransform) {
146+
if (fieldTransform) {
147+
$scope.fields = fieldTransform($scope.fields, $scope.model, $scope.options, $scope.form);
148+
if (!$scope.fields) {
149+
throw formlyUsability.getFormlyError('fieldTransform must return an array of fields');
150+
}
151+
}
152+
});
153+
145154
setupModels();
146155

147156
angular.forEach($scope.fields, attachKey); // attaches a key based on the index if a key isn't specified
148157
angular.forEach($scope.fields, setupWatchers); // setup watchers for all fields
149158
}
150159

160+
function checkDeprecatedOptions(options) {
161+
if (formlyConfig.extras.fieldTransform && angular.isFunction(formlyConfig.extras.fieldTransform)) {
162+
formlyWarn(
163+
'fieldtransform-as-a-function-deprecated',
164+
'fieldTransform as a function has been deprecated.',
165+
`Attempted for formlyConfig.extras: ${formlyConfig.extras.fieldTransform.name}`,
166+
formlyConfig.extras
167+
);
168+
} else if (options.fieldTransform && angular.isFunction(options.fieldTransform)) {
169+
formlyWarn(
170+
'fieldtransform-as-a-function-deprecated',
171+
'fieldTransform as a function has been deprecated.',
172+
`Attempted for form`,
173+
options
174+
);
175+
}
176+
}
151177

152178
function setupOptions() {
153179
formlyApiCheck.throw(

0 commit comments

Comments
 (0)