From bf3035cf90aae18fed0f16cae4f255d4e74c9b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 15 Feb 2017 21:36:31 +0100 Subject: [PATCH] Adapt to stricter core --- .../overview-block.directive.ts | 11 +++-- .../overview-page-layout.directive.ts | 42 +++++++++++-------- .../overview-textile-block.directive.ts | 29 +++++++------ 3 files changed, 50 insertions(+), 32 deletions(-) diff --git a/frontend/app/components/projects-overview/overview-block.directive.ts b/frontend/app/components/projects-overview/overview-block.directive.ts index 7d77949430..fe7078dc8c 100644 --- a/frontend/app/components/projects-overview/overview-block.directive.ts +++ b/frontend/app/components/projects-overview/overview-block.directive.ts @@ -31,7 +31,7 @@ export class OverviewBlockController { public layoutCtrl:ProjectsOverviewController; - constructor(public $element) { + constructor(public $element:ng.IAugmentedJQuery) { } public get editing() { @@ -53,9 +53,14 @@ function overviewBlock() { scope: {}, transclude: true, compile: function() { - return function(scope, element, attrs, ctrl, transclude) { + return function( + scope:any, + element:ng.IAugmentedJQuery, + attrs:ng.IAttributes, + ctrl:any, + transclude:any) { scope.$ctrl.layoutCtrl = ctrl; - transclude(scope, (clone) => { + transclude(scope, (clone:any) => { element.append(clone); }); }; diff --git a/frontend/app/components/projects-overview/overview-page-layout.directive.ts b/frontend/app/components/projects-overview/overview-page-layout.directive.ts index 8b7bf07928..0ac763c9ed 100644 --- a/frontend/app/components/projects-overview/overview-page-layout.directive.ts +++ b/frontend/app/components/projects-overview/overview-page-layout.directive.ts @@ -26,15 +26,17 @@ // See doc/COPYRIGHT.rdoc for more details. // ++ +import {WorkPackageNotificationService} from 'core-components/wp-edit/wp-notification.service'; + export class ProjectsOverviewController { - public selectedBlock:string; + public selectedBlock:string|null; - constructor(public $element, - public $scope, - public $http, - public $compile, - public wpNotificationsService) { + constructor(public $element:ng.IAugmentedJQuery, + public $scope:ng.IScope, + public $http:ng.IHttpService, + public $compile:ng.ICompileService, + public wpNotificationsService:WorkPackageNotificationService) { } public initialize() { @@ -56,12 +58,12 @@ export class ProjectsOverviewController { /** * Retrieve block identifiers in the given container */ - public activeBlockNames(container?) { + public activeBlockNames(container?:JQuery) { if (!container) { container = this.$element; } - return container.find('.widget-box').map((i, el) => { + return container.find('.widget-box').map((i:number, el:HTMLElement) => { return this.blockNameFromId(el.id); }).toArray(); } @@ -69,7 +71,7 @@ export class ProjectsOverviewController { /** * Remember removed custom blocks, since they need to be removed in backend. */ - public noteRemovedBlock(blockName) { + public noteRemovedBlock(blockName:string) { angular.element('') .attr({ type: 'hidden', name: 'deleted_custom_blocks[]', value: blockName }) .appendTo(this.saveForm); @@ -94,14 +96,14 @@ export class ProjectsOverviewController { /** * Given the block identifier (e.g., block_work_packages_watched), return the block name. */ - public blockNameFromId(id) { + public blockNameFromId(id:string):string { return id.replace(/^block_/, ''); } /** * Given the block name (e.g., work_packages_watched), return the selector to the dom block. */ - public idFromBlockName(name) { + public idFromBlockName(name:string):string { return "#block_" + name; } @@ -121,7 +123,7 @@ export class ProjectsOverviewController { method: 'POST', data: { block: this.selectedBlock }, headers: { Accept: 'text/html' } - }).then(response => { + }).then((response:{data: any}) => { var blockName = response.data.match(/id="block_(.*?)"/)[1]; this.addBlock(blockName, response.data); this.updateAvailableBlocks(); @@ -151,7 +153,7 @@ export class ProjectsOverviewController { url: attachments.data('refreshUrl'), method: 'GET', headers: { Accept: 'text/html' } - }).then(response => { + }).then((response:any) => { attachments.html(response.data); }).catch(error => { this.wpNotificationsService.handleErrorResponse(error); @@ -167,7 +169,8 @@ export class ProjectsOverviewController { } private compileBlock(content:string) { - return this.$compile(content)(this.$scope, undefined, { + let compileFn:any = this.$compile(content); + return compileFn(this.$scope, undefined, { transcludeControllers: { overviewPageLayout: { instance: this } } @@ -181,10 +184,15 @@ function overviewPageLayout() { scope: {}, transclude: true, compile: function() { - return function(scope, element, attrs, ctrls, transclude) { - transclude(scope, (clone) => { + return function( + scope:any, + element:ng.IAugmentedJQuery, + attrs:ng.IAttributes, + ctrls:any, + transclude:any) { + transclude(scope, (clone:any) => { element.append(clone); - scope.$ctrl.initialize(); + scope.$ctrl.initialSetup(); }); }; }, diff --git a/frontend/app/components/projects-overview/overview-textile-block.directive.ts b/frontend/app/components/projects-overview/overview-textile-block.directive.ts index cf9252e2e5..ba544b2d9a 100644 --- a/frontend/app/components/projects-overview/overview-textile-block.directive.ts +++ b/frontend/app/components/projects-overview/overview-textile-block.directive.ts @@ -43,12 +43,12 @@ export class OverviewTextileBlockController { // Current state of edit form showing public formVisible:boolean = false; - constructor(public $element, - public $timeout, - public $window, - public $q, - public I18n, - public NotificationsService) { + constructor(public $element:ng.IAugmentedJQuery, + public $timeout:ng.ITimeoutService, + public $window:ng.IWindowService, + public $q:ng.IQService, + public I18n:op.I18n, + public NotificationsService:any) { } public initialize() { @@ -61,7 +61,7 @@ export class OverviewTextileBlockController { return !!this.layoutCtrl; } - public toggleEditForm(state?) { + public toggleEditForm(state?:boolean) { if (state === undefined) { state = !this.formVisible; } @@ -81,9 +81,9 @@ export class OverviewTextileBlockController { /** * Save changes from the textile block */ - public submitForm(evt) { + public submitForm(evt:JQueryEventObject) { var form = this.$element.find('.textile-form'); - var formData = new FormData(form[0]); + var formData = new FormData(form[0] as HTMLFormElement); // $http fails to serialize the formData correctly, // even when forcing the content-type. @@ -126,11 +126,16 @@ function overviewTextileBlock() { }, transclude: true, compile: function() { - return function(scope, element, attrs, ctrl, transclude) { + return function( + scope:any, + element:ng.IAugmentedJQuery, + attrs:ng.IAttributes, + ctrl:any, + transclude:any) { scope.$ctrl.layoutCtrl = ctrl; - transclude(scope, (clone) => { + transclude(scope, (clone:any) => { element.append(clone); - scope.$ctrl.initialize(); + scope.$ctrl.initialSetup(); }); }; },