Skip to content

Commit

Permalink
feat(forms): add easy way to switch between forms modules (#9202)
Browse files Browse the repository at this point in the history
  • Loading branch information
kara authored and robwormald committed Jun 15, 2016
1 parent fe01e2e commit 22916bb
Show file tree
Hide file tree
Showing 75 changed files with 3,570 additions and 583 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ for PACKAGE in \
core \
compiler \
common \
forms \
platform-browser \
platform-browser-dynamic \
platform-server \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export class NgForm extends ControlContainer implements Form {
@Optional() @Self() @Inject(NG_VALIDATORS) validators: any[],
@Optional() @Self() @Inject(NG_ASYNC_VALIDATORS) asyncValidators: any[]) {
super();
console.warn(`
*It looks like you're using the old forms module. This will be opt-in in the next RC, and
will eventually be removed in favor of the new forms module. For more information, see:
https://docs.google.com/document/u/1/d/1RIezQqE4aEhBRmArIAS1mRIZtWFf6JxN_7B4meyWK0Y/pub
`);
this.form = new ControlGroup(
{}, null, composeValidators(validators), composeAsyncValidators(asyncValidators));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ export class NgFormModel extends ControlContainer implements Form,
@Optional() @Self() @Inject(NG_VALIDATORS) private _validators: any[],
@Optional() @Self() @Inject(NG_ASYNC_VALIDATORS) private _asyncValidators: any[]) {
super();
console.warn(`
*It looks like you're using the old forms module. This will be opt-in in the next RC, and
will eventually be removed in favor of the new forms module. For more information, see:
https://docs.google.com/document/u/1/d/1RIezQqE4aEhBRmArIAS1mRIZtWFf6JxN_7B4meyWK0Y/pub
`);
}

ngOnChanges(changes: SimpleChanges): void {
Expand Down
54 changes: 0 additions & 54 deletions modules/@angular/common/src/forms.ts

This file was deleted.

1 change: 1 addition & 0 deletions modules/@angular/core/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export './src/core/debug/debug_node.dart' show DebugElement,
asNativeElements;
export './src/core/testability/testability.dart';
export './src/core/change_detection.dart';
export './src/core/platform_directives_and_pipes.dart';
export './src/core/platform_common_providers.dart';
export './src/core/application_common_providers.dart';
export './src/core/reflection/reflection.dart';
1 change: 1 addition & 0 deletions modules/@angular/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export * from './src/linker';
export {DebugElement, DebugNode, asNativeElements, getDebugNode} from './src/debug/debug_node';
export * from './src/testability/testability';
export * from './src/change_detection';
export * from './src/platform_directives_and_pipes';
export * from './src/platform_common_providers';
export * from './src/application_common_providers';
export {wtfCreateScope, wtfLeave, wtfStartTimeRange, wtfEndTimeRange, WtfScopeFn} from './src/profile/profile';
Expand Down
58 changes: 58 additions & 0 deletions modules/@angular/core/src/platform_directives_and_pipes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {OpaqueToken} from './di';

/**
A token that can be provided when bootstrapping an application to make an array of directives
* available in every component of the application.
*
* ### Example
*
* ```typescript
* import {PLATFORM_DIRECTIVES} from '@angular/core';
* import {OtherDirective} from './myDirectives';
*
* @Component({
* selector: 'my-component',
* template: `
* <!-- can use other directive even though the component does not list it in `directives` -->
* <other-directive></other-directive>
* `
* })
* export class MyComponent {
* ...
* }
*
* bootstrap(MyComponent, [{provide: PLATFORM_DIRECTIVES, useValue: [OtherDirective],
multi:true}]);
* ```
* @stable
*/

export const PLATFORM_DIRECTIVES: OpaqueToken =
/*@ts2dart_const*/ new OpaqueToken('Platform Directives');

/**
* A token that can be provided when bootstraping an application to make an array of pipes
* available in every component of the application.
*
* ### Example
*
* ```typescript
* import {PLATFORM_PIPES} from '@angular/core';
* import {OtherPipe} from './myPipe';
*
* @Component({
* selector: 'my-component',
* template: `
* {{123 | other-pipe}}
* `
* })
* export class MyComponent {
* ...
* }
*
* bootstrap(MyComponent, [{provide: PLATFORM_PIPES, useValue: [OtherPipe], multi:true}]);
* ```
* @stable
*/

export const PLATFORM_PIPES: OpaqueToken = /*@ts2dart_const*/ new OpaqueToken('Platform Pipes');
1 change: 1 addition & 0 deletions modules/@angular/forms/common.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'index.dart';
1 change: 1 addition & 0 deletions modules/@angular/forms/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/forms';
19 changes: 19 additions & 0 deletions modules/@angular/forms/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@angular/forms",
"version": "0.0.0-PLACEHOLDER",
"description": "",
"main": "index.js",
"jsnext:main": "esm/index.js",
"typings": "index.d.ts",
"author": "angular",
"license": "MIT",
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER",
"@angular/common": "0.0.0-PLACEHOLDER",
"@angular/compiler": "0.0.0-PLACEHOLDER"
},
"repository": {
"type": "git",
"url": "https://github.com/angular/angular.git"
}
}
19 changes: 19 additions & 0 deletions modules/@angular/forms/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

