| Index: third_party/pkg/angular/lib/directive/ng_form.dart
|
| diff --git a/third_party/pkg/angular/lib/directive/ng_form.dart b/third_party/pkg/angular/lib/directive/ng_form.dart
|
| index f012f382fbeba389144a96439c5ee8c8c887863c..c2c4427f740bb3fef5325bc222208d7e6b11bb28 100644
|
| --- a/third_party/pkg/angular/lib/directive/ng_form.dart
|
| +++ b/third_party/pkg/angular/lib/directive/ng_form.dart
|
| @@ -5,26 +5,23 @@ part of angular.directive;
|
| * on if an action is set, the form will automatically either allow
|
| * or prevent the default browser submission from occurring.
|
| */
|
| -@Decorator(
|
| +@NgDirective(
|
| selector: 'form',
|
| - module: NgForm.module)
|
| -@Decorator(
|
| + publishTypes : const <Type>[NgControl],
|
| + visibility: NgDirective.CHILDREN_VISIBILITY)
|
| +@NgDirective(
|
| selector: 'fieldset',
|
| - module: NgForm.module)
|
| -@Decorator(
|
| + publishTypes : const <Type>[NgControl],
|
| + visibility: NgDirective.CHILDREN_VISIBILITY)
|
| +@NgDirective(
|
| selector: '.ng-form',
|
| - module: NgForm.module)
|
| -@Decorator(
|
| + publishTypes : const <Type>[NgControl],
|
| + visibility: NgDirective.CHILDREN_VISIBILITY)
|
| +@NgDirective(
|
| selector: '[ng-form]',
|
| - module: NgForm.module,
|
| - map: const { 'ng-form': '@name' })
|
| -class NgForm extends NgControl {
|
| - static final Module _module = new Module()
|
| - ..factory(NgControl, (i) => i.get(NgForm));
|
| - static module() => _module;
|
| -
|
| - final Scope _scope;
|
| -
|
| + publishTypes : const <Type>[NgControl],
|
| + visibility: NgDirective.CHILDREN_VISIBILITY)
|
| +class NgForm extends NgControl implements Map<String, NgControl> {
|
| /**
|
| * Instantiates a new instance of NgForm. Upon creation, the instance of the
|
| * class will be bound to the formName property on the scope (where formName
|
| @@ -35,52 +32,75 @@ class NgForm extends NgControl {
|
| * * [element] - The form DOM element.
|
| * * [injector] - An instance of Injector.
|
| */
|
| - NgForm(this._scope, NgElement element, Injector injector, Animate animate) :
|
| - super(element, injector, animate) {
|
| + NgForm(Scope scope, dom.Element element, Injector injector) :
|
| + super(scope, element, injector) {
|
|
|
| - if (!element.node.attributes.containsKey('action')) {
|
| - element.node.onSubmit.listen((event) {
|
| + if (!element.attributes.containsKey('action')) {
|
| + element.onSubmit.listen((event) {
|
| event.preventDefault();
|
| - onSubmit(valid == true);
|
| - if (valid == true) {
|
| - reset();
|
| - }
|
| + _scope.broadcast('submitNgControl', valid == null ? false : valid);
|
| + reset();
|
| });
|
| }
|
| }
|
|
|
| - /**
|
| - * The name of the control. This is usually fetched via the name attribute that is
|
| - * present on the element that the control is bound to.
|
| - */
|
| @NgAttr('name')
|
| get name => _name;
|
| - set name(String value) {
|
| - if (value != null) {
|
| - super.name = value;
|
| - _scope.context[name] = this;
|
| + set name(value) {
|
| + super.name = value;
|
| + _scope.context[name] = this;
|
| + }
|
| +
|
| + //FIXME: fix this reflection bug that shows up when Map is implemented
|
| + operator []=(String key, value) {
|
| + if (key == 'name') {
|
| + name = value;
|
| + } else {
|
| + _controlByName[key] = value;
|
| }
|
| }
|
|
|
| - /**
|
| - * The list of associated child controls.
|
| - */
|
| - get controls => _controlByName;
|
| + //FIXME: fix this reflection bug that shows up when Map is implemented
|
| + operator[](name) {
|
| + if (name == 'valid') {
|
| + return valid;
|
| + } else if (name == 'invalid') {
|
| + return invalid;
|
| + } else {
|
| + return _controlByName[name];
|
| + }
|
| + }
|
|
|
| - /**
|
| - * Returns the child control that is associated with the given name. If multiple
|
| - * child controls contain the same name then the first instance will be returned.
|
| - */
|
| - NgControl operator[](String name) =>
|
| - controls.containsKey(name) ? controls[name][0] : null;
|
| + bool get isEmpty => false;
|
| + bool get isNotEmpty => !isEmpty;
|
| + get values => null;
|
| + get keys => null;
|
| + get length => null;
|
| + clear() => null;
|
| + remove(_) => null;
|
| + containsKey(_) => false;
|
| + containsValue(_) => false;
|
| + addAll(_) => null;
|
| + forEach(_) => null;
|
| + putIfAbsent(_, __) => null;
|
| }
|
|
|
| class NgNullForm extends NgNullControl implements NgForm {
|
| - var _scope;
|
| -
|
| NgNullForm() {}
|
| - operator []=(String key, value) {}
|
| +
|
| operator[](name) {}
|
| + operator []=(String name, value) {}
|
|
|
| - get controls => null;
|
| + bool get isEmpty => false;
|
| + bool get isNotEmpty => true;
|
| + get values => null;
|
| + get keys => null;
|
| + get length => null;
|
| + clear() => null;
|
| + remove(_) => null;
|
| + containsKey(_) => false;
|
| + containsValue(_) => false;
|
| + addAll(_) => null;
|
| + forEach(_) => null;
|
| + putIfAbsent(_, __) => null;
|
| }
|
|
|