From 796a6797c6cb900da22e2843e5b13a13a3575c01 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 13 May 2014 10:14:42 +0200 Subject: [PATCH] Cleaned up dropdowns and save dialog a bit. --- .../controllers/work-packages-controller.js | 6 ++++-- .../components/selectable-title-directive.js | 1 + .../directives/components/with-dropdown.js | 15 ++++++++------- .../javascripts/angular/services/query-service.js | 13 +++++-------- public/templates/work_packages/modals/save.html | 10 ++++++++-- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/angular/controllers/work-packages-controller.js b/app/assets/javascripts/angular/controllers/work-packages-controller.js index 3e07b3b82f..cf9b9ccc24 100644 --- a/app/assets/javascripts/angular/controllers/work-packages-controller.js +++ b/app/assets/javascripts/angular/controllers/work-packages-controller.js @@ -109,7 +109,9 @@ angular.module('openproject.workPackages.controllers') $scope.showSettingsModal = settingsModal.activate; $scope.showShareModal = shareModal.activate; $scope.showSortingModal = sortingModal.activate; + $scope.showSaveModal = function(saveAs){ + $scope.$emit('hideAllDropdowns'); if( saveAs || $scope.query.isNew() ){ saveModal.activate(); } else { @@ -153,8 +155,8 @@ angular.module('openproject.workPackages.controllers') $scope.setupWorkPackagesTable = function(json) { var meta = json.meta; - if (!$scope.columns) $scope.columns = meta.columns; - if (!$scope.groupableColumns) $scope.groupableColumns = meta.groupable_columns; + $scope.columns = meta.columns; + $scope.groupableColumns = meta.groupable_columns; $scope.query = QueryService.getQuery() || QueryService.initQuery($scope.query_id, meta.query, $scope.columns, afterQuerySetupCallback); PaginationService.setPerPageOptions(meta.per_page_options); diff --git a/app/assets/javascripts/angular/directives/components/selectable-title-directive.js b/app/assets/javascripts/angular/directives/components/selectable-title-directive.js index 276977c17a..d4cb9913b7 100644 --- a/app/assets/javascripts/angular/directives/components/selectable-title-directive.js +++ b/app/assets/javascripts/angular/directives/components/selectable-title-directive.js @@ -47,6 +47,7 @@ angular.module('openproject.uiComponents') scope.reload = function(modelId, newTitle) { scope.selectedTitle = newTitle; scope.reloadMethod(modelId); + scope.$emit('hideAllDropdowns'); } scope.filterModels = function(filterBy) { diff --git a/app/assets/javascripts/angular/directives/components/with-dropdown.js b/app/assets/javascripts/angular/directives/components/with-dropdown.js index 0de8cdeb6e..3ba5ae18f9 100644 --- a/app/assets/javascripts/angular/directives/components/with-dropdown.js +++ b/app/assets/javascripts/angular/directives/components/with-dropdown.js @@ -29,11 +29,7 @@ // TODO move to UI components angular.module('openproject.uiComponents') - .directive('withDropdown', function () { - - function hideAllDropdowns() { - jQuery('.dropdown').hide(); - } + .directive('withDropdown', ['$rootScope', function ($rootScope) { function position(dropdown, trigger) { var hOffset = 0, @@ -67,6 +63,10 @@ angular.module('openproject.uiComponents') dropdownId: '@' }, link: function (scope, element, attributes) { + $rootScope.$on('hideAllDropdowns', function(event){ + jQuery('.dropdown').hide(); + }); + element.on('click', function () { var trigger = jQuery(this), @@ -74,11 +74,12 @@ angular.module('openproject.uiComponents') event.preventDefault(); event.stopPropagation(); - hideAllDropdowns(); + + scope.$emit('hideAllDropdowns'); dropdown.show(); position(dropdown, trigger); }); } }; - }); + }]); diff --git a/app/assets/javascripts/angular/services/query-service.js b/app/assets/javascripts/angular/services/query-service.js index f1500bfda7..7982b88a69 100644 --- a/app/assets/javascripts/angular/services/query-service.js +++ b/app/assets/javascripts/angular/services/query-service.js @@ -201,14 +201,11 @@ angular.module('openproject.services') }, doQuery: function(url, params, method, callback) { - if(!method){ - var method = 'GET'; - } - if(!callback){ - var callback = function(response){ - return response.data; - }; - } + method = method || 'GET'; + callback = callback || function(response){ + return response.data; + }; + return $http({ method: method, url: url, diff --git a/public/templates/work_packages/modals/save.html b/public/templates/work_packages/modals/save.html index 29144951e6..484d1f3421 100644 --- a/public/templates/work_packages/modals/save.html +++ b/public/templates/work_packages/modals/save.html @@ -4,8 +4,14 @@

Save

- - +
+ + +
+
+ + +