export default {
entry: '../../../dist/packages-dist/forms/esm/index.js',
dest: '../../../dist/packages-dist/forms/esm/forms.umd.js',
format: 'umd',
moduleName: 'ng.forms',
globals: {
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/compiler': 'ng.compiler',
'rxjs/Subject': 'Rx',
'rxjs/observable/PromiseObservable': 'Rx', // this is wrong, but this stuff has changed in rxjs b.6 so we need to fix it when we update.
'rxjs/operator/toPromise': 'Rx.Observable.prototype',
'rxjs/Observable': 'Rx'
},
plugins: [
// nodeResolve({ jsnext: true, main: true }),
]
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {unimplemented} from '../../facade/exceptions';
import {isPresent} from '../../facade/lang';
import {unimplemented} from '../facade/exceptions';
import {isPresent} from '../facade/lang';
import {AbstractControl} from '../model';


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Directive, ElementRef, Renderer, forwardRef} from '@angular/core';

import {isBlank} from '../../facade/lang';
import {isBlank} from '../facade/lang';

import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {unimplemented} from '../../facade/exceptions';
import {unimplemented} from '../facade/exceptions';

import {AbstractControlDirective} from './abstract_control_directive';
import {ControlValueAccessor} from './control_value_accessor';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Directive, Self} from '@angular/core';

import {isPresent} from '../../facade/lang';
import {isPresent} from '../facade/lang';

import {NgControl} from './ng_control';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Directive, Inject, Optional, Self, forwardRef} from '@angular/core';

import {EventEmitter, ObservableWrapper, PromiseWrapper} from '../../facade/async';
import {ListWrapper} from '../../facade/collection';
import {isPresent} from '../../facade/lang';
import {EventEmitter, ObservableWrapper, PromiseWrapper} from '../facade/async';
import {ListWrapper} from '../facade/collection';
import {isPresent} from '../facade/lang';
import {AbstractControl, FormControl, FormGroup} from '../model';
import {NG_ASYNC_VALIDATORS, NG_VALIDATORS} from '../validators';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Directive, Host, Inject, Input, OnChanges, OnDestroy, Optional, Output, Self, SimpleChanges, forwardRef} from '@angular/core';

import {EventEmitter, ObservableWrapper} from '../../facade/async';
import {BaseException} from '../../facade/exceptions';
import {EventEmitter, ObservableWrapper} from '../facade/async';
import {BaseException} from '../facade/exceptions';
import {FormControl} from '../model';
import {NG_ASYNC_VALIDATORS, NG_VALIDATORS} from '../validators';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Directive, ElementRef, Renderer, forwardRef} from '@angular/core';

