-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4226 from eclarizio/BZ1591484-Reconfigure
Change reconfigure setup to include values configured with originally
- Loading branch information
Showing
10 changed files
with
164 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
app/assets/javascripts/controllers/dialog_user/dialog_user_reconfigure_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
ManageIQ.angular.app.controller('dialogUserReconfigureController', ['API', 'dialogFieldRefreshService', 'miqService', 'dialogUserSubmitErrorHandlerService', 'resourceActionId', 'targetId', function(API, dialogFieldRefreshService, miqService, dialogUserSubmitErrorHandlerService, resourceActionId, targetId) { | ||
var vm = this; | ||
|
||
vm.$onInit = function() { | ||
var apiCall = new Promise(function(resolve) { | ||
var url = '/api/services/' + targetId + | ||
'?attributes=reconfigure_dialog'; | ||
|
||
resolve(API.get(url).then(init)); | ||
}); | ||
|
||
Promise.resolve(apiCall).then(miqService.refreshSelectpicker); | ||
}; | ||
|
||
function init(data) { | ||
vm.dialogId = data.reconfigure_dialog[0].id; | ||
vm.dialog = data.reconfigure_dialog[0]; | ||
vm.dialogLoaded = true; | ||
} | ||
|
||
vm.refreshField = refreshField; | ||
vm.setDialogData = setDialogData; | ||
vm.refreshUrl = '/api/service_dialogs/'; | ||
|
||
vm.submitButtonClicked = submitButtonClicked; | ||
vm.cancelClicked = cancelClicked; | ||
vm.saveable = saveable; | ||
vm.isValid = false; | ||
|
||
function refreshField(field) { | ||
var idList = { | ||
dialogId: vm.dialogId, | ||
resourceActionId: resourceActionId, | ||
targetId: targetId, | ||
targetType: "service", | ||
}; | ||
|
||
return dialogFieldRefreshService.refreshField(vm.dialogData, [field.name], vm.refreshUrl, idList); | ||
} | ||
|
||
function setDialogData(data) { | ||
vm.isValid = data.validations.isValid; | ||
vm.dialogData = data.data; | ||
} | ||
|
||
function submitButtonClicked() { | ||
miqService.sparkleOn(); | ||
|
||
var apiData = {action: 'reconfigure', resource: _.omit(vm.dialogData, 'action')}; | ||
var apiSubmitEndpoint = '/api/services/' + targetId; | ||
|
||
return API.post(apiSubmitEndpoint, apiData, {skipErrors: [400]}).then(function() { | ||
miqService.redirectBack(__('Order Request was Submitted'), 'info', '/service/explorer'); | ||
}).catch(function(err) { | ||
return Promise.reject(dialogUserSubmitErrorHandlerService.handleError(err)); | ||
}); | ||
} | ||
|
||
function cancelClicked(_event) { | ||
miqService.redirectBack(__('Dialog Cancelled'), 'info', '/service/explorer'); | ||
} | ||
|
||
function saveable() { | ||
return vm.isValid && ! dialogFieldRefreshService.areFieldsBeingRefreshed; | ||
} | ||
}]); |
13 changes: 13 additions & 0 deletions
13
app/assets/javascripts/services/dialog_user_submit_error_handler_service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ManageIQ.angular.app.service('dialogUserSubmitErrorHandlerService', ['miqService', function(miqService) { | ||
this.handleError = function(err) { | ||
miqService.sparkleOff(); | ||
var fullErrorMessage = err.data.error.message; | ||
var allErrorMessages = fullErrorMessage.split('-')[1].split(','); | ||
clearFlash(); | ||
_.forEach(allErrorMessages, function(errorMessage) { | ||
add_flash(errorMessage, 'error'); | ||
}); | ||
console.error(err); | ||
return err; | ||
}; | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#main_div | ||
.row.wrapper{"ng-controller" => "dialogUserReconfigureController as vm"} | ||
.spinner{'ng-show' => "!vm.dialogLoaded"} | ||
.col-md-12.col-lg-12{'ng-if' => 'vm.dialog'} | ||
%dialog-user{"dialog" =>"vm.dialog", "refresh-field" => "vm.refreshField(field)", "on-update" => "vm.setDialogData(data)"} | ||
.clearfix | ||
.pull-right.button-group{'ng-show' => "vm.dialogLoaded"} | ||
%miq-button{:name => t = _("Submit"), | ||
:title => t, | ||
:alt => t, | ||
:enabled => 'vm.saveable()', | ||
'on-click' => "vm.submitButtonClicked()", | ||
:primary => 'true'} | ||
%miq-button{:name => t = _("Cancel"), | ||
:title => t, | ||
:alt => t, | ||
:enabled => 'true', | ||
'on-click' => "vm.cancelClicked($event)"} | ||
:javascript | ||
ManageIQ.angular.app.value('resourceActionId', '#{resource_action_id}'); | ||
ManageIQ.angular.app.value('targetId', '#{target_id}'); | ||
miq_bootstrap('.wrapper'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters