Browse Source

Change detector.

pull/329/head
Sebastian Stehle 7 years ago
parent
commit
4b75fb6123
  1. 4
      src/Squidex/app/features/content/shared/assets-editor.component.ts
  2. 4
      src/Squidex/app/features/content/shared/references-editor.component.ts
  3. 13
      src/Squidex/app/framework/angular/forms/date-time-editor.component.ts
  4. 11
      src/Squidex/app/framework/angular/forms/dropdown.component.ts
  5. 16
      src/Squidex/app/framework/angular/forms/slider.component.ts
  6. 11
      src/Squidex/app/framework/angular/forms/stars.component.ts
  7. 9
      src/Squidex/app/framework/angular/forms/tag-editor.component.ts
  8. 11
      src/Squidex/app/framework/angular/forms/toggle.component.ts
  9. 5
      src/Squidex/app/shared/components/geolocation-editor.component.ts

4
src/Squidex/app/features/content/shared/assets-editor.component.ts

@ -74,11 +74,15 @@ export class AssetsEditorComponent implements ControlValueAccessor {
}
} else {
this.oldAssets = ImmutableArray.empty();
this.changeDetector.detectChanges();
}
}
public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled;
this.changeDetector.detectChanges();
}
public registerOnChange(fn: any) {

4
src/Squidex/app/features/content/shared/references-editor.component.ts

@ -104,11 +104,15 @@ export class ReferencesEditorComponent implements ControlValueAccessor, OnInit {
}
} else {
this.contentItems = ImmutableArray.empty();
this.changeDetector.detectChanges();
}
}
public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled;
this.changeDetector.detectChanges();
}
public registerOnChange(fn: any) {

13
src/Squidex/app/framework/angular/forms/date-time-editor.component.ts

@ -44,8 +44,12 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy,
@Input()
public hideClear: boolean;
public timeControl = new FormControl();
@ViewChild('dateInput')
public dateInput: ElementRef;
public isDisabled = false;
public timeControl = new FormControl();
public dateControl = new FormControl();
public get showTime() {
@ -56,11 +60,6 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy,
return !!this.dateValue;
}
@ViewChild('dateInput')
public dateInput: ElementRef;
public isDisabled = false;
constructor(
private readonly changeDetector: ChangeDetectorRef
) {
@ -122,6 +121,8 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy,
this.dateControl.enable({ emitEvent: false });
this.timeControl.enable({ emitEvent: false });
}
this.changeDetector.detectChanges();
}
public registerOnChange(fn: any) {

11
src/Squidex/app/framework/angular/forms/dropdown.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { AfterContentInit, ChangeDetectionStrategy, Component, ContentChildren, forwardRef, Input, QueryList, TemplateRef } from '@angular/core';
import { AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, forwardRef, Input, QueryList, TemplateRef } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
const KEY_ENTER = 13;
@ -46,6 +46,11 @@ export class DropdownComponent implements AfterContentInit, ControlValueAccessor
public isDisabled = false;
constructor(
private readonly changeDetector: ChangeDetectorRef
) {
}
public ngAfterContentInit() {
if (this.templates.length === 1) {
this.itemTemplate = this.selectionTemplate = this.templates.first;
@ -62,10 +67,14 @@ export class DropdownComponent implements AfterContentInit, ControlValueAccessor
public writeValue(obj: any) {
this.selectIndex(this.items && obj ? this.items.indexOf(obj) : 0);
this.changeDetector.detectChanges();
}
public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled;
this.changeDetector.detectChanges();
}
public registerOnChange(fn: any) {

16
src/Squidex/app/framework/angular/forms/slider.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { ChangeDetectionStrategy, Component, ElementRef, forwardRef, Input, Renderer2, ViewChild } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, forwardRef, Input, Renderer2, ViewChild } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Types } from '@app/framework/internal';
@ -31,8 +31,6 @@ export class SliderComponent implements ControlValueAccessor {
private value: number;
private isDragging = false;
public isDisabled = false;
@ViewChild('bar')
public bar: ElementRef;
@ -48,16 +46,26 @@ export class SliderComponent implements ControlValueAccessor {
@Input()
public step = 1;
constructor(private readonly renderer: Renderer2) { }
public isDisabled = false;
constructor(
private readonly changeDetector: ChangeDetectorRef,
private readonly renderer: Renderer2
) {
}
public writeValue(obj: any) {
this.lastValue = this.value = Types.isNumber(obj) ? obj : 0;
this.updateThumbPosition();
this.changeDetector.detectChanges();
}
public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled;
this.changeDetector.detectChanges();
}
public registerOnChange(fn: any) {

11
src/Squidex/app/framework/angular/forms/stars.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { ChangeDetectionStrategy, Component, forwardRef, Input } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, forwardRef, Input } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Types } from '@app/framework/internal';
@ -52,12 +52,21 @@ export class StarsComponent implements ControlValueAccessor {
public value: number | null = 1;
constructor(
private readonly changeDetector: ChangeDetectorRef
) {
}
public writeValue(obj: any) {
this.value = this.stars = Types.isNumber(obj) ? obj : 0;
this.changeDetector.markForCheck();
}
public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled;
this.changeDetector.markForCheck();
}
public registerOnChange(fn: any) {

9
src/Squidex/app/framework/angular/forms/tag-editor.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, forwardRef, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, forwardRef, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Subscription } from 'rxjs';
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
@ -129,6 +129,11 @@ export class TagEditorComponent implements AfterViewInit, ControlValueAccessor,
public addInput = new FormControl();
constructor(
private readonly changeDetector: ChangeDetectorRef
) {
}
public ngOnDestroy() {
this.subscription.unsubscribe();
}
@ -179,6 +184,8 @@ export class TagEditorComponent implements AfterViewInit, ControlValueAccessor,
} else {
this.items = [];
}
this.changeDetector.detectChanges();
}
public setDisabledState(isDisabled: boolean): void {

11
src/Squidex/app/framework/angular/forms/toggle.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { ChangeDetectionStrategy, Component, forwardRef } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, forwardRef } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Types } from '@app/framework/internal';
@ -28,12 +28,21 @@ export class ToggleComponent implements ControlValueAccessor {
public isChecked: boolean | null = null;
public isDisabled = false;
constructor(
private readonly changeDetector: ChangeDetectorRef
) {
}
public writeValue(obj: any) {
this.isChecked = Types.isBoolean(obj) ? obj : null;
this.changeDetector.detectChanges();
}
public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled;
this.changeDetector.detectChanges();
}
public registerOnChange(fn: any) {

5
src/Squidex/app/shared/components/geolocation-editor.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, forwardRef, ViewChild } from '@angular/core';
import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, forwardRef, ViewChild } from '@angular/core';
import { ControlValueAccessor, FormBuilder, NG_VALUE_ACCESSOR } from '@angular/forms';
import {
@ -71,6 +71,7 @@ export class GeolocationEditorComponent implements ControlValueAccessor, AfterVi
public isDisabled = false;
constructor(
private readonly changeDetector: ChangeDetectorRef,
private readonly resourceLoader: ResourceLoaderService,
private readonly formBuilder: FormBuilder,
private readonly uiState: UIState
@ -103,6 +104,8 @@ export class GeolocationEditorComponent implements ControlValueAccessor, AfterVi
} else {
this.geolocationForm.enable();
}
this.changeDetector.detectChanges();
}
private setDisabledStateOSM(isDisabled: boolean): void {

Loading…
Cancel
Save