import {NumberWrapper} from '../../facade/lang';
import {NumberWrapper} from '../facade/lang';

import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Directive, ElementRef, Injectable, Injector, Input, OnDestroy, OnInit, Renderer, forwardRef} from '@angular/core';

import {ListWrapper} from '../../facade/collection';
import {isPresent} from '../../facade/lang';
import {ListWrapper} from '../facade/collection';
import {isPresent} from '../facade/lang';

import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
import {NgControl} from './ng_control';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Directive, Inject, Input, OnChanges, Optional, Output, Self, SimpleChanges, forwardRef} from '@angular/core';

import {EventEmitter, ObservableWrapper} from '../../../facade/async';
import {StringMapWrapper} from '../../../facade/collection';
import {EventEmitter, ObservableWrapper} from '../../facade/async';
import {StringMapWrapper} from '../../facade/collection';
import {FormControl} from '../../model';
import {NG_ASYNC_VALIDATORS, NG_VALIDATORS} from '../../validators';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Directive, Host, Inject, Input, OnChanges, OnDestroy, Optional, Output, Self, SimpleChanges, SkipSelf, forwardRef} from '@angular/core';

import {EventEmitter, ObservableWrapper} from '../../../facade/async';
import {EventEmitter, ObservableWrapper} from '../../facade/async';
import {FormControl} from '../../model';
import {NG_ASYNC_VALIDATORS, NG_VALIDATORS} from '../../validators';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Directive, Inject, Input, OnChanges, Optional, Output, Self, SimpleChanges, forwardRef} from '@angular/core';

import {EventEmitter, ObservableWrapper} from '../../../facade/async';
import {ListWrapper, StringMapWrapper} from '../../../facade/collection';
import {BaseException} from '../../../facade/exceptions';
import {isBlank} from '../../../facade/lang';
import {EventEmitter, ObservableWrapper} from '../../facade/async';
import {ListWrapper, StringMapWrapper} from '../../facade/collection';
import {BaseException} from '../../facade/exceptions';
import {isBlank} from '../../facade/lang';
import {FormControl, FormGroup} from '../../model';
import {NG_ASYNC_VALIDATORS, NG_VALIDATORS, Validators} from '../../validators';
import {ControlContainer} from '../control_container';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Renderer, forwardRef} from '@angular/core';

import {MapWrapper} from '../../facade/collection';
import {StringWrapper, isBlank, isPresent, isPrimitive, looseIdentical} from '../../facade/lang';
import {MapWrapper} from '../facade/collection';
import {StringWrapper, isBlank, isPresent, isPrimitive, looseIdentical} from '../facade/lang';

import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Renderer, forwardRef} from '@angular/core';

import {MapWrapper} from '../../facade/collection';
import {StringWrapper, isBlank, isPresent, isPrimitive, isString, looseIdentical} from '../../facade/lang';
import {MapWrapper} from '../facade/collection';
import {StringWrapper, isBlank, isPresent, isPrimitive, isString, looseIdentical} from '../facade/lang';

import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ListWrapper, StringMapWrapper} from '../../facade/collection';
import {BaseException} from '../../facade/exceptions';
import {hasConstructor, isBlank, isPresent, looseIdentical} from '../../facade/lang';
import {ListWrapper, StringMapWrapper} from '../facade/collection';
import {BaseException} from '../facade/exceptions';
import {hasConstructor, isBlank, isPresent, looseIdentical} from '../facade/lang';
import {FormControl, FormGroup} from '../model';
import {Validators} from '../validators';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Attribute, Directive, forwardRef} from '@angular/core';

import {NumberWrapper} from '../../facade/lang';
import {NumberWrapper} from '../facade/lang';
import {AbstractControl} from '../model';
import {NG_VALIDATORS, Validators} from '../validators';

Expand Down
Loading

0 comments on commit 22916bb

Please sign in to comment.