From b153933c6520075b4ab8e05c3d87fa4436ef2520 Mon Sep 17 00:00:00 2001 From: Daniel Katzberg Date: Fri, 30 Sep 2016 15:36:46 +0200 Subject: [PATCH] #672 changed other dialog directives to the controllerAs Pattern --- .../dataSetSearchDialog.controller.js | 13 ++-- .../directives/dataSetSearchDialog.html.tmpl | 4 +- .../directives/dataSetSearchDialog.service.js | 67 ++++++++++--------- .../questionSearchDialog.controller.js | 13 ++-- .../directives/questionSearchDialog.html.tmpl | 4 +- .../questionSearchDialog.service.js | 5 +- .../variableSearchDialog.controller.js | 13 ++-- .../directives/variableSearchDialog.html.tmpl | 4 +- .../variableSearchDialog.service.js | 21 +++--- 9 files changed, 75 insertions(+), 69 deletions(-) diff --git a/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.controller.js b/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.controller.js index 91d17c8cd8..8b98b23a2c 100644 --- a/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.controller.js +++ b/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.controller.js @@ -2,10 +2,11 @@ angular.module('metadatamanagementApp') .controller('DataSetSearchDialogController', - function($mdDialog, $scope, dataSets) { - $scope.dataSets = dataSets; - $scope.closeDialog = $mdDialog.hide; - $scope.$on('$stateChangeStart', function() { - $scope.closeDialog(); + function($mdDialog, $scope, dataSets) { + var ctlr = this; + ctlr.dataSets = dataSets; + ctlr.closeDialog = $mdDialog.hide; + $scope.$on('$stateChangeStart', function() { + ctlr.closeDialog(); + }); }); - }); diff --git a/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.html.tmpl b/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.html.tmpl index a4c09194d8..74a315757a 100644 --- a/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.html.tmpl +++ b/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.html.tmpl @@ -3,13 +3,13 @@

{{'data-set-management.home.title' | translate }}

