-
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.
Change reconfigure setup to include values configured with originally
- Loading branch information
Showing
7 changed files
with
143 additions
and
49 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
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,74 @@ | ||
ManageIQ.angular.app.controller('dialogUserReconfigureController', ['API', 'dialogFieldRefreshService', 'miqService', 'resourceActionId', 'targetId', function(API, dialogFieldRefreshService, miqService, 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) { | ||
miqService.sparkleOff(); | ||
var fullErrorMessage = err.data.error.message; | ||
var allErrorMessages = fullErrorMessage.split('-')[1].split(','); | ||
clearFlash(); | ||
_.forEach(allErrorMessages, (function(errorMessage) { | ||
add_flash(errorMessage, 'error'); | ||
})); | ||
console.log(err); | ||
return Promise.reject(err); | ||
}); | ||
} | ||
|
||
function cancelClicked(_event) { | ||
miqService.redirectBack(__('Dialog Cancelled'), 'info', '/service/explorer'); | ||
} | ||
|
||
function saveable() { | ||
return vm.isValid && ! dialogFieldRefreshService.areFieldsBeingRefreshed; | ||
} | ||
}]); |
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