From 713902da06ebb68d758bee67e42e5e5b518ee9c1 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Thu, 4 Jan 2018 17:00:16 +0100 Subject: [PATCH] Made the app compile again. --- .../pages/content/content-field.component.ts | 3 +- .../pages/content/content-page.component.ts | 12 +++-- .../pages/contents/contents-page.component.ts | 2 +- .../content/shared/assets-editor.component.ts | 2 +- .../shared/references-editor.component.ts | 2 +- .../pages/dashboard-page.component.ts | 3 +- .../rules/pages/rules/rules-page.component.ts | 2 +- .../types/string-validation.component.ts | 2 +- .../framework/angular/http-extensions-impl.ts | 2 +- .../app/framework/angular/keys.pipe.ts | 2 +- .../angular/onboarding-tooltip.component.ts | 4 +- .../app/framework/angular/toggle.component.ts | 2 +- .../app/framework/utils/immutable-array.ts | 2 +- src/Squidex/app/framework/utils/version.ts | 2 +- .../app/shared/components/app-context.ts | 4 +- .../app/shared/guards/unset-app.guard.spec.ts | 4 +- .../app/shared/services/assets.service.ts | 4 +- .../app/shared/services/auth.service.ts | 2 +- .../app/shared/services/schemas.service.ts | 12 +++-- .../pages/internal/apps-menu.component.ts | 2 +- src/Squidex/package.json | 50 +++++++++---------- src/Squidex/tsconfig.json | 3 +- 22 files changed, 66 insertions(+), 57 deletions(-) diff --git a/src/Squidex/app/features/content/pages/content/content-field.component.ts b/src/Squidex/app/features/content/pages/content/content-field.component.ts index 97b8a6bf0..2e054bf06 100644 --- a/src/Squidex/app/features/content/pages/content/content-field.component.ts +++ b/src/Squidex/app/features/content/pages/content/content-field.component.ts @@ -41,7 +41,8 @@ export class ContentFieldComponent implements OnInit { } public ngOnInit() { - this.masterLanguageCode = this.languages.find(l => l.isMaster).iso2Code; + this.masterLanguageCode = this.languages.find(l => l.isMaster)!.iso2Code; + if (this.field.isDisabled) { this.fieldForm.disable(); } diff --git a/src/Squidex/app/features/content/pages/content/content-page.component.ts b/src/Squidex/app/features/content/pages/content/content-page.component.ts index fc0e42533..e79063056 100644 --- a/src/Squidex/app/features/content/pages/content/content-page.component.ts +++ b/src/Squidex/app/features/content/pages/content/content-page.component.ts @@ -47,7 +47,7 @@ export class ContentPageComponent implements CanComponentDeactivate, OnDestroy, public schema: SchemaDetailsDto; public content: ContentDto; - public contentOld: ContentDto; + public contentOld: ContentDto | null; public contentFormSubmitted = false; public contentForm: FormGroup; @@ -122,11 +122,13 @@ export class ContentPageComponent implements CanComponentDeactivate, OnDestroy, } public showLatest() { - this.content = this.contentOld; - this.contentOld = null; + if (this.contentOld) { + this.content = this.contentOld; + this.contentOld = null; - this.emitContentUpdated(this.content); - this.populateContentForm(); + this.emitContentUpdated(this.content); + this.populateContentForm(); + } } public saveAndPublish() { diff --git a/src/Squidex/app/features/content/pages/contents/contents-page.component.ts b/src/Squidex/app/features/content/pages/contents/contents-page.component.ts index dc74f9a34..6fdff0cbf 100644 --- a/src/Squidex/app/features/content/pages/contents/contents-page.component.ts +++ b/src/Squidex/app/features/content/pages/contents/contents-page.component.ts @@ -170,7 +170,7 @@ export class ContentsPageComponent implements OnDestroy, OnInit { } public load(showInfo = false) { - this.contentsService.getContents(this.ctx.appName, this.schema.name, this.contentsPager.pageSize, this.contentsPager.skip, this.contentsQuery, null, this.isArchive) + this.contentsService.getContents(this.ctx.appName, this.schema.name, this.contentsPager.pageSize, this.contentsPager.skip, this.contentsQuery, undefined, this.isArchive) .subscribe(dtos => { this.contentItems = ImmutableArray.of(dtos.items); this.contentsPager = this.contentsPager.setCount(dtos.total); diff --git a/src/Squidex/app/features/content/shared/assets-editor.component.ts b/src/Squidex/app/features/content/shared/assets-editor.component.ts index 3a8505fb9..8b70fa521 100644 --- a/src/Squidex/app/features/content/shared/assets-editor.component.ts +++ b/src/Squidex/app/features/content/shared/assets-editor.component.ts @@ -70,7 +70,7 @@ export class AssetsEditorComponent implements ControlValueAccessor, OnDestroy, O this.assetsService.getAssets(this.ctx.appName, 10000, 0, undefined, undefined, value) .subscribe(dtos => { - this.oldAssets = ImmutableArray.of(assetIds.map(id => dtos.items.find(x => x.id === id))); + this.oldAssets = ImmutableArray.of(assetIds.map(id => dtos.items.find(x => x.id === id)).filter(a => !!a).map(a => a!)); }); } } diff --git a/src/Squidex/app/features/content/shared/references-editor.component.ts b/src/Squidex/app/features/content/shared/references-editor.component.ts index 5af111897..88e854458 100644 --- a/src/Squidex/app/features/content/shared/references-editor.component.ts +++ b/src/Squidex/app/features/content/shared/references-editor.component.ts @@ -84,7 +84,7 @@ export class ReferencesEditorComponent implements ControlValueAccessor, OnInit { this.contentsService.getContents(this.ctx.appName, this.schemaId, 10000, 0, undefined, contentIds) .subscribe(dtos => { - this.contentItems = ImmutableArray.of(contentIds.map(id => dtos.items.find(c => c.id === id)).filter(c => !!c)); + this.contentItems = ImmutableArray.of(contentIds.map(id => dtos.items.find(c => c.id === id)).filter(r => !!r).map(r => r!)); }); } } diff --git a/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts b/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts index 2b9f253c1..0fbfbd231 100644 --- a/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts +++ b/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts @@ -9,6 +9,7 @@ import { Component, OnInit } from '@angular/core'; import { AppContext, + AppDto, DateTime, fadeAnimation, UsagesService @@ -35,7 +36,7 @@ export class DashboardPageComponent implements OnInit { public chartCallsCount: any; public chartCallsPerformance: any; - public app = this.ctx.appChanges.filter(x => !!x); + public app = this.ctx.appChanges.filter(x => !!x).map(x => x); public chartOptions = { responsive: true, diff --git a/src/Squidex/app/features/rules/pages/rules/rules-page.component.ts b/src/Squidex/app/features/rules/pages/rules/rules-page.component.ts index 62c491b82..63823659c 100644 --- a/src/Squidex/app/features/rules/pages/rules/rules-page.component.ts +++ b/src/Squidex/app/features/rules/pages/rules/rules-page.component.ts @@ -42,7 +42,7 @@ export class RulesPageComponent implements OnInit { public schemas: SchemaDto[]; public wizardMode = 'Wizard'; - public wizardRule: RuleDto; + public wizardRule: RuleDto | null; constructor(public readonly ctx: AppContext, private readonly schemasService: SchemasService, diff --git a/src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.ts b/src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.ts index 4c0b8750a..51b7724af 100644 --- a/src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.ts +++ b/src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.ts @@ -99,7 +99,7 @@ export class StringValidationComponent implements OnDestroy, OnInit { } else if (this.editForm.controls['pattern'].value && this.editForm.controls['pattern'].value.trim() !== '') { this.patternName = 'Advanced'; } else { - this.patternName = undefined; + this.patternName = ''; } } } \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/http-extensions-impl.ts b/src/Squidex/app/framework/angular/http-extensions-impl.ts index b8dcc9bcc..cbf5c8614 100644 --- a/src/Squidex/app/framework/angular/http-extensions-impl.ts +++ b/src/Squidex/app/framework/angular/http-extensions-impl.ts @@ -112,7 +112,7 @@ export module HTTP { export function pretifyError(message: string): Observable { return this.catch((response: HttpErrorResponse) => { - let result: ErrorDto = null; + let result: ErrorDto | null = null; if (!(response.error instanceof Error)) { try { diff --git a/src/Squidex/app/framework/angular/keys.pipe.ts b/src/Squidex/app/framework/angular/keys.pipe.ts index 8b3b91334..d3b96d442 100644 --- a/src/Squidex/app/framework/angular/keys.pipe.ts +++ b/src/Squidex/app/framework/angular/keys.pipe.ts @@ -12,7 +12,7 @@ import { Pipe, PipeTransform } from '@angular/core'; pure: true }) export class KeysPipe implements PipeTransform { - public transform(value: any, args: any[] = null): any { + public transform(value: any): any { return Object.keys(value); } } \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/onboarding-tooltip.component.ts b/src/Squidex/app/framework/angular/onboarding-tooltip.component.ts index 13dcd0bc1..86ff29192 100644 --- a/src/Squidex/app/framework/angular/onboarding-tooltip.component.ts +++ b/src/Squidex/app/framework/angular/onboarding-tooltip.component.ts @@ -25,7 +25,7 @@ import { fadeAnimation } from './animations'; export class OnboardingTooltipComponent implements OnDestroy, OnInit { private showTimer: any; private closeTimer: any; - private forMouseDownListener: Function; + private forMouseDownListener: Function | null; public tooltipModal = new ModalView(); @@ -91,7 +91,7 @@ export class OnboardingTooltipComponent implements OnDestroy, OnInit { } } - private isSameOrParent(underCursor: Element): boolean { + private isSameOrParent(underCursor: Element | null): boolean { if (!underCursor) { return false; } if (this.for === underCursor) { diff --git a/src/Squidex/app/framework/angular/toggle.component.ts b/src/Squidex/app/framework/angular/toggle.component.ts index 5fa5aaa23..e2b384a39 100644 --- a/src/Squidex/app/framework/angular/toggle.component.ts +++ b/src/Squidex/app/framework/angular/toggle.component.ts @@ -24,7 +24,7 @@ export class ToggleComponent implements ControlValueAccessor { private callChange = (v: any) => { /* NOOP */ }; private callTouched = () => { /* NOOP */ }; - public isChecked: boolean | null = null; + public isChecked: boolean | null | undefined = null; public isDisabled = false; public writeValue(value: boolean | null | undefined) { diff --git a/src/Squidex/app/framework/utils/immutable-array.ts b/src/Squidex/app/framework/utils/immutable-array.ts index bc21c0b32..54f29153a 100644 --- a/src/Squidex/app/framework/utils/immutable-array.ts +++ b/src/Squidex/app/framework/utils/immutable-array.ts @@ -61,7 +61,7 @@ export class ImmutableArray implements Iterable { return new ImmutableArray(this.items.filter(v => predicate(v!))); } - public find(predicate: (item: T, index: number) => boolean): T { + public find(predicate: (item: T, index: number) => boolean): T | undefined { return this.items.find(predicate); } diff --git a/src/Squidex/app/framework/utils/version.ts b/src/Squidex/app/framework/utils/version.ts index 6f8723a41..831b53c14 100644 --- a/src/Squidex/app/framework/utils/version.ts +++ b/src/Squidex/app/framework/utils/version.ts @@ -7,7 +7,7 @@ export class Version { constructor( - public readonly value?: string + public readonly value: string ) { } } \ No newline at end of file diff --git a/src/Squidex/app/shared/components/app-context.ts b/src/Squidex/app/shared/components/app-context.ts index bee564796..2f00b04e3 100644 --- a/src/Squidex/app/shared/components/app-context.ts +++ b/src/Squidex/app/shared/components/app-context.ts @@ -30,7 +30,7 @@ export class AppContext implements OnDestroy { return this.appField; } - public get appChanges(): Observable { + public get appChanges(): Observable { return this.appsStore.selectedApp; } @@ -59,7 +59,7 @@ export class AppContext implements OnDestroy { ) { this.appSubscription = this.appsStore.selectedApp.take(1).subscribe(app => { - this.appField = app; + this.appField = app!; }); } diff --git a/src/Squidex/app/shared/guards/unset-app.guard.spec.ts b/src/Squidex/app/shared/guards/unset-app.guard.spec.ts index e98222b70..e58831ef1 100644 --- a/src/Squidex/app/shared/guards/unset-app.guard.spec.ts +++ b/src/Squidex/app/shared/guards/unset-app.guard.spec.ts @@ -25,9 +25,9 @@ describe('UnsetAppGuard', () => { const guard = new UnsetAppGuard(appStoreService.object); - let result: boolean = undefined; + let result = false; - guard.canActivate(null, null) + guard.canActivate({}, {}) .subscribe(value => { result = value; }); diff --git a/src/Squidex/app/shared/services/assets.service.ts b/src/Squidex/app/shared/services/assets.service.ts index ce2c3071c..b97ef2c93 100644 --- a/src/Squidex/app/shared/services/assets.service.ts +++ b/src/Squidex/app/shared/services/assets.service.ts @@ -198,7 +198,7 @@ export class AssetsService { response.pixelWidth, response.pixelHeight, assetUrl, - new Version(event.headers.get('etag'))); + new Version(event.headers.get('etag')!)); return dto; } @@ -268,7 +268,7 @@ export class AssetsService { response.pixelWidth, response.pixelHeight); - return new Versioned(new Version(event.headers.get('etag')), replaced); + return new Versioned(new Version(event.headers.get('etag')!), replaced); } }) .do(() => { diff --git a/src/Squidex/app/shared/services/auth.service.ts b/src/Squidex/app/shared/services/auth.service.ts index 372ffb7bb..89d380ad4 100644 --- a/src/Squidex/app/shared/services/auth.service.ts +++ b/src/Squidex/app/shared/services/auth.service.ts @@ -35,7 +35,7 @@ export class Profile { } public get isExpired(): boolean { - return this.user.expired; + return this.user.expired || false; } public get authToken(): string { diff --git a/src/Squidex/app/shared/services/schemas.service.ts b/src/Squidex/app/shared/services/schemas.service.ts index 440b11b18..a1a1fd60f 100644 --- a/src/Squidex/app/shared/services/schemas.service.ts +++ b/src/Squidex/app/shared/services/schemas.service.ts @@ -385,10 +385,12 @@ export class StringFieldPropertiesDto extends FieldPropertiesDto { } if (this.allowedValues && this.allowedValues.length > 0) { + const values: (string | null)[] = this.allowedValues; + if (this.isRequired && !isOptional) { - validators.push(ValidatorsEx.validValues(this.allowedValues)); + validators.push(ValidatorsEx.validValues(values)); } else { - validators.push(ValidatorsEx.validValues(this.allowedValues.concat([null]))); + validators.push(ValidatorsEx.validValues(values.concat([null]))); } } @@ -437,10 +439,12 @@ export class NumberFieldPropertiesDto extends FieldPropertiesDto { } if (this.allowedValues && this.allowedValues.length > 0) { + const values: (number | null)[] = this.allowedValues; + if (this.isRequired && !isOptional) { - validators.push(ValidatorsEx.validValues(this.allowedValues)); + validators.push(ValidatorsEx.validValues(values)); } else { - validators.push(ValidatorsEx.validValues(this.allowedValues.concat([null]))); + validators.push(ValidatorsEx.validValues(values.concat([null]))); } } diff --git a/src/Squidex/app/shell/pages/internal/apps-menu.component.ts b/src/Squidex/app/shell/pages/internal/apps-menu.component.ts index c5b07ff01..f164a14f7 100644 --- a/src/Squidex/app/shell/pages/internal/apps-menu.component.ts +++ b/src/Squidex/app/shell/pages/internal/apps-menu.component.ts @@ -36,7 +36,7 @@ export class AppsMenuComponent implements OnDestroy, OnInit { public appsMenu = new ModalView(false, true); public apps: AppDto[] = []; - public selectedApp: AppDto; + public selectedApp: AppDto | null; constructor( private readonly appsStore: AppsStoreService diff --git a/src/Squidex/package.json b/src/Squidex/package.json index 7e6427fb0..5802668d3 100644 --- a/src/Squidex/package.json +++ b/src/Squidex/package.json @@ -15,22 +15,22 @@ "build:clean": "rimraf wwwroot/build" }, "dependencies": { - "@angular/animations": "5.1.0", - "@angular/common": "5.1.0", - "@angular/compiler": "5.1.0", - "@angular/core": "5.1.0", - "@angular/forms": "5.1.0", - "@angular/http": "5.1.0", - "@angular/platform-browser": "5.1.0", - "@angular/platform-browser-dynamic": "5.1.0", - "@angular/platform-server": "5.1.0", - "@angular/router": "5.1.0", + "@angular/animations": "5.1.3", + "@angular/common": "5.1.3", + "@angular/compiler": "5.1.3", + "@angular/core": "5.1.3", + "@angular/forms": "5.1.3", + "@angular/http": "5.1.3", + "@angular/platform-browser": "5.1.3", + "@angular/platform-browser-dynamic": "5.1.3", + "@angular/platform-server": "5.1.3", + "@angular/router": "5.1.3", "angular2-chartjs": "0.4.1", "babel-polyfill": "6.26.0", "bootstrap": "4.0.0-alpha.6", "core-js": "2.5.3", - "graphiql": "0.11.10", - "moment": "2.19.4", + "graphiql": "0.11.11", + "moment": "2.20.1", "mousetrap": "1.6.1", "ng2-dnd": "5.0.2", "oidc-client": "1.4.1", @@ -38,18 +38,18 @@ "progressbar.js": "1.0.1", "react": "16.2.0", "react-dom": "16.2.0", - "rxjs": "5.5.5", - "zone.js": "0.8.18" + "rxjs": "5.5.6", + "zone.js": "0.8.19" }, "devDependencies": { - "@angular/compiler": "5.1.0", - "@angular/compiler-cli": "5.1.0", - "@ngtools/webpack": "1.9.0", - "@types/core-js": "0.9.35", + "@angular/compiler": "5.1.3", + "@angular/compiler-cli": "5.1.3", + "@ngtools/webpack": "1.9.3", + "@types/core-js": "0.9.44", "@types/jasmine": "2.5.45", - "@types/mousetrap": "1.5.34", - "@types/node": "7.0.5", - "@types/react": "16.0.25", + "@types/mousetrap": "1.6", + "@types/node": "8.5.2", + "@types/react": "16.0.34", "@types/react-dom": "16.0.3", "angular2-router-loader": "0.3.5", "angular2-template-loader": "0.6.2", @@ -59,13 +59,13 @@ "css-loader": "0.28.7", "exports-loader": "0.6.4", "extract-text-webpack-plugin": "3.0.2", - "file-loader": "1.1.5", + "file-loader": "1.1.6", "html-loader": "0.5.1", "html-webpack-plugin": "2.30.1", "ignore-loader": "^0.1.2", "istanbul-instrumenter-loader": "0.2.0", "jasmine-core": "2.8.0", - "karma": "1.7.1", + "karma": "2.0.0", "karma-chrome-launcher": "2.2.0", "karma-cli": "1.0.1", "karma-coverage": "1.1.1", @@ -75,7 +75,7 @@ "karma-mocha-reporter": "2.2.5", "karma-phantomjs-launcher": "1.0.4", "karma-sourcemap-loader": "0.3.7", - "karma-webpack": "2.0.6", + "karma-webpack": "2.0.9", "node-sass": "4.7.2", "noop-loader": "^1.0.0", "null-loader": "0.1.1", @@ -84,7 +84,7 @@ "rimraf": "2.6.2", "sass-lint": "1.12.1", "sass-loader": "6.0.6", - "style-loader": "0.19.0", + "style-loader": "0.19.1", "tslint": "5.8.0", "tslint-loader": "3.5.3", "typemoq": "2.1.0", diff --git a/src/Squidex/tsconfig.json b/src/Squidex/tsconfig.json index 54692ff9c..824697758 100644 --- a/src/Squidex/tsconfig.json +++ b/src/Squidex/tsconfig.json @@ -3,13 +3,14 @@ "baseUrl": ".", "emitDecoratorMetadata": true, "experimentalDecorators": true, + "lib": ["es6", "esnext", "dom"], "moduleResolution": "node", "noImplicitAny": true, "noUnusedLocals": true, "noUnusedParameters": false, "removeComments": false, "sourceMap": true, - "strictNullChecks": false, + "strictNullChecks": true, "suppressImplicitAnyIndexErrors": true, "target": "es5", "paths": {