Skip to content

Commit

Permalink
updating compiled tests [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
travis committed Jan 8, 2016
1 parent e311386 commit f8865b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
18 changes: 9 additions & 9 deletions www/build/test/app/components/clickerForm/clickerForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ var __metadata = (this && this.__metadata) || function (k, v) {
var angular2_1 = require('angular2/angular2');
var clickers_1 = require('../../services/clickers');
var ionic_1 = require('ionic-framework/ionic');
var utils_1 = require('../../services/utils');
var ClickerForm = (function () {
function ClickerForm(clickerService, fb) {
this.clickerService = clickerService;
this.clickerForm = fb.group({
clickerName: ['', angular2_1.Validators.required]
this.form = fb.group({
clickerNameInput: ['', angular2_1.Validators.required]
});
this.clickerName = this.clickerForm.controls['clickerName'];
this.clickerNameInput = this.form.controls['clickerNameInput'];
}
ClickerForm.prototype.newClicker = function (formValue) {
var clickerName = null;
// need to mark the clickerName control as touched so validation
// will apply after the user has tried to add a clicker
this.clickerName.markAsTouched();
if (!this.clickerName.valid) {
this.clickerNameInput.markAsTouched();
if (!this.clickerNameInput.valid) {
return false;
}
clickerName = formValue['clickerName'];
this.clickerService.newClicker(clickerName);
// TODO - clear text on input field
this.clickerService.newClicker(formValue['clickerNameInput']);
// reset the value of the contorl and all validation / state
this.clickerNameInput = utils_1.Utils.resetControl(this.clickerNameInput);
};
ClickerForm = __decorate([
angular2_1.Component({
Expand Down
18 changes: 18 additions & 0 deletions www/build/test/app/services/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';
var Utils = (function () {
function Utils() {
}
// bit of a hack here to reset the validation / state on the control as well as the value
// expecting a Control.reset() method to do this but there doesn't seem to be one
// http://stackoverflow.com/questions/33084280/how-to-reset-control-value
Utils.resetControl = function (control) {
control['updateValue']('');
control['_touched'] = false;
control['_untouched'] = true;
control['_pristine'] = true;
control['_dirty'] = false;
return control;
};
return Utils;
})();
exports.Utils = Utils;

0 comments on commit f8865b0

Please sign in to comment.