From 48bbb25b36aea82a28bc39ba0dedf222577cf31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Fri, 2 Dec 2016 09:03:04 +0100 Subject: [PATCH 1/2] [24389] Fix initial ID rendering without schema As the work packages from the list response have no schema, but are used to build the table, they initially have no schema yet. --- .../work-packages/wp-display-attr/wp-display-attr.directive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.ts b/frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.ts index 9668476516..2122884274 100644 --- a/frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.ts +++ b/frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.ts @@ -53,7 +53,7 @@ export class WorkPackageDisplayAttributeController { protected $scope: ng.IScope) { // Update the attribute initially - if (this.workPackage) { + if (this.workPackage && this.customSchema && this.schema[this.attribute]) { this.updateAttribute(this.workPackage); } } From a5e68e6c4a8173f823adbce3d34d3506c28c8b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Fri, 2 Dec 2016 10:53:01 +0100 Subject: [PATCH 2/2] Fix test by using wpCacheService --- .../wp-display-attr/wp-display-attr.directive.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.test.ts b/frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.test.ts index 206f0d892b..fab9bee2d3 100644 --- a/frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.test.ts +++ b/frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.test.ts @@ -26,6 +26,7 @@ // See doc/COPYRIGHT.rdoc for more details. // ++ +import {WorkPackageCacheService} from './../work-package-cache.service'; describe('wpDisplayAttr directive', () => { var compile; @@ -33,6 +34,8 @@ describe('wpDisplayAttr directive', () => { var rootScope; var scope; var I18n; + var wpCacheService: WorkPackageCacheService; + beforeEach(angular.mock.module( 'openproject', @@ -49,13 +52,14 @@ describe('wpDisplayAttr directive', () => { }); })); - beforeEach(angular.mock.inject(($rootScope, $compile, _I18n_, _$httpBackend_) => { + beforeEach(angular.mock.inject(($rootScope, $compile, _I18n_, _$httpBackend_, _wpCacheService_) => { var html = ` `; I18n = _I18n_; + wpCacheService = _wpCacheService_; var stub = sinon.stub(I18n, 't'); stub.withArgs('js.general_text_no').returns('No'); stub.withArgs(sinon.match.any).returns(''); @@ -68,6 +72,8 @@ describe('wpDisplayAttr directive', () => { _$httpBackend_.expectGET('/api/v3/work_packages/1').respond(200); compile = () => { + wpCacheService.updateWorkPackage(scope.workPackage); + $compile(element)(scope); scope.$digest(); };