From 0a82f669ae53754011e97c61aafe4c7015b9b7b1 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 8 Jan 2015 15:58:35 -0500 Subject: [PATCH] Require that all form fields marked 'required' are filled out before we allow config validation --- .../config/config-contact-field.html | 4 ++- .../directives/config/config-setup-tool.html | 30 ++++++++++++------- static/js/core-config-setup.js | 14 +++++++-- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/static/directives/config/config-contact-field.html b/static/directives/config/config-contact-field.html index ce79a405c..9da7dc158 100644 --- a/static/directives/config/config-contact-field.html +++ b/static/directives/config/config-contact-field.html @@ -37,7 +37,9 @@ - +
+ +
diff --git a/static/directives/config/config-setup-tool.html b/static/directives/config/config-setup-tool.html index bd39b3f60..62311d78d 100644 --- a/static/directives/config/config-setup-tool.html +++ b/static/directives/config/config-setup-tool.html @@ -1,6 +1,8 @@
+
+
@@ -78,7 +80,7 @@ A valid SSL certificate and private key files are required to use this option.
- +
Certificate: @@ -206,7 +208,7 @@ - +
SMTP Server: @@ -249,7 +251,7 @@ - +
Username: @@ -299,7 +301,7 @@
- +
@@ -356,7 +358,7 @@ -
LDAP URI:
+
- +
Github: @@ -366,7 +368,7 @@
Github Endpoint: Enable Google Authentication - +
OAuth Client ID: @@ -465,7 +467,7 @@ -
+
Github (Enterprise) Build Triggers
@@ -488,7 +490,7 @@
- +
- +
Github: @@ -498,7 +500,7 @@
Github Endpoint: +
+
diff --git a/static/js/core-config-setup.js b/static/js/core-config-setup.js index d2669bb12..e6a79d4b6 100644 --- a/static/js/core-config-setup.js +++ b/static/js/core-config-setup.js @@ -127,6 +127,16 @@ angular.module("core-config-setup", ['angularFileUpload']) }, ApiService.errorDisplay('Could not validate configuration. Please report this error.')); }; + $scope.checkValidateAndSave = function() { + if ($scope.configform.$valid) { + $scope.validateAndSave(); + return; + } + + $element.find("input.ng-invalid:first")[0].scrollIntoView(); + $element.find("input.ng-invalid:first").focus(); + }; + $scope.validateAndSave = function() { $scope.savingConfiguration = false; $scope.validating = $scope.getServices($scope.config); @@ -593,9 +603,7 @@ angular.module("core-config-setup", ['angularFileUpload']) }, true); $scope.$watch('binding', function(binding) { - if (!binding) { return; } - - var current = binding; + var current = binding || []; var items = []; var itemHash = ''; for (var i = 0; i < current.length; ++i) {