Merge pull request #5096 from opf/fix/24389/inital-id-display

[24389] Fix initial ID rendering without schema
pull/5098/head
Oliver Günther 8 years ago committed by GitHub
commit 0e3b6fe145
  1. 8
      frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.test.ts
  2. 2
      frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.ts

@ -26,6 +26,7 @@
// See doc/COPYRIGHT.rdoc for more details. // See doc/COPYRIGHT.rdoc for more details.
// ++ // ++
import {WorkPackageCacheService} from './../work-package-cache.service';
describe('wpDisplayAttr directive', () => { describe('wpDisplayAttr directive', () => {
var compile; var compile;
@ -33,6 +34,8 @@ describe('wpDisplayAttr directive', () => {
var rootScope; var rootScope;
var scope; var scope;
var I18n; var I18n;
var wpCacheService: WorkPackageCacheService;
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
'openproject', '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 = ` var html = `
<wp-display-attr work-package="workPackage" attribute="attribute"> <wp-display-attr work-package="workPackage" attribute="attribute">
</wp-display-attr> </wp-display-attr>
`; `;
I18n = _I18n_; I18n = _I18n_;
wpCacheService = _wpCacheService_;
var stub = sinon.stub(I18n, 't'); var stub = sinon.stub(I18n, 't');
stub.withArgs('js.general_text_no').returns('No'); stub.withArgs('js.general_text_no').returns('No');
stub.withArgs(sinon.match.any).returns(''); stub.withArgs(sinon.match.any).returns('');
@ -68,6 +72,8 @@ describe('wpDisplayAttr directive', () => {
_$httpBackend_.expectGET('/api/v3/work_packages/1').respond(200); _$httpBackend_.expectGET('/api/v3/work_packages/1').respond(200);
compile = () => { compile = () => {
wpCacheService.updateWorkPackage(scope.workPackage);
$compile(element)(scope); $compile(element)(scope);
scope.$digest(); scope.$digest();
}; };

@ -53,7 +53,7 @@ export class WorkPackageDisplayAttributeController {
protected $scope: ng.IScope) { protected $scope: ng.IScope) {
// Update the attribute initially // Update the attribute initially
if (this.workPackage) { if (this.workPackage && this.customSchema && this.schema[this.attribute]) {
this.updateAttribute(this.workPackage); this.updateAttribute(this.workPackage);
} }
} }

Loading…
Cancel
Save