Fix TS warnings

pull/4589/head
Oliver Günther 8 years ago
parent 6a91f4b365
commit 6c5904c151
  1. 1
      frontend/app/components/api/api-paths/api-paths.service.test.ts
  2. 4
      frontend/app/components/api/api-v3/hal-link/hal-link.service.ts
  3. 5
      frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types.service.ts
  4. 7
      frontend/app/components/api/api-v3/hal-resources/hal-resource.service.ts
  5. 14
      frontend/app/components/api/api-v3/hal-resources/work-package-resource.service.ts
  6. 2
      frontend/app/components/api/api-work-packages/api-work-packages.service.ts
  7. 1
      frontend/app/components/context-menus/wp-context-menu/wp-context-menu.service.test.ts
  8. 20
      frontend/app/components/work-packages/wp-attachments-formattable-field/wp-attachments-formattable.directive.ts
  9. 10
      frontend/app/components/work-packages/wp-attachments-formattable-field/wp-attachments-formattable.models.ts
  10. 5
      frontend/app/components/work-packages/wp-attachments/wp-attachments.directive.test.ts
  11. 57
      frontend/app/components/work-packages/wp-attachments/wp-attachments.directive.ts
  12. 23
      frontend/app/components/work-packages/wp-attachments/wp-attachments.service.ts
  13. 8
      frontend/app/components/work-packages/wp-single-view/wp-single-view.directive.ts
  14. 5
      frontend/app/components/wp-buttons/wp-inline-create-button/wp-inline-create-button.controller.ts
  15. 3
      frontend/app/components/wp-display/field-types/wp-display-duration-field.module.ts
  16. 3
      frontend/app/components/wp-display/field-types/wp-display-id-field.module.ts
  17. 1
      frontend/tsconfig.json

