From f1d28556fbbe787e5d347e1a7af97e859b38be24 Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Sat, 14 Jun 2014 15:07:45 +0200 Subject: [PATCH 1/9] Add angular-busy --- app/assets/javascripts/angular/openproject-app.js | 3 ++- app/assets/javascripts/application.js.erb | 1 + app/assets/stylesheets/_external.sass.erb | 1 + bower.json | 3 ++- config/application.rb | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/angular/openproject-app.js b/app/assets/javascripts/angular/openproject-app.js index a498de2b24..7959160828 100644 --- a/app/assets/javascripts/angular/openproject-app.js +++ b/app/assets/javascripts/angular/openproject-app.js @@ -117,7 +117,8 @@ var openprojectApp = angular.module('openproject', [ 'ngAnimate', 'ngSanitize', 'truncate', - 'feature-flags' + 'feature-flags', + 'cgBusy' ]); window.appBasePath = jQuery('meta[name=app_base_path]').attr('content') || ''; diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index b0e46d5c0a..bf2e2fb273 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -65,6 +65,7 @@ //= require angular-sanitize //= require angular-truncate //= require angular-feature-flags/dist/featureFlags.js +//= require angular-busy //= require angular-context-menu diff --git a/app/assets/stylesheets/_external.sass.erb b/app/assets/stylesheets/_external.sass.erb index 5f0e992c8f..882cf32b06 100644 --- a/app/assets/stylesheets/_external.sass.erb +++ b/app/assets/stylesheets/_external.sass.erb @@ -31,3 +31,4 @@ @import "<%= asset_path("select2/select2.css") %>" @import "<%= asset_path("jquery-ui/themes/base/jquery-ui.css") %>" +@import "<%= asset_path("angular-busy/dist/angular-busy.css") %>" diff --git a/bower.json b/bower.json index b564140c32..26236a5175 100644 --- a/bower.json +++ b/bower.json @@ -22,7 +22,8 @@ "jquery-migrate": "~1.2.1", "momentjs": "~2.6.0", "moment-timezone": "~0.0.6", - "angular-context-menu": "0.1.1" + "angular-context-menu": "0.1.1", + "angular-busy": "~4.0.4" }, "devDependencies": { "mocha": "~1.14.0", diff --git a/config/application.rb b/config/application.rb index ba27f5df3c..78d5df6595 100644 --- a/config/application.rb +++ b/config/application.rb @@ -103,6 +103,7 @@ module OpenProject config.assets.paths << bower_assets_path.join(*%w(select2)).to_s config.assets.paths << bower_assets_path.join(*%w(jquery-ui themes base)).to_s config.assets.paths << bower_assets_path.join(*%w(jquery.atwho dist)).to_s + config.assets.paths << bower_assets_path.join(*%w(angular-busy dist)).to_s # Whitelist assets to be precompiled. # From 72cafdeb522228d3ec7dcc8245206db991a12e3a Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Sat, 14 Jun 2014 15:38:26 +0200 Subject: [PATCH 2/9] Start introducing angular-busy to wp#index --- .../work-package-total-sums-directive.js | 2 -- .../work_packages/work-packages-table-directive.js | 1 - .../controllers/work-packages-list-controller.js | 11 ++++------- public/templates/work_packages.list.html | 4 ++-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/angular/directives/work_packages/work-package-total-sums-directive.js b/app/assets/javascripts/angular/directives/work_packages/work-package-total-sums-directive.js index e2b1d83a8f..c7aac5247a 100644 --- a/app/assets/javascripts/angular/directives/work_packages/work-package-total-sums-directive.js +++ b/app/assets/javascripts/angular/directives/work_packages/work-package-total-sums-directive.js @@ -32,8 +32,6 @@ angular.module('openproject.workPackages.directives') 'WorkPackageService', function(WorkPackageService) { - var latestQueryReference; - return { restrict: 'A', scope: true, diff --git a/app/assets/javascripts/angular/directives/work_packages/work-packages-table-directive.js b/app/assets/javascripts/angular/directives/work_packages/work-packages-table-directive.js index 04cd9ee04a..bb1e0b22cb 100644 --- a/app/assets/javascripts/angular/directives/work_packages/work-packages-table-directive.js +++ b/app/assets/javascripts/angular/directives/work_packages/work-packages-table-directive.js @@ -50,7 +50,6 @@ angular.module('openproject.workPackages.directives') totalSums: '=', groupSums: '=', updateResults: '&', - withLoading: '=', updateBackUrl: '=' }, link: function(scope, element, attributes) { diff --git a/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js b/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js index b9a11b794b..8ce2d7cb01 100644 --- a/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js +++ b/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js @@ -59,15 +59,12 @@ angular.module('openproject.workPackages.controllers') var getWorkPackages, params; if($scope.query_id){ - getWorkPackages = WorkPackageService.getWorkPackagesByQueryId; - params = [$scope.projectIdentifier, $scope.query_id]; + getWorkPackages = WorkPackageService.getWorkPackagesByQueryId($scope.projectIdentifier, $scope.query_id); } else { - getWorkPackages = WorkPackageService.getWorkPackagesFromUrlQueryParams; - params = [$scope.projectIdentifier, $location]; + getWorkPackages = WorkPackageService.getWorkPackagesFromUrlQueryParams($scope.projectIdentifier, $location); } - $scope.withLoading(getWorkPackages, params) - .then(setupPage); + $scope.settingUpPage = getWorkPackages.then(setupPage); loadProjectTypesAndQueries(); } @@ -171,7 +168,7 @@ angular.module('openproject.workPackages.controllers') $scope.updateResults = function() { $scope.$broadcast('openproject.workPackages.updateResults'); - return $scope.withLoading(WorkPackageService.getWorkPackages, [$scope.projectIdentifier, $scope.query, PaginationService.getPaginationOptions()]) + $scope.refreshWorkPackages = WorkPackageService.getWorkPackages($scope.projectIdentifier, $scope.query, PaginationService.getPaginationOptions()) .then(setupWorkPackagesTable); }; diff --git a/public/templates/work_packages.list.html b/public/templates/work_packages.list.html index 4fc44778f3..bad86adcd9 100644 --- a/public/templates/work_packages.list.html +++ b/public/templates/work_packages.list.html @@ -100,8 +100,9 @@
-
+
From 17bb9e8528e42000b53fb86d0c489c79c0fdce07 Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Mon, 16 Jun 2014 16:52:48 +0200 Subject: [PATCH 3/9] Show spinner when fetching sums --- .../work_packages/work-package-total-sums-directive.js | 4 +++- .../controllers/work-packages-list-controller.js | 3 ++- public/templates/work_packages/work_packages_table.html | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/angular/directives/work_packages/work-package-total-sums-directive.js b/app/assets/javascripts/angular/directives/work_packages/work-package-total-sums-directive.js index c7aac5247a..c16b519e54 100644 --- a/app/assets/javascripts/angular/directives/work_packages/work-package-total-sums-directive.js +++ b/app/assets/javascripts/angular/directives/work_packages/work-package-total-sums-directive.js @@ -37,12 +37,14 @@ angular.module('openproject.workPackages.directives') scope: true, link: function(scope) { function fetchTotalSums() { - scope.withLoading(WorkPackageService.getWorkPackagesSums, [scope.projectIdentifier, scope.query, scope.columns]) + scope.fetchTotalSums = WorkPackageService.getWorkPackagesSums(scope.projectIdentifier, scope.query, scope.columns) .then(function(data){ angular.forEach(scope.columns, function(column, i){ column.total_sum = data.column_sums[i]; }); }); + + return scope.fetchTotalSums; } function totalSumsFetched() { diff --git a/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js b/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js index 8ce2d7cb01..c8df88c39d 100644 --- a/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js +++ b/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js @@ -54,7 +54,6 @@ angular.module('openproject.workPackages.controllers') function initialSetup() { $scope.operatorsAndLabelsByFilterType = OPERATORS_AND_LABELS_BY_FILTER_TYPE; - $scope.loading = false; $scope.disableFilters = false; var getWorkPackages, params; @@ -170,6 +169,8 @@ angular.module('openproject.workPackages.controllers') $scope.refreshWorkPackages = WorkPackageService.getWorkPackages($scope.projectIdentifier, $scope.query, PaginationService.getPaginationOptions()) .then(setupWorkPackagesTable); + + return $scope.refreshWorkPackages; }; // More diff --git a/public/templates/work_packages/work_packages_table.html b/public/templates/work_packages/work_packages_table.html index 970c81d461..9817552658 100644 --- a/public/templates/work_packages/work_packages_table.html +++ b/public/templates/work_packages/work_packages_table.html @@ -160,6 +160,7 @@ {{ I18n.t('js.label_sum_for') }} {{ I18n.t('js.label_all_work_packages') }} From 2671311e1a110df7f385a08ad11ba1fbbe987d49 Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Tue, 17 Jun 2014 10:02:40 +0200 Subject: [PATCH 4/9] Fix disabling of toggleable multiselect during initialization --- .../directives/components/toggled-multiselect-directive.js | 3 ++- app/assets/javascripts/angular/models/query.js | 4 ++-- public/templates/components/toggled_multiselect.html | 2 ++ public/templates/work_packages/query_filters.html | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/angular/directives/components/toggled-multiselect-directive.js b/app/assets/javascripts/angular/directives/components/toggled-multiselect-directive.js index c9da857933..8a1779de0e 100644 --- a/app/assets/javascripts/angular/directives/components/toggled-multiselect-directive.js +++ b/app/assets/javascripts/angular/directives/components/toggled-multiselect-directive.js @@ -36,7 +36,8 @@ angular.module('openproject.uiComponents') scope: { name: '=', values: '=', - availableOptions: '=' + availableOptions: '=', + disabled: '=' }, templateUrl: '/templates/components/toggled_multiselect.html', link: function(scope, element, attributes){ diff --git a/app/assets/javascripts/angular/models/query.js b/app/assets/javascripts/angular/models/query.js index b6f12c3080..aa1792d89c 100644 --- a/app/assets/javascripts/angular/models/query.js +++ b/app/assets/javascripts/angular/models/query.js @@ -244,8 +244,8 @@ angular.module('openproject.models') this.filters.splice(this.getFilterNames().indexOf(filterName), 1); }, - deactivateFilter: function(filter, loading) { - if (!loading) filter.deactivated = true; + deactivateFilter: function(filter) { + filter.deactivated = true; }, getFilterType: function(filterName) { diff --git a/public/templates/components/toggled_multiselect.html b/public/templates/components/toggled_multiselect.html index 15b476717f..d254c27b83 100644 --- a/public/templates/components/toggled_multiselect.html +++ b/public/templates/components/toggled_multiselect.html @@ -3,6 +3,7 @@ ng-show="!isMultiselect" name="v[{{name}}][]" ng-model="values" + ng-disabled="disabled" id="values-{{name}}" class="select-small" style="vertical-align: top;" @@ -15,6 +16,7 @@ ng-show="isMultiselect" name="v[{{name}}][]" ng-model="values" + ng-disabled="disabled" id="values-{{name}}" class="select-small" style="vertical-align: top;" diff --git a/public/templates/work_packages/query_filters.html b/public/templates/work_packages/query_filters.html index af51d5ceeb..16c082349c 100644 --- a/public/templates/work_packages/query_filters.html +++ b/public/templates/work_packages/query_filters.html @@ -135,7 +135,7 @@ name="filter.name" values="filter.values" is-multiselect="false" - ng-disabled="isLoading"/> + disabled="isLoading"/>
@@ -144,7 +144,7 @@ + ng-click="query.deactivateFilter(filter)"/> From a8dcbff99f48833f81fd367c41ae9782f870384e Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Tue, 17 Jun 2014 10:03:22 +0200 Subject: [PATCH 5/9] Resolve angular version to 1.2.16 --- bower.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 26236a5175..68336dda7d 100644 --- a/bower.json +++ b/bower.json @@ -33,6 +33,7 @@ "jquery-mockjax": "~1.5.3" }, "resolutions": { - "select2": "3.3.2" + "select2": "3.3.2", + "angular": "1.2.16" } } From 78cf3238d272b8b3b726f32fbd54d403fc79104a Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Tue, 17 Jun 2014 11:00:26 +0200 Subject: [PATCH 6/9] Fix karma --- .../tests/controllers/work-packages-list-controller-test.js | 2 +- .../work_packages/work-package-total-sums-directive-test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/karma/tests/controllers/work-packages-list-controller-test.js b/karma/tests/controllers/work-packages-list-controller-test.js index 63eb029cb6..f2674b285b 100644 --- a/karma/tests/controllers/work-packages-list-controller-test.js +++ b/karma/tests/controllers/work-packages-list-controller-test.js @@ -144,7 +144,7 @@ describe('WorkPackagesListController', function() { describe('initialisation', function() { it('should initialise', function() { buildController(); - expect(scope.loading).to.be.false; + expect(scope.settingUpPage).to.be.defined; }); }); }); diff --git a/karma/tests/directives/work_packages/work-package-total-sums-directive-test.js b/karma/tests/directives/work_packages/work-package-total-sums-directive-test.js index cb8cf85434..f80479def0 100644 --- a/karma/tests/directives/work_packages/work-package-total-sums-directive-test.js +++ b/karma/tests/directives/work_packages/work-package-total-sums-directive-test.js @@ -69,12 +69,12 @@ describe('workPackageTotalSums Directive', function() { }); describe('setting total sums for the columns', function(){ - beforeEach(inject(function($q) { + beforeEach(inject(function($q, WorkPackageService) { var sumsData = [1, 2]; scope.updateBackUrl = function(){ return 0; }; - scope.withLoading = function(callback, params) { - // Note: Seems easier to mock out the withLoading method instead of WorkPackageService.getWorkPackagesSums which can be seperately unit tested + + WorkPackageService.getWorkPackagesSums = function() { deferred = $q.defer(); deferred.resolve({ column_sums: sumsData } ); return deferred.promise; From 916637c208c87a6e1b72451a9714133798dea23a Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Tue, 17 Jun 2014 11:02:41 +0200 Subject: [PATCH 7/9] Remove ``withLoading`` wrapper from wp list controller scope --- .../controllers/work-packages-list-controller.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js b/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js index c8df88c39d..d5df210412 100644 --- a/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js +++ b/app/assets/javascripts/angular/work_packages/controllers/work-packages-list-controller.js @@ -180,10 +180,6 @@ angular.module('openproject.workPackages.controllers') $scope.isLoading = false; } - $scope.withLoading = function(callback, params){ - return WorkPackageLoadingHelper.withLoading($scope, callback, params, serviceErrorHandler); - }; - // Go initialSetup(); From 76eb05564b7b97bfbdbaed50242dbd959870cab1 Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Tue, 17 Jun 2014 11:20:54 +0200 Subject: [PATCH 8/9] Show spinner when loading additional columns --- app/assets/javascripts/angular/controllers/dialogs/columns.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/angular/controllers/dialogs/columns.js b/app/assets/javascripts/angular/controllers/dialogs/columns.js index 277e5c0f4a..755f16ac57 100644 --- a/app/assets/javascripts/angular/controllers/dialogs/columns.js +++ b/app/assets/javascripts/angular/controllers/dialogs/columns.js @@ -95,7 +95,9 @@ angular.module('openproject.workPackages.controllers') if(groupBy.length === 0) groupBy = undefined; // don't pass an empty string as groupBy - if(addedColumns.length) WorkPackageService.augmentWorkPackagesWithColumnsData(currentWorkPackages, addedColumns, groupBy); + if(addedColumns.length) { + $scope.refreshWorkPackages = WorkPackageService.augmentWorkPackagesWithColumnsData(currentWorkPackages, addedColumns, groupBy); + } columnsModal.deactivate(); }; From a0a7542aae5f668aeee57c35ae337a142c17790e Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Wed, 18 Jun 2014 16:19:08 +0200 Subject: [PATCH 9/9] Fix integration tests for sorting by column --- .../work_packages/work_package_query_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/features/accessibility/work_packages/work_package_query_spec.rb b/spec/features/accessibility/work_packages/work_package_query_spec.rb index 611ab7921f..1918c44680 100644 --- a/spec/features/accessibility/work_packages/work_package_query_spec.rb +++ b/spec/features/accessibility/work_packages/work_package_query_spec.rb @@ -36,7 +36,7 @@ describe 'Work package index accessibility' do project: project) } let(:work_packages_page) { WorkPackagesPage.new(project) } let(:sort_ascending_selector) { '.icon-sort-ascending' } - let(:sort_decending_selector) { '.icon-sort-descending' } + let(:sort_descending_selector) { '.icon-sort-descending' } before do allow(User).to receive(:current).and_return(user) @@ -79,12 +79,12 @@ describe 'Work package index accessibility' do find(column_header_link_selector) end - def sort_ascending_link - find(sort_ascending_selector) + def click_sort_ascending_link + execute_script "jQuery('#{sort_ascending_selector}').click()" end - def sort_decending_link - find(sort_decending_selector) + def click_sort_descending_link + execute_script "jQuery('#{sort_descending_selector}').click()" end shared_examples_for 'sort column' do @@ -124,7 +124,7 @@ describe 'Work package index accessibility' do describe 'descending' do before do column_header_link.click - sort_decending_link.click + click_sort_descending_link end it_behaves_like 'descending sorted column' @@ -133,7 +133,7 @@ describe 'Work package index accessibility' do describe 'ascending' do before do column_header_link.click - sort_ascending_link.click + click_sort_ascending_link end it_behaves_like 'ascending sorted column'