Use initAction instead initScope
initScope() is deprecated in Ocata and will be removed in Queens. So this patch changes to use initScope() to initAction(). Change-Id: I66af8b65824d224cb69004557df9f7aaf50afc72 Closes-Bug: #1647921
This commit is contained in:
parent
72435b52f7
commit
538e0104ac
@ -50,7 +50,7 @@
|
||||
};
|
||||
|
||||
var service = {
|
||||
initScope: initScope,
|
||||
initAction: initAction,
|
||||
perform: perform,
|
||||
allowed: allowed
|
||||
};
|
||||
@ -59,15 +59,15 @@
|
||||
|
||||
//////////////
|
||||
|
||||
function initScope($scope) {
|
||||
function initAction() {
|
||||
}
|
||||
|
||||
function perform(selected, $scope) {
|
||||
scope = $scope;
|
||||
scope.workflow = createWorkflow;
|
||||
scope.model = model;
|
||||
scope.$on('$destroy', function() {
|
||||
});
|
||||
}
|
||||
|
||||
function perform() {
|
||||
scope.model.init();
|
||||
return wizardModalService.modal({
|
||||
scope: scope,
|
||||
|
@ -56,8 +56,8 @@
|
||||
|
||||
it('open the modal and should destroy event watchers', function() {
|
||||
spyOn(wizardModalService, 'modal').and.callThrough();
|
||||
service.initScope($scope);
|
||||
service.perform();
|
||||
service.initAction();
|
||||
service.perform(null, $scope);
|
||||
|
||||
$scope.$emit('$destroy');
|
||||
|
||||
@ -74,8 +74,8 @@
|
||||
|
||||
spyOn(wizardModalService, 'modal').and.callThrough();
|
||||
|
||||
service.initScope($scope);
|
||||
service.perform();
|
||||
service.initAction();
|
||||
service.perform(null, $scope);
|
||||
var modalArgs = wizardModalService.modal.calls.argsFor(0)[0];
|
||||
modalArgs.submit();
|
||||
$timeout.flush();
|
||||
|
@ -64,7 +64,7 @@
|
||||
successEvent: events.DELETE_SUCCESS
|
||||
};
|
||||
var service = {
|
||||
initScope: initScope,
|
||||
initAction: initAction,
|
||||
allowed: allowed,
|
||||
perform: perform
|
||||
};
|
||||
@ -76,8 +76,7 @@
|
||||
|
||||
// include this function in your service
|
||||
// if you plan to emit events to the parent controller
|
||||
function initScope($scope) {
|
||||
scope = $scope;
|
||||
function initAction() {
|
||||
}
|
||||
|
||||
function allowed() {
|
||||
@ -85,7 +84,8 @@
|
||||
}
|
||||
|
||||
// delete selected resource objects
|
||||
function perform(selected) {
|
||||
function perform(selected, $scope) {
|
||||
scope = $scope;
|
||||
selected = angular.isArray(selected) ? selected : [selected];
|
||||
context.labels = labelize(selected.length);
|
||||
return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck);
|
||||
|
@ -90,7 +90,7 @@
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(deleteModalService, 'open').and.callThrough();
|
||||
service.initScope($scope, labelize);
|
||||
service.initAction(labelize);
|
||||
});
|
||||
|
||||
function labelize(count) {
|
||||
@ -117,7 +117,7 @@
|
||||
|
||||
function testDoubleObject() {
|
||||
var templates = generateTemplate(2);
|
||||
service.perform(templates);
|
||||
service.perform(templates, $scope);
|
||||
$scope.$apply();
|
||||
|
||||
expect(deleteModalService.open).toHaveBeenCalled();
|
||||
@ -129,7 +129,7 @@
|
||||
spyOn(magnumAPI, 'deleteEntity');
|
||||
var templates = generateTemplate(1);
|
||||
var template = templates[0];
|
||||
service.perform(templates);
|
||||
service.perform(templates, $scope);
|
||||
$scope.$apply();
|
||||
|
||||
var contextArg = deleteModalService.open.calls.argsFor(0)[2];
|
||||
|
@ -49,7 +49,7 @@
|
||||
};
|
||||
|
||||
var service = {
|
||||
initScope: initScope,
|
||||
initAction: initAction,
|
||||
perform: perform,
|
||||
allowed: allowed
|
||||
};
|
||||
@ -58,15 +58,15 @@
|
||||
|
||||
//////////////
|
||||
|
||||
function initScope($scope) {
|
||||
function initAction() {
|
||||
}
|
||||
|
||||
function perform(selected, $scope) {
|
||||
scope = $scope;
|
||||
scope.workflow = createWorkflow;
|
||||
scope.model = model;
|
||||
scope.$on('$destroy', function() {
|
||||
});
|
||||
}
|
||||
|
||||
function perform(selected) {
|
||||
scope.model.init();
|
||||
scope.selected = selected;
|
||||
return wizardModalService.modal({
|
||||
|
@ -56,8 +56,8 @@
|
||||
|
||||
it('open the modal and should destroy event watchers', function() {
|
||||
spyOn(wizardModalService, 'modal').and.callThrough();
|
||||
service.initScope($scope);
|
||||
service.perform();
|
||||
service.initAction();
|
||||
service.perform(null, $scope);
|
||||
|
||||
$scope.$emit('$destroy');
|
||||
|
||||
@ -74,8 +74,8 @@
|
||||
|
||||
spyOn(wizardModalService, 'modal').and.callThrough();
|
||||
|
||||
service.initScope($scope);
|
||||
service.perform();
|
||||
service.initAction();
|
||||
service.perform(null, $scope);
|
||||
var modalArgs = wizardModalService.modal.calls.argsFor(0)[0];
|
||||
modalArgs.submit();
|
||||
$timeout.flush();
|
||||
|
@ -64,7 +64,7 @@
|
||||
successEvent: events.DELETE_SUCCESS
|
||||
};
|
||||
var service = {
|
||||
initScope: initScope,
|
||||
initAction: initAction,
|
||||
allowed: allowed,
|
||||
perform: perform
|
||||
};
|
||||
@ -76,8 +76,7 @@
|
||||
|
||||
// include this function in your service
|
||||
// if you plan to emit events to the parent controller
|
||||
function initScope($scope) {
|
||||
scope = $scope;
|
||||
function initAction() {
|
||||
}
|
||||
|
||||
function allowed() {
|
||||
@ -85,7 +84,8 @@
|
||||
}
|
||||
|
||||
// delete selected resource objects
|
||||
function perform(selected) {
|
||||
function perform(selected, $scope) {
|
||||
scope = $scope;
|
||||
selected = angular.isArray(selected) ? selected : [selected];
|
||||
context.labels = labelize(selected.length);
|
||||
return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck);
|
||||
|
@ -90,7 +90,7 @@
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(deleteModalService, 'open').and.callThrough();
|
||||
service.initScope($scope, labelize);
|
||||
service.initAction(labelize);
|
||||
});
|
||||
|
||||
function labelize(count) {
|
||||
@ -107,7 +107,7 @@
|
||||
|
||||
function testSingleObject() {
|
||||
var clusters = generateCluster(1);
|
||||
service.perform(clusters[0]);
|
||||
service.perform(clusters[0], $scope);
|
||||
$scope.$apply();
|
||||
|
||||
expect(deleteModalService.open).toHaveBeenCalled();
|
||||
@ -117,7 +117,7 @@
|
||||
|
||||
function testDoubleObject() {
|
||||
var clusters = generateCluster(2);
|
||||
service.perform(clusters);
|
||||
service.perform(clusters, $scope);
|
||||
$scope.$apply();
|
||||
|
||||
expect(deleteModalService.open).toHaveBeenCalled();
|
||||
@ -129,7 +129,7 @@
|
||||
spyOn(magnumAPI, 'deleteEntity');
|
||||
var clusters = generateCluster(1);
|
||||
var cluster = clusters[0];
|
||||
service.perform(clusters);
|
||||
service.perform(clusters, $scope);
|
||||
$scope.$apply();
|
||||
|
||||
var contextArg = deleteModalService.open.calls.argsFor(0)[2];
|
||||
|
@ -36,7 +36,7 @@
|
||||
) {
|
||||
|
||||
var service = {
|
||||
initScope: initScope,
|
||||
initAction: initAction,
|
||||
perform: perform,
|
||||
allowed: allowed
|
||||
};
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
//////////////
|
||||
|
||||
function initScope() {
|
||||
function initAction() {
|
||||
}
|
||||
|
||||
function perform(selected) {
|
||||
|
@ -45,7 +45,7 @@
|
||||
selected = {
|
||||
id: '1'
|
||||
};
|
||||
service.initScope();
|
||||
service.initAction();
|
||||
service.perform(selected);
|
||||
expect(magnum.showCertificate).toHaveBeenCalled();
|
||||
});
|
||||
|
@ -47,7 +47,7 @@
|
||||
};
|
||||
|
||||
var service = {
|
||||
initScope: initScope,
|
||||
initAction: initAction,
|
||||
perform: perform,
|
||||
allowed: allowed
|
||||
};
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
//////////////
|
||||
|
||||
function initScope() {
|
||||
function initAction() {
|
||||
}
|
||||
|
||||
function signCertificateModal(html, $modal) {
|
||||
|
@ -65,7 +65,7 @@
|
||||
it('should pass submit() and success()', inject(function($timeout) {
|
||||
|
||||
var selected = {id : 1};
|
||||
service.initScope();
|
||||
service.initAction();
|
||||
service.perform(selected);
|
||||
$timeout.flush();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user