@ -27,6 +27,7 @@
// ++
import {ApiPathsService} from "./api-paths.service";
import { expect } from 'chai';
describe('apiPaths', () => {

@ -81,8 +81,8 @@ export class HalLink implements HalLinkInterface {
}
}
function halLinkService() {
[$q, apiV3] = arguments;
function halLinkService(...args) {
[$q, apiV3] = args;
return HalLink;
}

@ -62,9 +62,8 @@ export class HalResourceTypesService {
});
types
.map(typeConfig => [typeConfig.typeName, typeConfig.attrTypes])
.forEach(typeAttrConfig => {
this.halResourceTypesStorage.setResourceTypeAttributes(...typeAttrConfig);
.forEach(typeConfig => {
this.halResourceTypesStorage.setResourceTypeAttributes(typeConfig.typeName, typeConfig.attrTypes);
});
}
}

@ -167,7 +167,7 @@ function initializeResource(halResource:HalResource) {
if (Array.isArray(link)) {
var items = link.map(item => createLinkedResource(linkName, item.$link));
var property:Array = new ObservableArray(...items).on('change', () => {
var property:Array<HalResource> = new ObservableArray(...items).on('change', () => {
property.forEach(item => {
if (!item.$link) {
property.splice(property.indexOf(item), 1);
@ -246,15 +246,14 @@ function initializeResource(halResource:HalResource) {
}
}
function halResourceService() {
[$q, lazy, HalLink, halResourceTypesStorage] = arguments;
function halResourceService(...args) {
[$q, lazy, halResourceTypesStorage] = args;
return HalResource;
}
halResourceService.$inject = [
'$q',
'lazy',
'HalLink',
'halResourceTypesStorage'
];

@ -40,7 +40,7 @@ interface WorkPackageResourceEmbedded {
author:HalResource|any;
availableWatchers:HalResource|any;
category:HalResource|any;
children:HalResource[]|any[];
children:WorkPackageResourceInterface[];
parent:HalResource|any;
priority:HalResource|any;
project:HalResource|any;
@ -67,7 +67,7 @@ interface WorkPackageResourceLinks extends WorkPackageResourceEmbedded {
move():ng.IPromise<any>;
removeWatcher():ng.IPromise<any>;
self():ng.IPromise<any>;
update():ng.IPromise<any>;
update(payload:any):ng.IPromise<any>;
updateImmediately(payload:any):ng.IPromise<any>;
watch():ng.IPromise<any>;
}
@ -108,6 +108,8 @@ export class WorkPackageResource extends HalResource {
public schema;
public $pristine:{ [attribute:string]:any } = {};
public parentId:number;
public subject:string;
public lockVersion:number;
private form;
@ -132,7 +134,7 @@ export class WorkPackageResource extends HalResource {
args = args.map(arg => (arg ? arg.$source : arg));
}
if (!_.isEqual(...args)) {
if (!_.isEqual(args[0], args[1])) {
modified.push(key);
}
});
@ -335,7 +337,7 @@ export class WorkPackageResource extends HalResource {
this.id = 'new';
// Set update link to form
this.update = this.$links.update = form.$links.self;
this['update'] = this.$links.update = form.$links.self;
this.parentId = this.parentId || $stateParams.parent_id;
}
@ -344,8 +346,8 @@ export class WorkPackageResource extends HalResource {
export interface WorkPackageResourceInterface extends WorkPackageResourceLinks, WorkPackageResourceEmbedded, WorkPackageResource {
}
function wpResource() {
[$q, $stateParams, apiWorkPackages, wpCacheService, NotificationsService] = arguments;
function wpResource(...args) {
[$q, $stateParams, apiWorkPackages, wpCacheService, NotificationsService] = args;
return WorkPackageResource;
}

@ -81,7 +81,7 @@ export class ApiWorkPackagesService {
parent = this.apiV3.one('projects', projectIdentifier);
}
return this.apiV3.service('work_packages', parent);
return this.apiV3.one('work_packages', parent);
}
protected queryAsV3Params(offset:number, pageSize:number, query:api.ex.Query) {

@ -26,6 +26,7 @@
// See doc/COPYRIGHT.rdoc for more details.
// ++
import { expect } from 'chai';
declare var Factory:any;
describe('workPackageContextMenu', () => {

@ -1,7 +1,9 @@
import {WpAttachmentsService} from './../wp-attachments/wp-attachments.service';
import {WorkPackageResource} from './../../api/api-v3/hal-resources/work-package-resource.service'
import {InsertMode, ViewMode} from './wp-attachments-formattable.enums'
import {DropModel, EditorModel, MarkupModel, FieldModel, SingleAttachmentModel} from './wp-attachments-formattable.models'
import {WorkPackageResourceInterface} from "../../api/api-v3/hal-resources/work-package-resource.service";
import {WorkPackageSingleViewController} from "../wp-single-view/wp-single-view.directive";
import {WorkPackageEditFormController} from "../../wp-edit/wp-edit-form.directive";
export class WpAttachmentsFormattableController {
private viewMode: ViewMode = ViewMode.SHOW;
@ -13,10 +15,8 @@ export class WpAttachmentsFormattableController {
protected wpAttachments: WpAttachmentsService,
protected $timeout: ng.ITimeoutService) {
$element.get(0).addEventListener('drop', this.handleDrop);
$element.bind('dragenter', this.prevDefault)
.bind('dragleave', this.prevDefault)
.bind('dragover', this.prevDefault);
$element.on('drop', this.handleDrop);
$element.on('dragenter dragleave dragover', this.prevDefault);
}
@ -27,7 +27,7 @@ export class WpAttachmentsFormattableController {
const textarea: ng.IAugmentedJQuery = this.$element.find('textarea');
this.viewMode = (textarea.length > 0) ? ViewMode.EDIT : ViewMode.SHOW;
const workPackage: WorkPackageResource = this.$scope.workPackage;
const workPackage: WorkPackageResourceInterface = (this.$scope as any).workPackage;
const dropData: DropModel = new DropModel(this.$location, evt.dataTransfer, workPackage);
var description: any;
@ -105,14 +105,18 @@ export class WpAttachmentsFormattableController {
}
}
interface IAttachmentScope extends ng.IScope {
workPackage: WorkPackageResourceInterface
}
function wpAttachmentsFormattable() {
return {
bindToController: true,
controller: WpAttachmentsFormattableController,
link: function(scope: ng.IScope,
link: function(scope: IAttachmentScope,
element: ng.IAugmentedJQuery,
attrs: ng.IAttributes,
controllers: Array<ng.IControllerService>){
controllers: [WorkPackageSingleViewController, WorkPackageEditFormController]){
// right now the attachments directive will only work in combination with either
// the wpSingleView or the wpEditForm directive
// else the drop handler will fail because of a missing reference to the current wp

@ -1,6 +1,8 @@
import {IApplyAttachmentMarkup} from './wp-attachments-formattable.interfaces'
import {InsertMode} from './wp-attachments-formattable.enums'
import {WorkPackageResource} from "../../api/api-v3/hal-resources/work-package-resource.service";
import {
WorkPackageResourceInterface
} from "../../api/api-v3/hal-resources/work-package-resource.service";
import IAugmentedJQuery = angular.IAugmentedJQuery;
export class EditorModel implements IApplyAttachmentMarkup{
@ -34,7 +36,7 @@ export class EditorModel implements IApplyAttachmentMarkup{
export class MarkupModel{
public createMarkup(insertUrl: string, insertMode: InsertMode, addLineBreak?: boolean = false): string {
public createMarkup(insertUrl: string, insertMode: InsertMode, addLineBreak: boolean = false): string {
if (angular.isUndefined((insertUrl))) return "";
var markup:string = "";
@ -73,7 +75,7 @@ export class DropModel{
maximumAttachmentFileSize : 0, // initialized during init process from ConfigurationService
};
constructor(protected $location: ng.ILocationService, protected dt: DataTransfer, protected workPackage: WorkPackageResource){
constructor(protected $location: ng.ILocationService, protected dt: DataTransfer, protected workPackage: WorkPackageResourceInterface){
this.files = dt.files;
this.filesCount = this.files.length;
this.isUpload = this._isUpload(dt);
@ -158,7 +160,7 @@ export class SingleAttachmentModel {
export class FieldModel implements IApplyAttachmentMarkup {
public contentToInsert: string;
constructor(protected workPackage: WorkPackageResource, protected markupModel: MarkupModel){
constructor(protected workPackage: WorkPackageResourceInterface, protected markupModel: MarkupModel){
this.contentToInsert = workPackage.description.raw || "";
}

@ -26,6 +26,7 @@
// See doc/COPYRIGHT.rdoc for more details.
//++
import {WorkPackageAttachmentsController} from './wp-attachments.directive'
type FileListAsArray = FileList & typeFixes.ArrayFix;
describe('WorkPackageAttachmentsDirective', function() {
var compile;
@ -97,7 +98,7 @@ describe('WorkPackageAttachmentsDirective', function() {
it('filters out attachments of type directory', function() {
var files = [{type: 'directory'}, {type: 'file'}];
controller.filterFiles(files);
controller.filterFiles(<FileListAsArray> files);
expect(files).to.eql([{type: 'file'}]);
});
@ -122,7 +123,7 @@ describe('WorkPackageAttachmentsDirective', function() {
var uploadStub = wpAttachments.upload = sinon.stub().returns(dumbPromise);
controller.uploadFilteredFiles(files);
controller.uploadFilteredFiles(<FileListAsArray> files);
expect(uploadStub.calledWith(workPackage, [{type: 'file'}])).to.be.true;
});

@ -29,34 +29,35 @@
import {wpDirectivesModule} from '../../../angular-modules';
import {WpAttachmentsService} from './wp-attachments.service';
type FileListAsArray = FileList & typeFixes.ArrayFix;
export class WorkPackageAttachmentsController {
public workPackage:any;
public workPackage: any;
public attachments:any[] = [];
public fetchingConfiguration:boolean = false;
public files:File[] = [];
public hasRightToUpload:boolean = false;
public I18n:any;
public loading:boolean = false;
public rejectedFiles:any[] = [];
public attachments: any[] = [];
public fetchingConfiguration: boolean = false;
public files: FileListAsArray = [];
public hasRightToUpload: boolean = false;
public loading: boolean = false;
public rejectedFiles: any[] = [];
public settings = {
maximumFileSize: Number
};
public size:any;
public size: any;
private currentlyFocussing;
private editMode:boolean;
private editMode: boolean;
constructor(protected $scope:any,
protected $element:ng.IAugmentedJQuery,
protected $attrs:ng.IAttributes,
protected wpAttachments:WpAttachmentsService,
protected NotificationsService:any,
protected I18n:any,
protected ConfigurationService:any,
protected ConversionService:any) {
constructor(protected $scope: any,
protected $element: ng.IAugmentedJQuery,
protected $attrs: ng.IAttributes,
protected wpAttachments: WpAttachmentsService,
protected NotificationsService: any,
protected I18n: any,
protected ConfigurationService: any,
protected ConversionService: any) {
this.attachments = this.wpAttachments.getCurrentAttachments();
this.editMode = $attrs.hasOwnProperty('edit');
@ -76,7 +77,7 @@ export class WorkPackageAttachmentsController {
}
public upload():void {
public upload(): void {
if (this.workPackage.isNew) {
this.files.forEach((file) => {
this.attachments.push(file);
@ -92,7 +93,7 @@ export class WorkPackageAttachmentsController {
}
};
public loadAttachments():void {
public loadAttachments(): void {
if (this.editMode) {
this.loading = true;
this.wpAttachments.load(this.workPackage, true).finally(() => {
@ -101,7 +102,7 @@ export class WorkPackageAttachmentsController {
}
};
public remove(file):void {
public remove(file): void {
if (this.workPackage.isNew) {
_.remove(this.wpAttachments.attachments, file);
} else {
@ -109,30 +110,30 @@ export class WorkPackageAttachmentsController {
}
};
public focus(attachment:any):void {
public focus(attachment: any): void {
this.currentlyFocussing = attachment;
};
public focussing(attachment:any):boolean {
public focussing(attachment: any): boolean {
return this.currentlyFocussing === attachment;
};
public filterFiles(files):void {
public filterFiles(files): void {
// Directories cannot be uploaded and as such, should not become files in
// the sense of this directive. The files within the directories will
// be taken though.
_.remove(files, (file:any) => {
_.remove(files, (file: any) => {
return file.type === 'directory';
});
};
public uploadFilteredFiles(files):void {
public uploadFilteredFiles(files): void {
this.filterFiles(files);
this.upload();
}
}
function wpAttachmentsDirective():ng.IDirective {
function wpAttachmentsDirective(): ng.IDirective {
return {
bindToController: true,
controller: WorkPackageAttachmentsController,
@ -142,7 +143,7 @@ function wpAttachmentsDirective():ng.IDirective {
scope: {
workPackage: '&',
},
templateUrl: (element:ng.IAugmentedJQuery, attrs:ng.IAttributes):string => {
templateUrl: (element: ng.IAugmentedJQuery, attrs: ng.IAttributes): string => {
if (attrs.hasOwnProperty('edit')) {
return '/components/work-packages/wp-attachments/wp-attachments-edit.directive.html';
} else {

@ -27,28 +27,29 @@
// ++
import {wpServicesModule} from '../../../angular-modules.ts';
import ArrayLiteralExpression = ts.ArrayLiteralExpression;
import {WorkPackageResource} from './../../api/api-v3/hal-resources/work-package-resource.service'
import {HalResource} from './../../api/api-v3/hal-resources/hal-resource.service'
import {WorkPackageResourceInterface} from "../../api/api-v3/hal-resources/work-package-resource.service";
type FileListAsArray = FileList & typeFixes.ArrayFix;
export class WpAttachmentsService {
public attachments: Array = [];
public attachments: Array<any> = [];
constructor(
protected $q: ng.IQService,
protected $timeout: ng.ITimeoutService,
protected $http: ng.IHttpProvider,
protected $http: ng.IHttpService,
protected Upload,
protected I18n,
protected NotificationsService
) {}
public upload(workPackage: WorkPackageResource, files: FileList): ng.IPromise {
public upload(workPackage: WorkPackageResourceInterface, files: FileListAsArray): ng.IPromise<any> {
const uploadPath: string = workPackage.$links.attachments.$link.href;
const uploads = _.map(files, (file: File) => {
var options: Object = {
fields: {
metadata: {
description: file.description,
description: (file as any).description,
fileName: file.name,
}
},
@ -77,11 +78,11 @@ export class WpAttachmentsService {
return allUploadsDone.promise;
}
public load(workPackage: WorkPackageResource, reload:boolean = false): ng.IPromise<Array> {
public load(workPackage: WorkPackageResource, reload:boolean = false): ng.IPromise<Array<any>> {
const loadedAttachments = this.$q.defer();
const path: string = workPackage.$links.attachments.$link.href;
this.$http.get(path, {cache: !reload}).success(response => {
this.$http.get(path, {cache: !reload}).success((response: any) => {
_.remove(this.attachments);
_.extend(this.attachments,response._embedded.elements);
loadedAttachments.resolve(this.attachments);
@ -104,7 +105,7 @@ export class WpAttachmentsService {
}
};
public hasAttachments(workPackage: WorkPackageResource): ng.IPromise {
public hasAttachments(workPackage: WorkPackageResourceInterface): ng.IPromise {
const existance = this.$q.defer();
this.load(workPackage).then((attachments:any) => {
@ -121,7 +122,7 @@ export class WpAttachmentsService {
this.attachments.length = 0;
};
public addPendingAttachments(files: FileList | File): void {
public addPendingAttachments(files: FileListAsArray | File): void {
if (angular.isArray(files)) {
files.forEach(file => {
this.attachments.push(file);
@ -133,7 +134,7 @@ export class WpAttachmentsService {
}
// not in use until furinvaders create is merged
public uploadPendingAttachments = (wp: WorkPackageResource): ng.IPromise<any> => {
public uploadPendingAttachments = (wp: WorkPackageResourceInterface): ng.IPromise<any> => {
if (angular.isDefined(wp) && this.attachments.length > 0){
return this.upload(wp, this.attachments);
}

@ -28,11 +28,15 @@
import {opWorkPackagesModule} from '../../../angular-modules';
import {scopedObservable} from '../../../helpers/angular-rx-utils';
import {WorkPackageResource} from '../../api/api-v3/hal-resources/work-package-resource.service';
import {
WorkPackageResource,
WorkPackageResourceInterface
} from '../../api/api-v3/hal-resources/work-package-resource.service';
import {WorkPackageEditFormController} from "../../wp-edit/wp-edit-form.directive";
export class WorkPackageSingleViewController {
public formCtrl: WorkPackageEditFormController;
public workPackage:any|WorkPackageResource;
public workPackage:WorkPackageResourceInterface;
public singleViewWp;
public groupedFields:any[] = [];
public hideEmptyFields:boolean = true;

@ -28,9 +28,8 @@
import {wpButtonsModule} from '../../../angular-modules';
import WorkPackageCreateButtonController from '../wp-create-button/wp-create-button.controller';
import {WorkPackageCreateService} from "../../wp-create/wp-create.service";
import {scopedObservable} from "../../../helpers/angular-rx-utils";
import {WorkPackageCacheService} from "../../work-packages/work-package-cache.service";
import {WorkPackageCreateService} from '../../wp-create/wp-create.service';
import {WorkPackageCacheService} from '../../work-packages/work-package-cache.service';
class WorkPackageInlineCreateButtonController extends WorkPackageCreateButtonController {
public query:op.Query;

@ -27,6 +27,7 @@
// ++
import {DisplayField} from "../wp-display-field/wp-display-field.module";
import {WorkPackageResource} from "../../api/api-v3/hal-resources/work-package-resource.service";
export class DurationDisplayField extends DisplayField {
@ -35,7 +36,7 @@ export class DurationDisplayField extends DisplayField {
isManualRenderer = true;
constructor(public resource:HalResource,
constructor(public resource:WorkPackageResource,
public name:string,
public schema) {
super(resource, name, schema);

@ -27,13 +27,14 @@
// ++
import {DisplayField} from "../wp-display-field/wp-display-field.module";
import {WorkPackageResource} from "../../api/api-v3/hal-resources/work-package-resource.service";
export class IdDisplayField extends DisplayField {
public template: string = '/components/wp-display/field-types/wp-display-id-field.directive.html'
public text: Object;
constructor(public resource:HalResource,
constructor(public resource:WorkPackageResource,
public name:string,
public schema) {
super(resource, name, schema);

@ -11,6 +11,7 @@
"files": [
"typings/index.d.ts",
"app/typings/open-project.typings.ts",
"app/typings/type-fixes.d.ts",
"tests/typings/tests.d.ts"
]
}

Loading…
Cancel
Save