- +
-
+
diff --git a/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.service.js b/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.service.js index 7606af4544..37a05c8d96 100644 --- a/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.service.js +++ b/src/main/webapp/scripts/datasetmanagement/directives/dataSetSearchDialog.service.js @@ -2,36 +2,37 @@ 'use strict'; angular.module('metadatamanagementApp') -.service('DataSetSearchDialogService', - function($mdDialog, blockUI, DataSetSearchResource, CleanJSObjectService) { - var dataSets = []; - var showDialog = function() { - var dialogParent = angular.element(document.body); - $mdDialog.show({ - controller: 'DataSetSearchDialogController', - parent: dialogParent, - clickOutsideToClose: true, - locals: { - dataSets: dataSets - }, - templateUrl: 'scripts/datasetmanagement/directives/' + - 'dataSetSearchDialog.html.tmpl', - }); - }; - var findByVariableId = function(variableId) { - blockUI.start(); - DataSetSearchResource.findByVariableId(variableId) - .then(function(items) { - if (!CleanJSObjectService.isNullOrEmpty(items)) { - dataSets = items.hits.hits; - blockUI.stop(); - showDialog(); - } else { - blockUI.stop(); - } - }); - }; - return { - findByVariableId: findByVariableId - }; - }); + .service('DataSetSearchDialogService', + function($mdDialog, blockUI, DataSetSearchResource, CleanJSObjectService) { + var dataSets = []; + var showDialog = function() { + var dialogParent = angular.element(document.body); + $mdDialog.show({ + controller: 'DataSetSearchDialogController', + controllerAs: 'dataSetSearchDialogController', + parent: dialogParent, + clickOutsideToClose: true, + locals: { + dataSets: dataSets + }, + templateUrl: 'scripts/datasetmanagement/directives/' + + 'dataSetSearchDialog.html.tmpl', + }); + }; + var findByVariableId = function(variableId) { + blockUI.start(); + DataSetSearchResource.findByVariableId(variableId) + .then(function(items) { + if (!CleanJSObjectService.isNullOrEmpty(items)) { + dataSets = items.hits.hits; + blockUI.stop(); + showDialog(); + } else { + blockUI.stop(); + } + }); + }; + return { + findByVariableId: findByVariableId + }; + }); diff --git a/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.controller.js b/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.controller.js index 25d2e69bf0..56f4c8fef9 100644 --- a/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.controller.js +++ b/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.controller.js @@ -2,10 +2,11 @@ angular.module('metadatamanagementApp') .controller('QuestionSearchDialogController', - function($mdDialog, $scope, questions) { - $scope.questions = questions; - $scope.closeDialog = $mdDialog.hide; - $scope.$on('$stateChangeStart', function() { - $scope.closeDialog(); + function($mdDialog, $scope, questions) { + var ctlr = this; + ctlr.questions = questions; + ctlr.closeDialog = $mdDialog.hide; + $scope.$on('$stateChangeStart', function() { + ctlr.closeDialog(); + }); }); - }); diff --git a/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.html.tmpl b/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.html.tmpl index 0b48bbc82d..242cd64e97 100644 --- a/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.html.tmpl +++ b/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.html.tmpl @@ -3,13 +3,13 @@

{{'question-management.home.title' | translate }}

- +
-
+
diff --git a/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.service.js b/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.service.js index 0f1e9a6380..2cc4beab14 100644 --- a/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.service.js +++ b/src/main/webapp/scripts/questionmanagement/directives/questionSearchDialog.service.js @@ -1,6 +1,6 @@ /* global document*/ - 'use strict'; + angular.module('metadatamanagementApp').service('QuestionSearchDialogService', function($mdDialog, blockUI, QuestionSearchResource, CleanJSObjectService) { var questions = []; @@ -8,13 +8,14 @@ angular.module('metadatamanagementApp').service('QuestionSearchDialogService', var dialogParent = angular.element(document.body); $mdDialog.show({ controller: 'QuestionSearchDialogController', + controllerAs: 'questionSearchDialogController', parent: dialogParent, clickOutsideToClose: true, locals: { questions: questions }, templateUrl: 'scripts/questionmanagement/' + - 'directives/questionSearchDialog.html.tmpl', + 'directives/questionSearchDialog.html.tmpl', }); }; var findByProjectId = function(dataAcquisitionProjectId) { diff --git a/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.controller.js b/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.controller.js index c70757b39a..f8753c0129 100644 --- a/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.controller.js +++ b/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.controller.js @@ -2,10 +2,11 @@ angular.module('metadatamanagementApp') .controller('VariableSearchDialogController', - function($mdDialog, $scope, variables) { - $scope.variables = variables; - $scope.closeDialog = $mdDialog.hide; - $scope.$on('$stateChangeStart', function() { - $scope.closeDialog(); + function($mdDialog, $scope, variables) { + var ctrl = this; + ctrl.variables = variables; + ctrl.closeDialog = $mdDialog.hide; + $scope.$on('$stateChangeStart', function() { + ctrl.closeDialog(); + }); }); - }); diff --git a/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.html.tmpl b/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.html.tmpl index bed77ee85f..a1a38b81e4 100644 --- a/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.html.tmpl +++ b/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.html.tmpl @@ -3,13 +3,13 @@

{{'variable-management.home.title' | translate }}

- +
-
+
diff --git a/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.service.js b/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.service.js index ea39f5f55c..ac9803f87f 100644 --- a/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.service.js +++ b/src/main/webapp/scripts/variablemanagement/directives/variableSearchDialog.service.js @@ -8,27 +8,28 @@ angular.module('metadatamanagementApp').service('VariableSearchDialogService', var dialogParent = angular.element(document.body); $mdDialog.show({ controller: 'VariableSearchDialogController', + controllerAs: 'variableSearchDialogController', parent: dialogParent, clickOutsideToClose: true, locals: { variables: variables }, templateUrl: 'scripts/variablemanagement/' + - 'directives/variableSearchDialog.html.tmpl', + 'directives/variableSearchDialog.html.tmpl', }); }; var findByQuestionId = function(questionId) { blockUI.start(); VariableSearchResource.findByQuestionId(questionId) - .then(function(items) { - if (!CleanJSObjectService.isNullOrEmpty(items)) { - variables = items.hits.hits; - blockUI.stop(); - showDialog(); - } else { - blockUI.stop(); - } - }); + .then(function(items) { + if (!CleanJSObjectService.isNullOrEmpty(items)) { + variables = items.hits.hits; + blockUI.stop(); + showDialog(); + } else { + blockUI.stop(); + } + }); }; return { findByQuestionId: findByQuestionId