Skip to content

Commit

Permalink
Inactive buttons should not be clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
AparnaKarve committed Sep 24, 2015
1 parent feb675c commit 528446f
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 32 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
//= require directives/repository/valid_unc_path
//= require services/miq_service
//= require services/timer_option_service
//= require controllers/buttons/button_group_controller
//= require controllers/ems_common/ems_common_form_controller
//= require controllers/host/host_form_controller
//= require controllers/provider_foreman/provider_foreman_form_controller
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ManageIQ.angularApplication.controller('buttonGroupController', ['$http', '$scope', 'miqService', function($http, $scope, miqService) {
var init = function() {
$scope.saveable = miqService.saveable;
$scope.disabledClick = miqService.disabledClick;
};
init();
}]);
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ ManageIQ.angularApplication.controller('emsCommonFormController', ['$http', '$sc
};
$scope.formId = emsCommonFormId;
$scope.afterGet = false;
$scope.saveable = miqService.saveable;
$scope.validateClicked = miqService.validateWithREST;
$scope.disabledClick = miqService.disabledClick;
$scope.modelCopy = angular.copy( $scope.emsCommonModel );
$scope.formFieldsUrl = $attrs.formFieldsUrl;
$scope.createUrl = $attrs.createUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ ManageIQ.angularApplication.controller('hostFormController', ['$http', '$scope',
$scope.modelCopy = angular.copy( $scope.hostModel );
$scope.afterGet = false;
$scope.formId = hostFormId;
$scope.saveable = miqService.saveable;
$scope.validateClicked = miqService.validateWithAjax;
$scope.formFieldsUrl = $attrs.formFieldsUrl;
$scope.createUrl = $attrs.createUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ManageIQ.angularApplication.controller('tenantFormController', ['$http', '$scope
$scope.formId = tenantFormId;
$scope.afterGet = false;
$scope.modelCopy = angular.copy( $scope.tenantModel );
$scope.saveable = miqService.saveable;

ManageIQ.angularApplication.$scope = $scope;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ManageIQ.angularApplication.controller('tenantQuotaFormController',['$http', '$s
$scope.formId = tenantQuotaFormId;
$scope.afterGet = false;
$scope.modelCopy = angular.copy( $scope.tenantQuotaModel );
$scope.saveable = miqService.saveable;

ManageIQ.angularApplication.$scope = $scope;
$scope.newRecord = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ ManageIQ.angularApplication.controller('scheduleFormController', ['$http', '$sco
$scope.afterGet = false;
$scope.validateClicked = miqService.validateWithAjax;
$scope.modelCopy = angular.copy( $scope.scheduleModel );
$scope.saveable = miqService.saveable;

ManageIQ.angularApplication.$scope = $scope;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- else
- validate = "validateClicked('#{url_for(:action => validate_url, :id => id, :type => valtype, :button => "validate")}')"

%div{'ng-show' => ng_show}
%div{"ng-show" => ng_show, "ng-controller" => "buttonGroupController"}
= button_tag("Validate",
:class => "btn btn-primary btn-xs btn-disabled",
:alt => "Validate",
Expand Down
8 changes: 4 additions & 4 deletions app/views/layouts/angular/_x_edit_buttons_angular.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.button-group
.button-group{"ng-controller" => "buttonGroupController"}
= button_tag("Add",
"class" => "btn btn-primary btn-disabled",
"class" => "btn btn-primary btn-disabled",
:alt => "Add",
:title => "Add",
"ng-click" => "addClicked($event, false)",
"ng-click" => "disabledClick($event)",
"ng-show" => "newRecord && !saveable(angularForm)")
= button_tag("Add",
Expand All @@ -17,7 +17,7 @@
:class => "btn btn-primary btn-disabled",
:alt => "Save changes",
:title => "Save changes",
"ng-click" => "saveClicked($event, false)",
"ng-click" => "disabledClick($event)",
"ng-show" => "!newRecord && !saveable(angularForm)")
= button_tag("Save",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
describe('buttonGroupController', function() {
var $scope, $controller, $httpBackend, miqService;

beforeEach(module('ManageIQ.angularApplication'));

beforeEach(inject(function(_$httpBackend_, $rootScope, _$controller_, _miqService_) {
miqService = _miqService_;
$scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
$controller = _$controller_('buttonGroupController',
{$http: $httpBackend, $scope: $scope, miqService: miqService});
}));

afterEach(function() {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});

describe('saveable should exist in the scope', function() {
it('returns true', function() {
expect($scope.saveable).toBeDefined();
});
});

describe('disabledClick should exist in the scope', function() {
it('returns true', function() {
expect($scope.disabledClick).toBeDefined();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,6 @@ describe('emsCommonFormController', function() {
});
});

describe('saveable should exist in the scope', function() {
beforeEach(function() {
$httpBackend.flush();
});
it('returns true', function() {
expect($scope.saveable).toBeDefined();
});
});

describe('Validates credential fields', function() {
beforeEach(function() {
$httpBackend.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,6 @@ describe('hostFormController', function() {
});
});

describe('saveable should exist in the scope', function() {
it('returns true', function() {
expect($scope.saveable).toBeDefined();
});
});

describe('Validates credential fields', function() {
beforeEach(inject(function($compile, miqService) {
var angularForm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,6 @@ describe('scheduleFormController', function() {
});
});

describe('saveable should exist in the scope', function() {
it('returns true', function() {
expect($scope.saveable).toBeDefined();
});
});

describe('Validates credential fields', function() {
beforeEach(inject(function($compile, miqService) {
var angularForm;
Expand Down
1 change: 1 addition & 0 deletions spec/javascripts/support/jasmine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ src_files:
- javascripts/controllers/schedule/schedule_form_controller.js
- javascripts/controllers/repository/repository_form_controller.js
- javascripts/controllers/retirement/retirement_form_controller.js
- javascripts/controllers/buttons/button_group_controller.js
- javascripts/directives/autofocus.js
- javascripts/directives/repository/valid_unc_path.js
- javascripts/directives/checkchange.js
Expand Down

0 comments on commit 528446f

Please sign in to comment.