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 31e441741..a8176fc71 100644 --- a/src/Squidex/app/features/content/shared/assets-editor.component.ts +++ b/src/Squidex/app/features/content/shared/assets-editor.component.ts @@ -35,8 +35,8 @@ export const SQX_ASSETS_EDITOR_CONTROL_VALUE_ACCESSOR: any = { }) export class AssetsEditorComponent extends AppComponentBase implements ControlValueAccessor, OnDestroy, OnInit { private assetUpdatedSubscription: Subscription; - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; public newAssets = ImmutableArray.empty(); public oldAssets = ImmutableArray.empty(); @@ -83,11 +83,11 @@ export class AssetsEditorComponent extends AppComponentBase implements ControlVa } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public addFiles(files: FileList) { @@ -142,7 +142,7 @@ export class AssetsEditorComponent extends AppComponentBase implements ControlVa ids = null; } - this.onTouched(); - this.onChange(ids); + this.callTouched(); + this.callChange(ids); } } \ No newline at end of file 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 ded63f413..924250d0a 100644 --- a/src/Squidex/app/features/content/shared/references-editor.component.ts +++ b/src/Squidex/app/features/content/shared/references-editor.component.ts @@ -34,8 +34,8 @@ export const SQX_REFERENCES_EDITOR_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_REFERENCES_EDITOR_CONTROL_VALUE_ACCESSOR] }) export class ReferencesEditorComponent extends AppComponentBase implements ControlValueAccessor, OnInit { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; @Input() public schemaId: string; @@ -91,11 +91,11 @@ export class ReferencesEditorComponent extends AppComponentBase implements Contr } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public canDrop() { @@ -137,8 +137,8 @@ export class ReferencesEditorComponent extends AppComponentBase implements Contr ids = null; } - this.onTouched(); - this.onChange(ids); + this.callTouched(); + this.callChange(ids); } private loadFields() { diff --git a/src/Squidex/app/framework/angular/autocomplete.component.ts b/src/Squidex/app/framework/angular/autocomplete.component.ts index e492a7f6b..5f37f12f0 100644 --- a/src/Squidex/app/framework/angular/autocomplete.component.ts +++ b/src/Squidex/app/framework/angular/autocomplete.component.ts @@ -30,8 +30,8 @@ export const SQX_AUTOCOMPLETE_CONTROL_VALUE_ACCESSOR: any = { }) export class AutocompleteComponent implements ControlValueAccessor, OnDestroy, OnInit { private subscription: Subscription; - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; @Input() public source: AutocompleteSource; @@ -78,11 +78,11 @@ export class AutocompleteComponent implements ControlValueAccessor, OnDestroy, O } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public ngOnDestroy() { @@ -134,7 +134,7 @@ export class AutocompleteComponent implements ControlValueAccessor, OnDestroy, O public blur() { this.reset(); - this.onTouched(); + this.callTouched(); } public selectItem(selection: any | null = null) { @@ -153,7 +153,7 @@ export class AutocompleteComponent implements ControlValueAccessor, OnDestroy, O } else { this.queryInput.setValue(selection.toString(), { emitEvent: false }); } - this.onChange(selection); + this.callChange(selection); } finally { this.reset(); } diff --git a/src/Squidex/app/framework/angular/date-time-editor.component.ts b/src/Squidex/app/framework/angular/date-time-editor.component.ts index 309b3bed4..c766be4c6 100644 --- a/src/Squidex/app/framework/angular/date-time-editor.component.ts +++ b/src/Squidex/app/framework/angular/date-time-editor.component.ts @@ -10,6 +10,8 @@ import { ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR } from '@angular/f import { Subscription } from 'rxjs'; import * as moment from 'moment'; +import { Types } from './../utils/types'; + let Pikaday = require('pikaday/pikaday'); export const SQX_DATE_TIME_EDITOR_CONTROL_VALUE_ACCESSOR: any = { @@ -29,8 +31,8 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy, private timeValue: any | null = null; private dateValue: any | null = null; private suppressEvents = false; - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; @Input() public mode: string; @@ -84,8 +86,8 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy, }); } - public writeValue(value: any) { - if (!value || value.length === 0) { + public writeValue(value: string) { + if (!Types.isString(value) || value.length === 0) { this.timeValue = null; this.dateValue = null; } else { @@ -114,11 +116,11 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy, } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public ngAfterViewInit() { @@ -138,7 +140,7 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy, } public touched() { - this.onTouched(); + this.callTouched(); } public writeNow() { @@ -157,8 +159,8 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy, this.dateValue = null; - this.onChange(null); - this.onTouched(); + this.callChange(null); + this.callTouched(); return false; } @@ -182,7 +184,7 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy, } } - this.onChange(result); + this.callChange(result); } private updateControls() { diff --git a/src/Squidex/app/framework/angular/dropdown.component.ts b/src/Squidex/app/framework/angular/dropdown.component.ts index f7d0fc118..858742e66 100644 --- a/src/Squidex/app/framework/angular/dropdown.component.ts +++ b/src/Squidex/app/framework/angular/dropdown.component.ts @@ -26,8 +26,8 @@ export const SQX_DROPDOWN_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_DROPDOWN_CONTROL_VALUE_ACCESSOR] }) export class DropdownComponent implements AfterContentInit, ControlValueAccessor { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; @Input() public items: any[] = []; @@ -68,11 +68,11 @@ export class DropdownComponent implements AfterContentInit, ControlValueAccessor } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public onKeyDown(event: KeyboardEvent) { @@ -94,7 +94,7 @@ export class DropdownComponent implements AfterContentInit, ControlValueAccessor public open() { this.dropdown.show(); - this.onTouched(); + this.callTouched(); } public selectIndexAndClose(selectedIndex: number) { @@ -131,7 +131,7 @@ export class DropdownComponent implements AfterContentInit, ControlValueAccessor this.selectedIndex = selectedIndex; this.selectedItem = value; - this.onChange(value); + this.callChange(value); } } } \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/geolocation-editor.component.ts b/src/Squidex/app/framework/angular/geolocation-editor.component.ts index 3cf44cbf3..6226b8ac3 100644 --- a/src/Squidex/app/framework/angular/geolocation-editor.component.ts +++ b/src/Squidex/app/framework/angular/geolocation-editor.component.ts @@ -31,8 +31,8 @@ interface Geolocation { providers: [SQX_GEOLOCATION_EDITOR_CONTROL_VALUE_ACCESSOR] }) export class GeolocationEditorComponent implements ControlValueAccessor, AfterViewInit { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; private marker: any; private map: any; private value: Geolocation | null = null; @@ -111,11 +111,11 @@ export class GeolocationEditorComponent implements ControlValueAccessor, AfterVi } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public updateValueByInput() { @@ -210,8 +210,8 @@ export class GeolocationEditorComponent implements ControlValueAccessor, AfterVi } if (fireEvent) { - this.onChange(this.value); - this.onTouched(); + this.callChange(this.value); + this.callTouched(); } } } \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/indeterminate-value.directive.ts b/src/Squidex/app/framework/angular/indeterminate-value.directive.ts index 034bd5b79..8cec0c565 100644 --- a/src/Squidex/app/framework/angular/indeterminate-value.directive.ts +++ b/src/Squidex/app/framework/angular/indeterminate-value.directive.ts @@ -19,8 +19,8 @@ export const SQX_INDETERMINATE_VALUE_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_INDETERMINATE_VALUE_CONTROL_VALUE_ACCESSOR] }) export class IndeterminateValueDirective implements ControlValueAccessor { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; constructor( private readonly renderer: Renderer, @@ -30,12 +30,12 @@ export class IndeterminateValueDirective implements ControlValueAccessor { @HostListener('change', ['$event.target.value']) public onChange(value: any) { - this.onChange(value); + this.callChange(value); } @HostListener('blur') public onTouched() { - this.onTouched(); + this.callTouched(); } public writeValue(value: boolean | number | undefined) { @@ -51,10 +51,10 @@ export class IndeterminateValueDirective implements ControlValueAccessor { } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } } \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/jscript-editor.component.ts b/src/Squidex/app/framework/angular/jscript-editor.component.ts index e2b7cc74e..d3fc0df0d 100644 --- a/src/Squidex/app/framework/angular/jscript-editor.component.ts +++ b/src/Squidex/app/framework/angular/jscript-editor.component.ts @@ -26,8 +26,8 @@ export const SQX_JSCRIPT_EDITOR_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_JSCRIPT_EDITOR_CONTROL_VALUE_ACCESSOR] }) export class JscriptEditorComponent implements ControlValueAccessor, AfterViewInit { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; private valueChanged = new Subject(); private aceEditor: any; private value: string; @@ -58,11 +58,11 @@ export class JscriptEditorComponent implements ControlValueAccessor, AfterViewIn } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public ngAfterViewInit() { @@ -82,7 +82,7 @@ export class JscriptEditorComponent implements ControlValueAccessor, AfterViewIn this.aceEditor.on('blur', () => { this.changeValue(); - this.onTouched(); + this.callTouched(); }); this.aceEditor.on('change', () => { @@ -95,7 +95,7 @@ export class JscriptEditorComponent implements ControlValueAccessor, AfterViewIn const newValue = this.aceEditor.getValue(); if (this.value !== newValue) { - this.onChange(newValue); + this.callChange(newValue); } this.value = newValue; diff --git a/src/Squidex/app/framework/angular/json-editor.component.ts b/src/Squidex/app/framework/angular/json-editor.component.ts index 90beb4b27..263a1be2f 100644 --- a/src/Squidex/app/framework/angular/json-editor.component.ts +++ b/src/Squidex/app/framework/angular/json-editor.component.ts @@ -24,8 +24,8 @@ export const SQX_JSON_EDITOR_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_JSON_EDITOR_CONTROL_VALUE_ACCESSOR] }) export class JsonEditorComponent implements ControlValueAccessor, AfterViewInit { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; private valueChanged = new Subject(); private aceEditor: any; private value: any; @@ -63,11 +63,11 @@ export class JsonEditorComponent implements ControlValueAccessor, AfterViewInit } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public ngAfterViewInit() { @@ -87,7 +87,7 @@ export class JsonEditorComponent implements ControlValueAccessor, AfterViewInit this.aceEditor.on('blur', () => { this.changeValue(); - this.onTouched(); + this.callTouched(); }); this.aceEditor.on('change', () => { @@ -112,7 +112,7 @@ export class JsonEditorComponent implements ControlValueAccessor, AfterViewInit const newValueString = JSON.stringify(newValue); if (this.valueString !== newValueString) { - this.onChange(newValue); + this.callChange(newValue); } this.value = newValue; diff --git a/src/Squidex/app/framework/angular/lowercase-input.directive.ts b/src/Squidex/app/framework/angular/lowercase-input.directive.ts index 66d61338d..6645d1697 100644 --- a/src/Squidex/app/framework/angular/lowercase-input.directive.ts +++ b/src/Squidex/app/framework/angular/lowercase-input.directive.ts @@ -8,6 +8,8 @@ import { Directive, forwardRef, ElementRef, HostListener, Renderer } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { Types } from './../utils/types'; + export const SQX_LOWERCASE_INPUT_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => LowerCaseInputDirective), multi: true }; @@ -17,8 +19,8 @@ export const SQX_LOWERCASE_INPUT_VALUE_ACCESSOR: any = { providers: [SQX_LOWERCASE_INPUT_VALUE_ACCESSOR] }) export class LowerCaseInputDirective implements ControlValueAccessor { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; constructor( private readonly element: ElementRef, @@ -31,16 +33,16 @@ export class LowerCaseInputDirective implements ControlValueAccessor { const normalizedValue = (value == null ? '' : value.toString()).toLowerCase(); this.renderer.setElementProperty(this.element.nativeElement, 'value', normalizedValue); - this.onChange(normalizedValue); + this.callChange(normalizedValue); } @HostListener('blur') public onTouched() { - this.onTouched(); + this.callTouched(); } - public writeValue(value: any) { - const normalizedValue = value ? '' : value.toString().toLowerCase(); + public writeValue(value: string) { + const normalizedValue = Types.isString(value) ? value.toLowerCase() : ''; this.renderer.setElementProperty(this.element.nativeElement, 'value', normalizedValue); } @@ -50,10 +52,10 @@ export class LowerCaseInputDirective implements ControlValueAccessor { } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } } \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/markdown-editor.component.ts b/src/Squidex/app/framework/angular/markdown-editor.component.ts index 9716ef10f..41d4cefc8 100644 --- a/src/Squidex/app/framework/angular/markdown-editor.component.ts +++ b/src/Squidex/app/framework/angular/markdown-editor.component.ts @@ -25,8 +25,8 @@ export const SQX_MARKDOWN_EDITOR_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_MARKDOWN_EDITOR_CONTROL_VALUE_ACCESSOR] }) export class MarkdownEditorComponent implements ControlValueAccessor, AfterViewInit { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; private simplemde: any; private value: string; private isDisabled = false; @@ -65,11 +65,11 @@ export class MarkdownEditorComponent implements ControlValueAccessor, AfterViewI } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public ngAfterViewInit() { @@ -84,12 +84,12 @@ export class MarkdownEditorComponent implements ControlValueAccessor, AfterViewI if (this.value !== value) { this.value = value; - this.onChange(value); + this.callChange(value); } }); this.simplemde.codemirror.on('blur', () => { - this.onTouched(); + this.callTouched(); }); this.simplemde.codemirror.on('refresh', () => { diff --git a/src/Squidex/app/framework/angular/rich-editor.component.ts b/src/Squidex/app/framework/angular/rich-editor.component.ts index c690ed43a..6c5806cc5 100644 --- a/src/Squidex/app/framework/angular/rich-editor.component.ts +++ b/src/Squidex/app/framework/angular/rich-editor.component.ts @@ -25,8 +25,8 @@ export const SQX_RICH_EDITOR_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_RICH_EDITOR_CONTROL_VALUE_ACCESSOR] }) export class RichEditorComponent implements ControlValueAccessor, AfterViewInit, OnDestroy { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; private tinyEditor: any; private value: string; private isDisabled = false; @@ -56,11 +56,11 @@ export class RichEditorComponent implements ControlValueAccessor, AfterViewInit, } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public ngAfterViewInit() { @@ -78,12 +78,12 @@ export class RichEditorComponent implements ControlValueAccessor, AfterViewInit, if (this.value !== value) { this.value = value; - self.onChange(value); + self.callChange(value); } }); self.tinyEditor.on('blur', () => { - self.onTouched(); + self.callTouched(); }); setTimeout(() => { diff --git a/src/Squidex/app/framework/angular/slider.component.ts b/src/Squidex/app/framework/angular/slider.component.ts index 2fe82b581..bab84dbdb 100644 --- a/src/Squidex/app/framework/angular/slider.component.ts +++ b/src/Squidex/app/framework/angular/slider.component.ts @@ -21,8 +21,8 @@ export const SQX_SLIDER_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_SLIDER_CONTROL_VALUE_ACCESSOR] }) export class SliderComponent implements ControlValueAccessor { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; private mouseMoveSubscription: Function | null = null; private mouseUpSubscription: Function | null = null; private centerStartOffset = 0; @@ -61,11 +61,11 @@ export class SliderComponent implements ControlValueAccessor { } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public onBarMouseClick(event: MouseEvent): boolean { @@ -157,14 +157,14 @@ export class SliderComponent implements ControlValueAccessor { } private updateTouched() { - this.onTouched(); + this.callTouched(); } private updateValue() { if (this.lastValue !== this.value) { this.lastValue = this.value; - this.onChange(this.value); + this.callChange(this.value); } } diff --git a/src/Squidex/app/framework/angular/stars.component.ts b/src/Squidex/app/framework/angular/stars.component.ts index 6afa84d37..c73b0184e 100644 --- a/src/Squidex/app/framework/angular/stars.component.ts +++ b/src/Squidex/app/framework/angular/stars.component.ts @@ -21,8 +21,8 @@ export const SQX_STARS_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_STARS_CONTROL_VALUE_ACCESSOR] }) export class StarsComponent implements ControlValueAccessor { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; private maximumStarsValue = 5; @Input() @@ -53,7 +53,7 @@ export class StarsComponent implements ControlValueAccessor { public writeValue(value: number | null | undefined) { if (Types.isNumber(value)) { - this.value = this.stars = value!; + this.value = this.stars = value || 0; } else { this.value = null; this.stars = 0; @@ -65,11 +65,11 @@ export class StarsComponent implements ControlValueAccessor { } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public setPreview(value: number) { @@ -97,8 +97,8 @@ export class StarsComponent implements ControlValueAccessor { this.value = null; this.stars = 0; - this.onChange(this.value); - this.onTouched(); + this.callChange(this.value); + this.callTouched(); } return false; @@ -112,8 +112,8 @@ export class StarsComponent implements ControlValueAccessor { if (this.value !== value) { this.value = this.stars = value; - this.onChange(this.value); - this.onTouched(); + this.callChange(this.value); + this.callTouched(); } return false; diff --git a/src/Squidex/app/framework/angular/tag-editor.component.ts b/src/Squidex/app/framework/angular/tag-editor.component.ts index e379b1947..87a6e6383 100644 --- a/src/Squidex/app/framework/angular/tag-editor.component.ts +++ b/src/Squidex/app/framework/angular/tag-editor.component.ts @@ -72,8 +72,8 @@ export const SQX_TAG_EDITOR_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_TAG_EDITOR_CONTROL_VALUE_ACCESSOR] }) export class TagEditorComponent implements ControlValueAccessor { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; @Input() public converter: Converter = new StringConverter(); @@ -107,11 +107,11 @@ export class TagEditorComponent implements ControlValueAccessor { } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public remove(index: number) { @@ -119,7 +119,7 @@ export class TagEditorComponent implements ControlValueAccessor { } public markTouched() { - this.onTouched(); + this.callTouched(); } private resetForm() { @@ -146,9 +146,9 @@ export class TagEditorComponent implements ControlValueAccessor { this.items = items; if (items.length === 0 && this.useDefaultValue) { - this.onChange(undefined); + this.callChange(undefined); } else { - this.onChange(this.items); + this.callChange(this.items); } } } \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/toggle.component.ts b/src/Squidex/app/framework/angular/toggle.component.ts index c45705ce3..bac7739ba 100644 --- a/src/Squidex/app/framework/angular/toggle.component.ts +++ b/src/Squidex/app/framework/angular/toggle.component.ts @@ -21,14 +21,14 @@ export const SQX_TOGGLE_CONTROL_VALUE_ACCESSOR: any = { providers: [SQX_TOGGLE_CONTROL_VALUE_ACCESSOR] }) export class ToggleComponent implements ControlValueAccessor { - private onChange = (v: any) => { /* NOOP */ }; - private onTouched = () => { /* NOOP */ }; + private callChange = (v: any) => { /* NOOP */ }; + private callTouched = () => { /* NOOP */ }; public isChecked: boolean | null = null; public isDisabled = false; public writeValue(value: boolean | null | undefined) { - this.isChecked = Types.isBoolean(value) ? value! : null; + this.isChecked = Types.isBoolean(value) ? value || null : null; } public setDisabledState(isDisabled: boolean): void { @@ -36,11 +36,11 @@ export class ToggleComponent implements ControlValueAccessor { } public registerOnChange(fn: any) { - this.onChange = fn; + this.callChange = fn; } public registerOnTouched(fn: any) { - this.onTouched = fn; + this.callTouched = fn; } public changeState() { @@ -50,7 +50,7 @@ export class ToggleComponent implements ControlValueAccessor { this.isChecked = !(this.isChecked === true); - this.onChange(this.isChecked); - this.onTouched(); + this.callChange(this.isChecked); + this.callTouched(); } } \ No newline at end of file diff --git a/src/Squidex/app/shared/services/assets.service.spec.ts b/src/Squidex/app/shared/services/assets.service.spec.ts index 8a23706b1..f55da60ec 100644 --- a/src/Squidex/app/shared/services/assets.service.spec.ts +++ b/src/Squidex/app/shared/services/assets.service.spec.ts @@ -21,24 +21,26 @@ import { } from './../'; describe('AssetDto', () => { - it('should update name property and user info when renaming', () => { - const now = DateTime.now(); + const creation = DateTime.today(); + const creator = 'not-me'; + const modified = DateTime.now(); + const modifier = 'me'; + const version = new Version('2'); - const asset_1 = new AssetDto('1', 'other', 'other', DateTime.today(), DateTime.today(), 'name.png', 'png', 1, 1, 'image/png', false, 1, 1, new Version('1')); - const asset_2 = asset_1.rename('new-name.png', 'me', now); + it('should update name property and user info when renaming', () => { + const asset_1 = new AssetDto('1', creator, creator, creation, creation, 'name.png', 'png', 1, 1, 'image/png', false, 1, 1, version); + const asset_2 = asset_1.rename('new-name.png', modifier, modified); expect(asset_2.fileName).toEqual('new-name.png'); - expect(asset_2.lastModified).toEqual(now); - expect(asset_2.lastModifiedBy).toEqual('me'); + expect(asset_2.lastModified).toEqual(modified); + expect(asset_2.lastModifiedBy).toEqual(modifier); }); it('should update file properties when uploading', () => { - const now = DateTime.now(); - - const update = new AssetReplacedDto(2, 2, 'image/jpeg', true, 2, 2, new Version('1')); + const update = new AssetReplacedDto(2, 2, 'image/jpeg', true, 2, 2, new Version('2')); - const asset_1 = new AssetDto('1', 'other', 'other', DateTime.today(), DateTime.today(), 'name.png', 'png', 1, 1, 'image/png', false, 1, 1, new Version('1')); - const asset_2 = asset_1.update(update, 'me', now); + const asset_1 = new AssetDto('1', creator, creator, creation, creation, 'name.png', 'png', 1, 1, 'image/png', false, 1, 1, version); + const asset_2 = asset_1.update(update, modifier, modified); expect(asset_2.fileSize).toEqual(2); expect(asset_2.fileVersion).toEqual(2); @@ -46,8 +48,8 @@ describe('AssetDto', () => { expect(asset_2.isImage).toBeTruthy(); expect(asset_2.pixelWidth).toEqual(2); expect(asset_2.pixelHeight).toEqual(2); - expect(asset_2.lastModified).toEqual(now); - expect(asset_2.lastModifiedBy).toEqual('me'); + expect(asset_2.lastModified).toEqual(modified); + expect(asset_2.lastModifiedBy).toEqual(modifier); expect(asset_2.version).toEqual(update); }); }); diff --git a/src/Squidex/app/shared/services/contents.service.spec.ts b/src/Squidex/app/shared/services/contents.service.spec.ts index 54a0a92d1..6385871fd 100644 --- a/src/Squidex/app/shared/services/contents.service.spec.ts +++ b/src/Squidex/app/shared/services/contents.service.spec.ts @@ -19,43 +19,43 @@ import { } from './../'; describe('ContentDto', () => { - it('should update data property and user info when updating', () => { - const now = DateTime.now(); + const creation = DateTime.today(); + const creator = 'not-me'; + const modified = DateTime.now(); + const modifier = 'me'; + const version = new Version('1'); - const content_1 = new ContentDto('1', false, false, 'other', 'other', DateTime.now(), DateTime.now(), { data: 1 }, new Version('1')); - const content_2 = content_1.update({ data: 2 }, 'me', now); + it('should update data property and user info when updating', () => { + const content_1 = new ContentDto('1', false, false, creator, creator, creation, creation, { data: 1 }, version); + const content_2 = content_1.update({ data: 2 }, modifier, modified); expect(content_2.data).toEqual({ data: 2 }); - expect(content_2.lastModified).toEqual(now); - expect(content_2.lastModifiedBy).toEqual('me'); + expect(content_2.lastModified).toEqual(modified); + expect(content_2.lastModifiedBy).toEqual(modifier); }); it('should update isPublished property and user info when publishing', () => { - const now = DateTime.now(); - - const content_1 = new ContentDto('1', false, false, 'other', 'other', DateTime.now(), DateTime.now(), { data: 1 }, new Version('1')); - const content_2 = content_1.publish('me', now); + const content_1 = new ContentDto('1', false, false, creator, creator, creation, creation, { data: 1 }, version); + const content_2 = content_1.publish(modifier, modified); expect(content_2.isPublished).toBeTruthy(); - expect(content_2.lastModified).toEqual(now); - expect(content_2.lastModifiedBy).toEqual('me'); + expect(content_2.lastModified).toEqual(modified); + expect(content_2.lastModifiedBy).toEqual(modifier); }); it('should update isPublished property and user info when unpublishing', () => { - const now = DateTime.now(); - - const content_1 = new ContentDto('1', true, false, 'other', 'other', DateTime.now(), DateTime.now(), { data: 1 }, new Version('1')); - const content_2 = content_1.unpublish('me', now); + const content_1 = new ContentDto('1', true, false, creator, creator, creation, creation, { data: 1 }, version); + const content_2 = content_1.unpublish(modifier, modified); expect(content_2.isPublished).toBeFalsy(); - expect(content_2.lastModified).toEqual(now); - expect(content_2.lastModifiedBy).toEqual('me'); + expect(content_2.lastModified).toEqual(modified); + expect(content_2.lastModifiedBy).toEqual(modifier); }); it('should update data property when setting data', () => { const newData = {}; - const content_1 = new ContentDto('1', true, false, 'other', 'other', DateTime.now(), DateTime.now(), { data: 1 }, new Version('1')); + const content_1 = new ContentDto('1', true, false, creator, creator, creation, creation, { data: 1 }, version); const content_2 = content_1.setData(newData); expect(content_2.data).toBe(newData); diff --git a/src/Squidex/app/shared/services/schemas.service.spec.ts b/src/Squidex/app/shared/services/schemas.service.spec.ts index 7018ff6d6..b80b9be17 100644 --- a/src/Squidex/app/shared/services/schemas.service.spec.ts +++ b/src/Squidex/app/shared/services/schemas.service.spec.ts @@ -28,40 +28,39 @@ import { describe('SchemaDto', () => { const properties = new SchemaPropertiesDto('Name'); + const creation = DateTime.today(); + const creator = 'not-me'; + const modified = DateTime.now(); + const modifier = 'me'; + const version = new Version('1'); it('should update isPublished property and user info when publishing', () => { - const now = DateTime.now(); - - const schema_1 = new SchemaDto('1', 'name', properties, false, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1')); - const schema_2 = schema_1.publish('me', now); + const schema_1 = new SchemaDto('1', 'name', properties, false, creator, creator, creation, creation, version); + const schema_2 = schema_1.publish(modifier, modified); expect(schema_2.isPublished).toBeTruthy(); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); it('should update isPublished property and user info when unpublishing', () => { - const now = DateTime.now(); - - const schema_1 = new SchemaDto('1', 'name', properties, true, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1')); - const schema_2 = schema_1.unpublish('me', now); + const schema_1 = new SchemaDto('1', 'name', properties, false, creator, creator, creation, creation, version); + const schema_2 = schema_1.unpublish(modifier, modified); expect(schema_2.isPublished).toBeFalsy(); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); it('should update properties property and user info when updating', () => { const newProperties = new SchemaPropertiesDto('New Name'); - const now = DateTime.now(); - - const schema_1 = new SchemaDto('1', 'name', properties, false, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1')); - const schema_2 = schema_1.update(newProperties, 'me', now); + const schema_1 = new SchemaDto('1', 'name', properties, false, creator, creator, creation, creation, version); + const schema_2 = schema_1.update(newProperties, modifier, modified); expect(schema_2.properties).toEqual(newProperties); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); it('should update scripts properties and user info when configure scripts', () => { @@ -74,10 +73,8 @@ describe('SchemaDto', () => { '', ''); - const now = DateTime.now(); - - const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1'), []); - const schema_2 = schema_1.configureScripts(newScripts, 'me', now); + const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, creator, creator, creation, creation, version, []); + const schema_2 = schema_1.configureScripts(newScripts, modifier, modified); expect(schema_2.scriptQuery).toEqual(''); expect(schema_2.scriptCreate).toEqual(''); @@ -85,89 +82,82 @@ describe('SchemaDto', () => { expect(schema_2.scriptDelete).toEqual(''); expect(schema_2.scriptPublish).toEqual(''); expect(schema_2.scriptUnpublish).toEqual(''); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); }); describe('SchemaDetailsDto', () => { const properties = new SchemaPropertiesDto('Name'); + const creation = DateTime.today(); + const creator = 'not-me'; + const modified = DateTime.now(); + const modifier = 'me'; + const version = new Version('1'); it('should update isPublished property and user info when publishing', () => { - const now = DateTime.now(); - - const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1'), []); - const schema_2 = schema_1.publish('me', now); + const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, creator, creator, creation, creation, version, []); + const schema_2 = schema_1.publish(modifier, modified); expect(schema_2.isPublished).toBeTruthy(); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); it('should update isPublished property and user info when unpublishing', () => { - const now = DateTime.now(); - - const schema_1 = new SchemaDetailsDto('1', 'name', properties, true, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1'), []); - const schema_2 = schema_1.unpublish('me', now); + const schema_1 = new SchemaDetailsDto('1', 'name', properties, true, creator, creator, creation, creation, version, []); + const schema_2 = schema_1.unpublish(modifier, modified); expect(schema_2.isPublished).toBeFalsy(); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); it('should update properties property and user info when updating', () => { const newProperties = new SchemaPropertiesDto('New Name'); - const now = DateTime.now(); - - const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1'), []); - const schema_2 = schema_1.update(newProperties, 'me', now); + const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, creator, creator, creation, creation, version, []); + const schema_2 = schema_1.update(newProperties, modifier, modified); expect(schema_2.properties).toEqual(newProperties); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); it('should update fields property and user info when adding field', () => { const field1 = new FieldDto(1, '1', false, false, false, 'l', createProperties('String')); const field2 = new FieldDto(2, '2', false, false, false, 'l', createProperties('Number')); - const now = DateTime.now(); - - const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1'), [field1]); - const schema_2 = schema_1.addField(field2, 'me', now); + const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, creator, creator, creation, creation, version, [field1]); + const schema_2 = schema_1.addField(field2, modifier, modified); expect(schema_2.fields).toEqual([field1, field2]); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); it('should update fields property and user info when removing field', () => { const field1 = new FieldDto(1, '1', false, false, false, 'l', createProperties('String')); const field2 = new FieldDto(2, '2', false, false, false, 'l', createProperties('Number')); - const now = DateTime.now(); - - const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1'), [field1, field2]); - const schema_2 = schema_1.removeField(field1, 'me', now); + const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, creator, creator, creation, creation, version, [field1, field2]); + const schema_2 = schema_1.removeField(field1, modifier, modified); expect(schema_2.fields).toEqual([field2]); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); it('should update fields property and user info when replacing fields', () => { const field1 = new FieldDto(1, '1', false, false, false, 'l', createProperties('String')); const field2 = new FieldDto(2, '2', false, false, false, 'l', createProperties('Number')); - const now = DateTime.now(); - - const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1'), [field1, field2]); - const schema_2 = schema_1.replaceFields([field2, field1], 'me', now); + const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, creator, creator, creation, creation, version, [field1, field2]); + const schema_2 = schema_1.replaceFields([field2, field1], modifier, modified); expect(schema_2.fields).toEqual([field2, field1]); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); it('should update fields property and user info when updating field', () => { @@ -175,14 +165,12 @@ describe('SchemaDetailsDto', () => { const field2_1 = new FieldDto(2, '2', false, false, false, 'l', createProperties('Number')); const field2_2 = new FieldDto(2, '2', false, false, false, 'l', createProperties('Boolean')); - const now = DateTime.now(); - - const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, 'other', 'other', DateTime.now(), DateTime.now(), new Version('1'), [field1_0, field2_1]); - const schema_2 = schema_1.updateField(field2_2, 'me', now); + const schema_1 = new SchemaDetailsDto('1', 'name', properties, false, creator, creator, creation, creation, version, [field1_0, field2_1]); + const schema_2 = schema_1.updateField(field2_2, modifier, modified); expect(schema_2.fields).toEqual([field1_0, field2_2]); - expect(schema_2.lastModified).toEqual(now); - expect(schema_2.lastModifiedBy).toEqual('me'); + expect(schema_2.lastModified).toEqual(modifier); + expect(schema_2.lastModifiedBy).toEqual(modified); }); }); diff --git a/src/Squidex/app/shared/services/schemas.service.ts b/src/Squidex/app/shared/services/schemas.service.ts index 42ca23c75..6f054326e 100644 --- a/src/Squidex/app/shared/services/schemas.service.ts +++ b/src/Squidex/app/shared/services/schemas.service.ts @@ -797,7 +797,7 @@ export class SchemasService { user, now, now, - version || new Version('0'), + version, dto.fields || [], response.scriptQuery, response.scriptCreate, diff --git a/src/Squidex/app/shared/services/webhooks.service.spec.ts b/src/Squidex/app/shared/services/webhooks.service.spec.ts index 52a22513f..023266f8c 100644 --- a/src/Squidex/app/shared/services/webhooks.service.spec.ts +++ b/src/Squidex/app/shared/services/webhooks.service.spec.ts @@ -23,21 +23,25 @@ import { } from './../'; describe('WebhookDto', () => { - const now = DateTime.now(); - const user = 'me'; + const creation = DateTime.today(); + const creator = 'not-me'; + const modified = DateTime.now(); + const modifier = 'me'; const version = new Version('1'); it('should update url and schemas', () => { - const webhook_1 = new WebhookDto('id1', 'token1', user, user, now, now, version, [], 'http://squidex.io/hook', 1, 2, 3, 4); + const webhook_1 = new WebhookDto('id1', 'token1', creator, creator, creation, creation, version, [], 'http://squidex.io/hook', 1, 2, 3, 4); const webhook_2 = webhook_1.update(new UpdateWebhookDto('http://squidex.io/hook2', [ new WebhookSchemaDto('1', true, true, true, true, true), new WebhookSchemaDto('2', true, true, true, true, true) - ]), user, now); + ]), modifier, modified); expect(webhook_2.url).toEqual('http://squidex.io/hook2'); expect(webhook_2.schemas.length).toEqual(2); + expect(webhook_2.lastModified).toEqual(modified); + expect(webhook_2.lastModifiedBy).toEqual(modifier); }); }); diff --git a/src/Squidex/tsconfig.json b/src/Squidex/tsconfig.json index b740cdfc7..54692ff9c 100644 --- a/src/Squidex/tsconfig.json +++ b/src/Squidex/tsconfig.json @@ -9,7 +9,7 @@ "noUnusedParameters": false, "removeComments": false, "sourceMap": true, - "strictNullChecks": true, + "strictNullChecks": false, "suppressImplicitAnyIndexErrors": true, "target": "es5", "paths": {