Skip to content

Commit

Permalink
Changed API call to pass in region number get list of playbooks
Browse files Browse the repository at this point in the history
Changed API call to get list of playbooks to pass in current region number so only playbooks in current region are displayed in drop down.

https://bugzilla.redhat.com/show_bug.cgi?id=1449696
  • Loading branch information
h-kataria committed May 15, 2017
1 parent d315a66 commit c30356e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalogItemFormId', 'miqService', 'postService', 'API', 'catalogItemDataFactory', function($scope, catalogItemFormId, miqService, postService, API, catalogItemDataFactory) {
ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalogItemFormId', 'currentRegion','miqService', 'postService', 'API', 'catalogItemDataFactory', function($scope, catalogItemFormId, currentRegion, miqService, postService, API, catalogItemDataFactory) {
var vm = this;
var sort_options = "&sort_by=name&sort_order=ascending"
var init = function() {
Expand Down Expand Up @@ -39,6 +39,7 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
getRemoveResourcesTypes();
vm.provisioning_cloud_type = '';
vm.retirement_cloud_type = '';
vm.currentRegion = currentRegion;
vm.formId = catalogItemFormId;
vm.afterGet = false;
vm.model = "catalogItemModel";
Expand Down Expand Up @@ -326,8 +327,8 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog

// get playbooks for selected repository
vm.repositoryChanged = function(prefix, id) {
API.get("/api/configuration_script_sources/" + id + "?attributes=configuration_script_payloads" + sort_options).then(function (data) {
vm[prefix + '_playbooks'] = data.configuration_script_payloads;
API.get("/api/configuration_script_sources/" + id + "/configuration_script_payloads?expand=resources&filter[]=region_number=" + vm.currentRegion + sort_options).then(function (data) {
vm[prefix + '_playbooks'] = data.resources;
// if repository has changed
if (id !== vm.catalogItemModel[prefix + '_repository_id']) {
vm.catalogItemModel[prefix + '_playbook_id'] = '';
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,9 @@ def ot_show

def ansible_playbook?
prov_type = params[:st_prov_type] ? params[:st_prov_type] : @record.prov_type
prov_type == "generic_ansible_playbook"
ansible_playbook = prov_type == "generic_ansible_playbook"
@current_region = MiqRegion.my_region.region if ansible_playbook
ansible_playbook
end
helper_method :ansible_playbook?

Expand Down
1 change: 1 addition & 0 deletions app/views/catalog/_st_angular_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@

:javascript
ManageIQ.angular.app.value('catalogItemFormId', '#{@record.id || "new"}');
ManageIQ.angular.app.value('currentRegion', '#{@current_region}');
miq_bootstrap('#form_div');

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('catalogItemFormController', function() {
var $scope, $controller, postService;
var $scope, $controller, currentRegion, postService;

beforeEach(module('ManageIQ'));

Expand Down Expand Up @@ -46,6 +46,7 @@ describe('catalogItemFormController', function() {

$controller = _$controller_('catalogItemFormController', {
$scope: $scope,
currentRegion: currentRegion,
catalogItemFormId: 1000000000001
});
}));
Expand Down

0 comments on commit c30356e

Please sign in to comment.