From 08d3a735ab3409f491a65e69b9578800d0576eb3 Mon Sep 17 00:00:00 2001 From: gconsidine Date: Tue, 1 Aug 2017 14:36:45 -0400 Subject: [PATCH] Add ability to submit cred form after api validation error --- .../credentials/edit-credentials.controller.js | 14 +++++++++----- .../client/lib/components/form/form.directive.js | 1 - .../lib/components/input/message.partial.html | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/awx/ui/client/features/credentials/edit-credentials.controller.js b/awx/ui/client/features/credentials/edit-credentials.controller.js index ccdb687761..92a3dc357c 100644 --- a/awx/ui/client/features/credentials/edit-credentials.controller.js +++ b/awx/ui/client/features/credentials/edit-credentials.controller.js @@ -6,6 +6,9 @@ function EditCredentialsController (models, $state, $scope, strings) { let credentialType = models.credentialType; let organization = models.organization; + let omit = ['user', 'team', 'inputs']; + let isEditable = credential.isEditable(); + vm.mode = 'edit'; vm.strings = strings; vm.panelTitle = credential.get('name'); @@ -35,11 +38,12 @@ function EditCredentialsController (models, $state, $scope, strings) { // Only exists for permissions compatibility $scope.credential_obj = credential.get(); - vm.form = credential.createFormSchema({ - omit: ['user', 'team', 'inputs'] - }); - - vm.form.disabled = !credential.isEditable(); + if (isEditable) { + vm.form = credential.createFormSchema('put', { omit }); + } else { + vm.form = credential.createFormSchema({ omit }); + vm.form.disabled = !isEditable; + } vm.form.organization._resource = 'organization'; vm.form.organization._model = organization; diff --git a/awx/ui/client/lib/components/form/form.directive.js b/awx/ui/client/lib/components/form/form.directive.js index e8b80898aa..e4956d1101 100644 --- a/awx/ui/client/lib/components/form/form.directive.js +++ b/awx/ui/client/lib/components/form/form.directive.js @@ -149,7 +149,6 @@ function AtFormController (eventService, strings) { errorMessageSet = true; component.state._rejected = true; - component.state._isValid = false; component.state._message = errors[component.state.id].join(' '); }); } diff --git a/awx/ui/client/lib/components/input/message.partial.html b/awx/ui/client/lib/components/input/message.partial.html index 00951434a6..cb73ab9620 100644 --- a/awx/ui/client/lib/components/input/message.partial.html +++ b/awx/ui/client/lib/components/input/message.partial.html @@ -1,4 +1,4 @@ -

+

{{ state._message }}