Un-use 'scope' attribute for wizard modal service

'scope' attribute for wizard modal service is deprecated.
It will be removed on Queens.
So this patch changes not to use 'scope' attribute.

Change-Id: Id716858468fcb05dcce9160809308b4213da923c
Closes-Bug: #1647995
This commit is contained in:
Shu Muto 2017-08-24 17:00:52 +09:00
parent 9fb9727321
commit d4b03832ed
6 changed files with 18 additions and 104 deletions

View File

@ -69,37 +69,22 @@
function initAction() { function initAction() {
} }
function onDetailChange(e, queue) {
angular.extend(model, queue);
e.stopPropagation();
}
function onMetadataChange(e, metadata) {
model.metadata = metadata;
e.stopPropagation();
}
function perform(selected, $scope) { function perform(selected, $scope) {
scope = $scope; scope = $scope;
var queueWatcher = $scope.$on(events.DETAILS_CHANGED, onDetailChange);
var metadataWatcher = $scope.$on(events.METADATA_CHANGED, onMetadataChange);
$scope.$on('$destroy', function destroy() {
queueWatcher();
metadataWatcher();
});
wizard.modal({ return wizard.modal({
scope: scope,
workflow: createQueueWorkflow, workflow: createQueueWorkflow,
submit: submit submit: submit
}); }).result;
} }
function allowed() { function allowed() {
return policy.ifAllowed({ rules: [['queue', 'add_queue']] }); return policy.ifAllowed({ rules: [['queue', 'add_queue']] });
} }
function submit() { function submit(stepModels) {
model = stepModels.queueDetailsForm;
model.metadata = stepModels.queueMetadataForm;
return zaqar.createQueue(model).then(success); return zaqar.createQueue(model).then(success);
} }

View File

@ -70,22 +70,12 @@
function initAction() { function initAction() {
} }
function onSubscriptionChange(e, subscription) {
angular.extend(model, subscription);
e.stopPropagation();
}
function perform(queue, $scope) { function perform(queue, $scope) {
scope = $scope; scope = $scope;
var subWatcher = $scope.$on(events.SUBSCRIPTION_CHANGED, onSubscriptionChange);
$scope.$on('$destroy', function destroy() {
subWatcher();
});
model = { subscriber: null, ttl: null, options: {} }; model = { subscriber: null, ttl: null, options: {} };
model.queueName = queue.name; model.queueName = queue.name;
wizard.modal({ wizard.modal({
scope: scope,
workflow: createSubWorkflow, workflow: createSubWorkflow,
submit: submit submit: submit
}); });
@ -95,7 +85,8 @@
return policy.ifAllowed({ rules: [['queue', 'add_subscriptions']] }); return policy.ifAllowed({ rules: [['queue', 'add_subscriptions']] });
} }
function submit() { function submit(stepModels) {
angular.extend(model, stepModels.subscriptionForm);
return zaqar.addSubscription(model).then(success, error); return zaqar.addSubscription(model).then(success, error);
} }

View File

@ -69,30 +69,13 @@
function initAction() { function initAction() {
} }
function onDetailChange(e, queue) {
angular.extend(model, queue);
e.stopPropagation();
}
function onMetadataChange(e, metadata) {
model.metadata = metadata;
e.stopPropagation();
}
function perform(queue, $scope) { function perform(queue, $scope) {
scope = $scope; scope = $scope;
var queueWatcher = $scope.$on(events.DETAILS_CHANGED, onDetailChange);
var metadataWatcher = $scope.$on(events.METADATA_CHANGED, onMetadataChange);
$scope.$on('$destroy', function destroy() {
queueWatcher();
metadataWatcher();
});
model = queue; model = queue;
$scope.queue = model;
model.queue_name = queue.name; model.queue_name = queue.name;
wizard.modal({ wizard.modal({
scope: $scope, data: {queue: model},
workflow: updateQueueWorkflow, workflow: updateQueueWorkflow,
submit: submit submit: submit
}); });
@ -102,7 +85,9 @@
return policy.ifAllowed({ rules: [['queue', 'update_queue']] }); return policy.ifAllowed({ rules: [['queue', 'update_queue']] });
} }
function submit() { function submit(stepModels) {
model = stepModels.queueDetailsForm;
model.metadata = stepModels.queueMetadataForm;
return zaqar.updateQueue(model).then(success); return zaqar.updateQueue(model).then(success);
} }

