Skip to content

Commit

Permalink
Fix buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ZitaNemeckova committed Jun 27, 2017
1 parent f7b0063 commit 12d32f4
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ ManageIQ.angular.app.controller('vmCloudAssociateFloatingIpFormController', ['$h
.then(getAssociateFloatingIpFormData)
.catch(miqService.handleFailure);

vm.cancelClicked = function() {
$scope.cancelClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/associate_floating_ip_vm/' + vmCloudAssociateFloatingIpFormId + '?button=cancel';
miqService.miqAjaxButton(url);
};

vm.submitClicked = function() {
$scope.submitClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/associate_floating_ip_vm/' + vmCloudAssociateFloatingIpFormId + '?button=submit';
miqService.miqAjaxButton(url, vm.vmCloudModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ ManageIQ.angular.app.controller('vmCloudAttachFormController', ['$scope', 'vmClo

ManageIQ.angular.scope = vm;

vm.submitClicked = function() {
$scope.submitClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/attach_volume/' + vmCloudAttachFormId + '?button=attach';
miqService.miqAjaxButton(url, vm.vmCloudModel);
};

vm.cancelClicked = function() {
$scope.cancelClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/attach_volume/' + vmCloudAttachFormId + '?button=cancel';
miqService.miqAjaxButton(url);
};

vm.resetClicked = function() {
$scope.resetClicked = function() {
vm.vmCloudModel = angular.copy( vm.modelCopy );
miqService.miqFlash("warn", "All changes have been reset");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ ManageIQ.angular.app.controller('vmCloudDetachFormController', ['$scope', 'vmClo

ManageIQ.angular.scope = vm;

vm.submitClicked = function() {
$scope.submitClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/detach_volume/' + vmCloudDetachFormId + '?button=detach';
miqService.miqAjaxButton(url, vm.vmCloudModel);
};

vm.cancelClicked = function() {
$scope.cancelClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/detach_volume/' + vmCloudDetachFormId + '?button=cancel';
miqService.miqAjaxButton(url);
};

vm.resetClicked = function() {
$scope.resetClicked = function() {
vm.vmCloudModel = angular.copy(vm.modelCopy);
miqService.miqFlash("warn", "All changes have been reset");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ ManageIQ.angular.app.controller('vmCloudDisassociateFloatingIpFormController', [
.then(getDisassociateFloatingIpFormData)
.catch(miqService.handleFailure);

vm.cancelClicked = function() {
$scope.cancelClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/disassociate_floating_ip_vm/' + vmCloudDisassociateFloatingIpFormId + '?button=cancel';
miqService.miqAjaxButton(url);
};

vm.submitClicked = function() {
$scope.submitClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/disassociate_floating_ip_vm/' + vmCloudDisassociateFloatingIpFormId + '?button=submit';
miqService.miqAjaxButton(url, vm.vmCloudModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ ManageIQ.angular.app.controller('vmCloudEvacuateFormController', ['$http', '$sco
vm.modelCopy = angular.copy( vm.vmCloudModel );

ManageIQ.angular.scope = vm;
$scope.saveable = miqService.saveable;

if (vmCloudEvacuateFormId) {
$http.get('/vm_cloud/evacuate_form_fields/' + vmCloudEvacuateFormId)
.then(getEvacuateFormData)
.catch(miqService.handleFailure);
}

vm.cancelClicked = function() {
$scope.cancelClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/evacuate_vm?button=cancel';
if (vmCloudEvacuateFormId) {
Expand All @@ -27,7 +28,7 @@ ManageIQ.angular.app.controller('vmCloudEvacuateFormController', ['$http', '$sco
miqService.miqAjaxButton(url);
};

vm.submitClicked = function() {
$scope.submitClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/evacuate_vm?button=submit';
if (vmCloudEvacuateFormId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ManageIQ.angular.app.controller('vmCloudLiveMigrateFormController', ['$http', '$
.catch(miqService.handleFailure);
}

vm.cancelClicked = function() {
$scope.cancelClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/live_migrate_vm/?button=cancel';
if (vmCloudLiveMigrateFormId) {
Expand All @@ -32,7 +32,7 @@ ManageIQ.angular.app.controller('vmCloudLiveMigrateFormController', ['$http', '$
miqService.miqAjaxButton(url);
};

vm.submitClicked = function() {
$scope.submitClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/live_migrate_vm?button=submit';
if (vmCloudLiveMigrateFormId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ ManageIQ.angular.app.controller('vmCloudResizeFormController', ['$http', '$scope
.catch(miqService.handleFailure);
};

vm.cancelClicked = function() {
$scope.cancelClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/resize_vm/' + vmCloudResizeFormId + '?button=cancel';
miqService.miqAjaxButton(url);
};

vm.submitClicked = function() {
$scope.submitClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/resize_vm/' + vmCloudResizeFormId + '?button=submit';
miqService.miqAjaxButton(url, vm.vmCloudModel);
Expand Down
6 changes: 5 additions & 1 deletion app/views/vm_common/_associate_floating_ip.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
%select{:name => 'floating_ip',
'ng-model' => 'vm.vmCloudModel.floating_ip',
'ng-options' => 'floating_ip.address for floating_ip in vm.floating_ips track by floating_ip.address'}
= render :partial => "layouts/angular/paging_group_buttons.html.haml"

%div_for_paging{'ng-controller' => "pagingDivButtonGroupController",
'paging_div_buttons_state_enabled' => true,
'paging_div_buttons_id' => "angular_paging_div_buttons",
'paging_div_buttons_type' => "Submit"}

:javascript
ManageIQ.angular.app.value('vmCloudAssociateFloatingIpFormId', '#{@record.id}');
Expand Down
14 changes: 8 additions & 6 deletions app/views/vm_common/_attach.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%form#form_div{:name => "angularForm",
'ng-controller' => "vmCloudAttachFormController as vm",
"miq-form" => true,
'form-changed' => true,
"model" => "vm.vmCloudModel",
"model-copy" => 'vm.modelCopy'}
= render :partial => "layouts/flash_msg"
Expand All @@ -14,8 +15,7 @@
= select_tag("volume_id",
options_for_select(@volume_choices),
"ng-model" => "vm.vmCloudModel.volume_id",
:miqrequired => true,
:checkchange => true,
:required => true,
"selectpicker-for-select-tag" => true)
.form-group
%label.col-md-2.control-label
Expand All @@ -24,11 +24,13 @@
%input.form-control{:type => "text",
:name => "device_path",
'ng-model' => "vm.vmCloudModel.device_path",
'ng-maxlength' => 128,
:miqrequired => false,
:checkchange => true}
'ng-maxlength' => 128}
%div_for_paging{'ng-controller' => "pagingDivButtonGroupController",
'paging_div_buttons_state_enabled' => true,
'paging_div_buttons_id' => "angular_paging_div_buttons",
'paging_div_buttons_type' => "Submit"}
= render :partial => "layouts/angular/paging_group_buttons.html.haml"
:javascript
ManageIQ.angular.app.value('vmCloudAttachFormId', '#{@vm.id}');
Expand Down
10 changes: 7 additions & 3 deletions app/views/vm_common/_detach.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%form#form_div{:name => "angularForm",
'ng-controller' => "vmCloudDetachFormController as vm",
"miq-form" => true,
'form-changed' => true,
"model" => "vm.vmCloudModel",
"model-copy" => 'vm.modelCopy'}
= render :partial => "layouts/flash_msg"
Expand All @@ -14,11 +15,14 @@
= select_tag("volume_id",
options_for_select(@volume_choices.sort),
"ng-model" => "vm.vmCloudModel.volume_id",
:miqrequired => true,
:checkchange => true,
:required => true,
"selectpicker-for-select-tag" => "")
= render :partial => "layouts/angular/paging_group_buttons.html.haml"
%div_for_paging{'ng-controller' => "pagingDivButtonGroupController",
'paging_div_buttons_state_enabled' => true,
'paging_div_buttons_id' => "angular_paging_div_buttons",
'paging_div_buttons_type' => "Submit"}
:javascript
ManageIQ.angular.app.value('vmCloudDetachFormId', '#{@vm.id}');
Expand Down
10 changes: 7 additions & 3 deletions app/views/vm_common/_disassociate_floating_ip.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@
'ng-model' => 'vm.vmCloudModel.floating_ip',
'ng-options' => 'floating_ip.address for floating_ip in vm.floating_ips track by floating_ip.address'}

= render :partial => "layouts/angular/paging_group_buttons.html.haml"
%div_for_paging{'ng-controller' => "pagingDivButtonGroupController",
'paging_div_buttons_state_enabled' => true,
'paging_div_buttons_id' => "angular_paging_div_buttons",
'paging_div_buttons_type' => "Submit"}


- unless @explorer
%table{:width => '100%'}
%tr
%td{:align => 'right'}
= button_tag(_("Submit"),
:class => "btn btn-primary",
"ng-click" => "vm.submitClicked()",
"ng-click" => "submitClicked()",
"ng-disabled" => "angularForm.$pristine || angularForm.$invalid",
"ng-class" => "{'btn-disabled': angularForm.$pristine || angularForm.$invalid}")
= button_tag(_("Cancel"),
:class => "btn btn-default",
"ng-click" => "vm.cancelClicked()")
"ng-click" => "cancelClicked()")
:javascript
ManageIQ.angular.app.value('vmCloudDisassociateFloatingIpFormId', '#{@record.id}');
Expand Down
11 changes: 7 additions & 4 deletions app/views/vm_common/_evacuate.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%form#form_div{:name => "angularForm",
'ng-controller' => "vmCloudEvacuateFormController as vm",
"miq-form" => true,
'form-changed' => true,
"model" => "vm.vmCloudModel",
"model-copy" => 'vm.modelCopy'}
= render :partial => "layouts/flash_msg"
Expand All @@ -14,8 +15,7 @@
%input{:type => "checkbox",
:name => "auto_select_host",
'ng-model' => "vm.vmCloudModel.auto_select_host",
:miqrequired => true,
:checkchange => true,
:required => true,
'ng-disabled' => "vm.hosts.length == 0"}
%input{:type => "hidden",
Expand Down Expand Up @@ -48,7 +48,10 @@
'ng-model' => 'vm.vmCloudModel.host',
'ng-options' => 'host.name as host.name for host in vm.hosts track by host.id'}
= render :partial => "layouts/angular/paging_group_buttons.html.haml"
%div_for_paging{'ng-controller' => "pagingDivButtonGroupController",
'paging_div_buttons_state_enabled' => true,
'paging_div_buttons_id' => "angular_paging_div_buttons",
'paging_div_buttons_type' => "Submit"}
%hr
%div
Expand All @@ -64,7 +67,7 @@
%tr
%td{:align => 'right'}
#buttons_on
= button_tag(t = _('Submit'),
= button_tag(t = _('PEpa'),
:class => "btn btn-primary",
:alt => t,
:title => t,
Expand Down
7 changes: 5 additions & 2 deletions app/views/vm_common/_live_migrate.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
'ng-model' => 'vm.mCloudModel.host',
'ng-options' => 'host.name as host.name for host in vm.hosts track by host.id'}
%div_for_paging{'ng-controller' => "pagingDivButtonGroupController",
'paging_div_buttons_state_enabled' => true,
'paging_div_buttons_id' => "angular_paging_div_buttons",
'paging_div_buttons_type' => "Submit"}
%hr
%div
%h3
Expand All @@ -58,8 +63,6 @@
- @quadicon_no_url = true
= render :partial => "layouts/gtl"
= render :partial => "layouts/angular/paging_group_buttons.html.haml"
- unless @explorer
%table{:width => '100%'}
%tr
Expand Down
14 changes: 9 additions & 5 deletions app/views/vm_common/_resize.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%form#form_div{"name" => "angularForm",
"ng-controller" => "vmCloudResizeFormController as vm",
"miq-form" => true,
'form-changed' => true,
"model" => "vm.vmCloudModel",
"model-copy" => "vm.modelCopy"}
= render :partial => "layouts/flash_msg"
Expand All @@ -19,23 +20,26 @@
%select{:name => 'flavor_id',
'ng-model' => 'vm.vmCloudModel.flavor_id',
'ng-options' => 'flavor.id as flavor.name for flavor in vm.flavors track by flavor.id',
:miqrequired => true,
:checkchange => true}
:required => true}
%div_for_paging{'ng-controller' => "pagingDivButtonGroupController",
'paging_div_buttons_state_enabled' => true,
'paging_div_buttons_id' => "angular_paging_div_buttons",
'paging_div_buttons_type' => "Submit"}
= render :partial => "layouts/angular/paging_group_buttons.html.haml"
- unless @explorer
%table{:width => '100%'}
%tr
%td{:align => 'right'}
= button_tag(_("Submit"),
:class => "btn btn-primary",
"ng-click" => "vm.submitClicked()",
"ng-click" => "submitClicked()",
"ng-disabled" => "angularForm.$pristine || angularForm.$invalid",
"ng-class" => "{'btn-disabled': angularForm.$pristine || angularForm.$invalid}")
= button_tag(_("Cancel"),
:class => "btn btn-default",
"ng-click" => "vm.cancelClicked()")
"ng-click" => "cancelClicked()")
:javascript
ManageIQ.angular.app.value('vmCloudResizeFormId', '#{@record.id}');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ describe('vmCloudAssociateFloatingIpFormController', function() {

describe('#submitClicked', function() {
beforeEach(function() {
setTimeout(vm.submitClicked);
setTimeout($scope.submitClicked);
});

it('delegates to miqService.miqAjaxButton', function(done) {
setTimeout(function() {
expect(miqService.miqAjaxButton).toHaveBeenCalledWith(
'/vm_cloud/associate_floating_ip_vm/1000000000001?button=submit',
true
$scope.vm.vmCloudModel
);
done();
});
Expand All @@ -42,7 +42,7 @@ describe('vmCloudAssociateFloatingIpFormController', function() {
$scope.angularForm = {
$setPristine: function(value) {},
};
setTimeout(vm.cancelClicked);
setTimeout($scope.cancelClicked);
});

it('delegates to miqService.miqAjaxButton', function(done) {
Expand Down

0 comments on commit 12d32f4

Please sign in to comment.