From d4b03832ed86500f2f26ea2041b422b1b87bdaac Mon Sep 17 00:00:00 2001 From: Shu Muto Date: Thu, 24 Aug 2017 17:00:52 +0900 Subject: [PATCH] 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 --- .../queues/actions/create-queue.service.js | 25 +++------------ .../actions/create-subscription.service.js | 13 ++------ .../queues/actions/update-queue.service.js | 23 +++----------- .../queue-details/queue-details.controller.js | 28 ++--------------- .../queue-metadata.controller.js | 2 +- .../subscription/subscription.controller.js | 31 ++----------------- 6 files changed, 18 insertions(+), 104 deletions(-) diff --git a/zaqar_ui/static/dashboard/project/queues/actions/create-queue.service.js b/zaqar_ui/static/dashboard/project/queues/actions/create-queue.service.js index accde35..e2e7fe6 100644 --- a/zaqar_ui/static/dashboard/project/queues/actions/create-queue.service.js +++ b/zaqar_ui/static/dashboard/project/queues/actions/create-queue.service.js @@ -69,37 +69,22 @@ 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) { 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({ - scope: scope, + return wizard.modal({ workflow: createQueueWorkflow, submit: submit - }); + }).result; } function allowed() { 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); } diff --git a/zaqar_ui/static/dashboard/project/queues/actions/create-subscription.service.js b/zaqar_ui/static/dashboard/project/queues/actions/create-subscription.service.js index a10f120..ef1803d 100644 --- a/zaqar_ui/static/dashboard/project/queues/actions/create-subscription.service.js +++ b/zaqar_ui/static/dashboard/project/queues/actions/create-subscription.service.js @@ -70,22 +70,12 @@ function initAction() { } - function onSubscriptionChange(e, subscription) { - angular.extend(model, subscription); - e.stopPropagation(); - } - function perform(queue, $scope) { scope = $scope; - var subWatcher = $scope.$on(events.SUBSCRIPTION_CHANGED, onSubscriptionChange); - $scope.$on('$destroy', function destroy() { - subWatcher(); - }); model = { subscriber: null, ttl: null, options: {} }; model.queueName = queue.name; wizard.modal({ - scope: scope, workflow: createSubWorkflow, submit: submit }); @@ -95,7 +85,8 @@ return policy.ifAllowed({ rules: [['queue', 'add_subscriptions']] }); } - function submit() { + function submit(stepModels) { + angular.extend(model, stepModels.subscriptionForm); return zaqar.addSubscription(model).then(success, error); } diff --git a/zaqar_ui/static/dashboard/project/queues/actions/update-queue.service.js b/zaqar_ui/static/dashboard/project/queues/actions/update-queue.service.js index 8d8108f..05c3626 100644 --- a/zaqar_ui/static/dashboard/project/queues/actions/update-queue.service.js +++ b/zaqar_ui/static/dashboard/project/queues/actions/update-queue.service.js @@ -69,30 +69,13 @@ 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) { 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; - $scope.queue = model; model.queue_name = queue.name; wizard.modal({ - scope: $scope, + data: {queue: model}, workflow: updateQueueWorkflow, submit: submit }); @@ -102,7 +85,9 @@ 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); } diff --git a/zaqar_ui/static/dashboard/project/queues/steps/queue-details/queue-details.controller.js b/zaqar_ui/static/dashboard/project/queues/steps/queue-details/queue-details.controller.js index a9c275f..4ffd8fd 100644 --- a/zaqar_ui/static/dashboard/project/queues/steps/queue-details/queue-details.controller.js +++ b/zaqar_ui/static/dashboard/project/queues/steps/queue-details/queue-details.controller.js @@ -22,44 +22,22 @@ .controller('horizon.dashboard.project.queues.steps.QueueDetailsController', controller); controller.$inject = [ - '$scope', - 'horizon.app.core.openstack-service-api.zaqar', - 'horizon.dashboard.project.queues.events' + '$scope' ]; /** * @ngdoc controller * @name horizon.dashboard.project.queues.steps.QueueDetailsController * @param {Object} $scope - * @param {Object} zaqar - * @param {Object} events * @returns {undefined} Returns nothing * @description This controller is use for creating a queue. */ - function controller($scope, zaqar, events) { + function controller($scope) { var ctrl = this; ctrl.queue = $scope.queue ? $scope.queue : {}; ctrl.update = $scope.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); - } - } + $scope.stepModels.queueDetailsForm = ctrl.queue; } // end of controller })(); diff --git a/zaqar_ui/static/dashboard/project/queues/steps/queue-metadata/queue-metadata.controller.js b/zaqar_ui/static/dashboard/project/queues/steps/queue-metadata/queue-metadata.controller.js index 78d45b1..b0fdf1d 100644 --- a/zaqar_ui/static/dashboard/project/queues/steps/queue-metadata/queue-metadata.controller.js +++ b/zaqar_ui/static/dashboard/project/queues/steps/queue-metadata/queue-metadata.controller.js @@ -105,7 +105,7 @@ function onMetadataChanged(newValue, oldValue) { if (newValue !== oldValue) { - $scope.$emit(events.METADATA_CHANGED, newValue); + $scope.stepModels.queueMetadataForm = newValue; } } diff --git a/zaqar_ui/static/dashboard/project/queues/steps/subscription/subscription.controller.js b/zaqar_ui/static/dashboard/project/queues/steps/subscription/subscription.controller.js index 81a6440..95f35fd 100644 --- a/zaqar_ui/static/dashboard/project/queues/steps/subscription/subscription.controller.js +++ b/zaqar_ui/static/dashboard/project/queues/steps/subscription/subscription.controller.js @@ -23,46 +23,21 @@ SubscriptionController); SubscriptionController.$inject = [ - '$scope', - 'horizon.app.core.openstack-service-api.zaqar', - 'horizon.dashboard.project.queues.events' + '$scope' ]; /** * @ngdoc controller * @name horizon.dashboard.project.queues.steps.SubscriptionController * @param {Object} $scope - * @param {Object} zaqar - * @param {Object} events * @returns {undefined} Returns nothing * @description This controller is use for creating a subscription. */ - function SubscriptionController($scope, zaqar, events) { + function SubscriptionController($scope) { var ctrl = this; ctrl.subscription = { ttl: 3600 }; ctrl.update = false; - - //////////////////////// - - // 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); - } - } - + $scope.stepModels.subscriptionForm = ctrl.subscription; } // end of SubscriptionController - })();