View File

@ -22,44 +22,22 @@
.controller('horizon.dashboard.project.queues.steps.QueueDetailsController', controller); .controller('horizon.dashboard.project.queues.steps.QueueDetailsController', controller);
controller.$inject = [ controller.$inject = [
'$scope', '$scope'
'horizon.app.core.openstack-service-api.zaqar',
'horizon.dashboard.project.queues.events'
]; ];
/** /**
* @ngdoc controller * @ngdoc controller
* @name horizon.dashboard.project.queues.steps.QueueDetailsController * @name horizon.dashboard.project.queues.steps.QueueDetailsController
* @param {Object} $scope * @param {Object} $scope
* @param {Object} zaqar
* @param {Object} events
* @returns {undefined} Returns nothing * @returns {undefined} Returns nothing
* @description This controller is use for creating a queue. * @description This controller is use for creating a queue.
*/ */
function controller($scope, zaqar, events) { function controller($scope) {
var ctrl = this; var ctrl = this;
ctrl.queue = $scope.queue ? $scope.queue : {}; ctrl.queue = $scope.queue ? $scope.queue : {};
ctrl.update = $scope.queue; ctrl.update = $scope.queue;
//////////////////////// $scope.stepModels.queueDetailsForm = ctrl.queue;
// watch this object, when it changes, emit to parent listeners
var watcher = $scope.$watchCollection(getQueue, onQueneChange);
$scope.$on('$destroy', function() {
watcher();
});
////////////////////////
function getQueue() {
return ctrl.queue;
}
function onQueneChange(newValue, oldValue) {
if (newValue !== oldValue) {
$scope.$emit(events.DETAILS_CHANGED, newValue);
}
}
} // end of controller } // end of controller
})(); })();

View File

@ -105,7 +105,7 @@
function onMetadataChanged(newValue, oldValue) { function onMetadataChanged(newValue, oldValue) {
if (newValue !== oldValue) { if (newValue !== oldValue) {
$scope.$emit(events.METADATA_CHANGED, newValue); $scope.stepModels.queueMetadataForm = newValue;
} }
} }

View File

@ -23,46 +23,21 @@
SubscriptionController); SubscriptionController);
SubscriptionController.$inject = [ SubscriptionController.$inject = [
'$scope', '$scope'
'horizon.app.core.openstack-service-api.zaqar',
'horizon.dashboard.project.queues.events'
]; ];
/** /**
* @ngdoc controller * @ngdoc controller
* @name horizon.dashboard.project.queues.steps.SubscriptionController * @name horizon.dashboard.project.queues.steps.SubscriptionController
* @param {Object} $scope * @param {Object} $scope
* @param {Object} zaqar
* @param {Object} events
* @returns {undefined} Returns nothing * @returns {undefined} Returns nothing
* @description This controller is use for creating a subscription. * @description This controller is use for creating a subscription.
*/ */
function SubscriptionController($scope, zaqar, events) { function SubscriptionController($scope) {
var ctrl = this; var ctrl = this;
ctrl.subscription = { ttl: 3600 }; ctrl.subscription = { ttl: 3600 };
ctrl.update = false; ctrl.update = false;
$scope.stepModels.subscriptionForm = ctrl.subscription;
////////////////////////
// watch this object, when it changes, emit to parent listeners
var watcher = $scope.$watchCollection(getSubscription, onSubscriptionChange);
$scope.$on('$destroy', function() {
watcher();
});
////////////////////////
function getSubscription() {
return ctrl.subscription;
}
function onSubscriptionChange(newValue, oldValue) {
if (newValue !== oldValue) {
$scope.$emit(events.SUBSCRIPTION_CHANGED, newValue);
}
}
} // end of SubscriptionController } // end of SubscriptionController
})(); })();