From 5dea770d44b0ab25bf7d8a8214a3a8d8a4a59f6c Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Fri, 30 May 2014 10:11:57 +0200 Subject: [PATCH 1/2] Add angular-feature-flags Signed-off-by: Alex Coles --- bower.json | 1 + 1 file changed, 1 insertion(+) diff --git a/bower.json b/bower.json index cf0f83427d..8024abc9e0 100644 --- a/bower.json +++ b/bower.json @@ -18,6 +18,7 @@ "angular-modal": "~0.3.0", "angular-sanitize": "~1.2.14", "angular-truncate": "latest", + "angular-feature-flags": "mjt01/angular-feature-flags", "jquery-migrate": "~1.2.1", "momentjs": "~2.6.0", "moment-timezone": "~0.0.6", From ffa98158cb302b43164f54030c984150b25af13e Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Fri, 30 May 2014 10:40:14 +0200 Subject: [PATCH 2/2] Selectively display details view with feature flag Integrate angular-feature-flags (there is currently no UI for overriding feature flags). This provides a more generic solution than 56bb307e. As a side-effect, this fixes Bug # 8388 Signed-off-by: Alex Coles --- .../javascripts/angular/directives/components/toolbar.js | 1 - .../work_packages/work-packages-table-directive.js | 9 +++++++-- app/assets/javascripts/angular/openproject-app.js | 7 +++++-- app/assets/javascripts/application.js.erb | 1 + public/javascripts/feature-flags.json | 8 ++++++++ public/templates/work_packages.html | 4 ++-- public/templates/work_packages.list.html | 3 ++- 7 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 public/javascripts/feature-flags.json diff --git a/app/assets/javascripts/angular/directives/components/toolbar.js b/app/assets/javascripts/angular/directives/components/toolbar.js index 8aaafcb661..cda07f991a 100644 --- a/app/assets/javascripts/angular/directives/components/toolbar.js +++ b/app/assets/javascripts/angular/directives/components/toolbar.js @@ -33,7 +33,6 @@ angular.module('openproject.uiComponents') return { restrict: 'EA', link: function(scope, element, attributes) { - scope.hideWorkPackageDetails = true; // temporarily disable work package details links } }; }); 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 fe60426419..ceedcb75a7 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 @@ -31,7 +31,8 @@ angular.module('openproject.workPackages.directives') .directive('workPackagesTable', [ 'I18n', 'WorkPackagesTableService', - function(I18n, WorkPackagesTableService){ + 'flags', + function(I18n, WorkPackagesTableService, flags){ return { restrict: 'E', @@ -86,7 +87,11 @@ angular.module('openproject.workPackages.directives') } }); - scope.hideWorkPackageDetails = true; // temporarily disable work package details links + scope.$watch(function() { + return flags.isOn('detailsView'); + }, function(detailsEnabled) { + scope.hideWorkPackageDetails = !detailsEnabled; + }); } }; }]); diff --git a/app/assets/javascripts/angular/openproject-app.js b/app/assets/javascripts/angular/openproject-app.js index 166858f891..b9597cf824 100644 --- a/app/assets/javascripts/angular/openproject-app.js +++ b/app/assets/javascripts/angular/openproject-app.js @@ -114,7 +114,8 @@ var openprojectApp = angular.module('openproject', [ 'openproject.timeEntries', 'ngAnimate', 'ngSanitize', - 'truncate' + 'truncate', + 'feature-flags' ]); window.appBasePath = jQuery('meta[name=app_base_path]').attr('content') || ''; @@ -134,6 +135,8 @@ openprojectApp }; }); }]) - .run(['$http', function($http){ + .run(['$http', 'flags', function($http, flags) { $http.defaults.headers.common.Accept = 'application/json'; + + flags.set($http.get('/javascripts/feature-flags.json')); }]); diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 3be3e31acc..93eaf3df8b 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -64,6 +64,7 @@ //= require angular-ui-date/src/date //= require angular-sanitize //= require angular-truncate/dist/angular-truncate +//= require angular-feature-flags/dist/featureFlags.js //= require ng-context-menu diff --git a/public/javascripts/feature-flags.json b/public/javascripts/feature-flags.json new file mode 100644 index 0000000000..7df0933397 --- /dev/null +++ b/public/javascripts/feature-flags.json @@ -0,0 +1,8 @@ +[ + { + "key": "detailsView", + "active": false, + "name": "Details View", + "description": "Displays details for individual work packages." + } +] diff --git a/public/templates/work_packages.html b/public/templates/work_packages.html index 2da723fb10..fd91d7b86d 100644 --- a/public/templates/work_packages.html +++ b/public/templates/work_packages.html @@ -22,7 +22,7 @@ {{ I18n.t('js.toolbar.filter') }} -
  • +
    • -
    • +