Merge pull request #93 from finnlabs/housekeeping/ts-strictness

Adapt to stricter core
pull/6827/head
Oliver Günther 8 years ago committed by GitHub
commit ee64447598
  1. 11
      frontend/app/components/projects-overview/overview-block.directive.ts
  2. 42
      frontend/app/components/projects-overview/overview-page-layout.directive.ts
  3. 29
      frontend/app/components/projects-overview/overview-textile-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);
});
};

@ -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('<input>')
.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();
});
};
},

@ -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();
});
};
},

Loading…
Cancel
Save