Replace API call by already available information about the permission to log time

pull/8306/head
Henriette Dinger 5 years ago
parent fc1cd082f4
commit e6fbd080c1
  1. 25
      frontend/src/app/modules/fields/display/field-types/wp-spent-time-display-field.module.ts

@ -33,7 +33,6 @@ import { ProjectResource } from "core-app/modules/hal/resources/project-resource
import { InjectField } from "core-app/helpers/angular/inject-field.decorator";
import * as URI from 'urijs';
import { TimeEntryCreateService } from 'core-app/modules/time_entries/create/create.service';
import {TimeEntryDmService} from "core-app/modules/hal/dm-services/time-entry-dm.service";
export class WorkPackageSpentTimeDisplayField extends DurationDisplayField {
public text = {
@ -44,7 +43,6 @@ export class WorkPackageSpentTimeDisplayField extends DurationDisplayField {
@InjectField() PathHelper:PathHelperService;
@InjectField() projectCacheService:ProjectCacheService;
@InjectField() timeEntryCreateService:TimeEntryCreateService;
@InjectField() timeEntryDm:TimeEntryDmService;
public render(element:HTMLElement, displayText:string):void {
if (!this.value) {
@ -75,23 +73,18 @@ export class WorkPackageSpentTimeDisplayField extends DurationDisplayField {
}
private appendTimelogLink(element:HTMLElement) {
this
.timeEntryDm
.list({ pageSize: 1 })
.then(collection => {
if (!!collection.createTimeEntry) {
const timelogElement = document.createElement('a');
timelogElement.setAttribute('class','icon icon-time');
timelogElement.textContent = this.text.logTime;
if (this.resource.logTime) {
const timelogElement = document.createElement('a');
timelogElement.setAttribute('class','icon icon-time');
timelogElement.textContent = this.text.logTime;
element.appendChild(timelogElement);
element.appendChild(timelogElement);
let classContext = this;
timelogElement.addEventListener('click', function() {
classContext.showTimelogWidget();
});
}
let classContext = this;
timelogElement.addEventListener('click', function() {
classContext.showTimelogWidget();
});
}
}
private showTimelogWidget() {

Loading…
Cancel
Save