Skip to content

Commit

Permalink
#672 changed other dialog directives to the controllerAs Pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Katzberg committed Sep 30, 2016
1 parent 8903edc commit b153933
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<div class="md-toolbar-tools">
<h2>{{'data-set-management.home.title' | translate }}</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="closeDialog()">
<md-button class="md-icon-button" ng-click="dataSetSearchDialogController.closeDialog()">
<md-icon md-svg-src="/assets/images/icons/ic_close_white_24px.svg" aria-label="Close dialog"></md-icon>
</md-button>
</div>
</md-toolbar>
<md-dialog-content>
<div ng-repeat="dataSet in dataSets">
<div ng-repeat="dataSet in dataSetSearchDialogController.dataSets">
<dataset-search-result search-result="dataSet._source"></dataset-search-result>
</div>
</md-dialog-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<div class="md-toolbar-tools">
<h2>{{'question-management.home.title' | translate }}</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="closeDialog()">
<md-button class="md-icon-button" ng-click="questionSearchDialogController.closeDialog()">
<md-icon md-svg-src="/assets/images/icons/ic_close_white_24px.svg" aria-label="Close dialog"></md-icon>
</md-button>
</div>
</md-toolbar>
<md-dialog-content>
<div ng-repeat="question in questions">
<div ng-repeat="question in questionSearchDialogController.questions">
<question-search-result search-result="question._source"></question-search-result>
</div>
</md-dialog-content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/* global document*/

'use strict';

angular.module('metadatamanagementApp').service('QuestionSearchDialogService',
function($mdDialog, blockUI, QuestionSearchResource, CleanJSObjectService) {
var questions = [];
var showDialog = function() {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<div class="md-toolbar-tools">
<h2>{{'variable-management.home.title' | translate }}</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="closeDialog()">
<md-button class="md-icon-button" ng-click="variableSearchDialogController.closeDialog()">
<md-icon md-svg-src="/assets/images/icons/ic_close_white_24px.svg" aria-label="Close dialog"></md-icon>
</md-button>
</div>
</md-toolbar>
<md-dialog-content>
<div ng-repeat="variable in variables">
<div ng-repeat="variable in variableSearchDialogController.variables">
<variable-search-result search-result="variable._source"></variable-search-result>
</div>
</md-dialog-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b153933

Please sign in to comment.