Browse Source

Bugfix for change detection and schema fields.

pull/333/head
Sebastian Stehle 7 years ago
parent
commit
8702829495
  1. 10
      src/Squidex/app/features/content/shared/assets-editor.component.ts
  2. 14
      src/Squidex/app/features/content/shared/references-editor.component.ts
  3. 22
      src/Squidex/app/features/schemas/pages/schema/field.component.ts
  4. 2
      src/Squidex/app/framework/angular/forms/control-errors.component.ts
  5. 4
      src/Squidex/app/framework/angular/forms/date-time-editor.component.ts
  6. 4
      src/Squidex/app/framework/angular/forms/dropdown.component.ts
  7. 4
      src/Squidex/app/framework/angular/forms/slider.component.ts
  8. 2
      src/Squidex/app/framework/angular/forms/tag-editor.component.ts
  9. 4
      src/Squidex/app/framework/angular/forms/toggle.component.ts
  10. 8
      src/Squidex/app/framework/angular/modals/dialog-renderer.component.ts
  11. 2
      src/Squidex/app/framework/angular/modals/modal-dialog.component.ts
  12. 2
      src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.ts
  13. 2
      src/Squidex/app/framework/angular/modals/tooltip.component.ts
  14. 4
      src/Squidex/app/shared/components/asset.component.ts
  15. 2
      src/Squidex/app/shared/components/geolocation-editor.component.ts
  16. 2
      src/Squidex/app/shell/pages/internal/profile-menu.component.ts

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

@ -65,24 +65,24 @@ export class AssetsEditorComponent implements ControlValueAccessor {
this.updateValue(); this.updateValue();
} }
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}, () => { }, () => {
this.oldAssets = ImmutableArray.empty(); this.oldAssets = ImmutableArray.empty();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}); });
} }
} else { } else {
this.oldAssets = ImmutableArray.empty(); this.oldAssets = ImmutableArray.empty();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
} }
public setDisabledState(isDisabled: boolean): void { public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled; this.isDisabled = isDisabled;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public registerOnChange(fn: any) { public registerOnChange(fn: any) {
@ -140,7 +140,7 @@ export class AssetsEditorComponent implements ControlValueAccessor {
this.callTouched(); this.callTouched();
this.callChange(ids); this.callChange(ids);
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public sort(assets: AssetDto[]) { public sort(assets: AssetDto[]) {

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

@ -74,11 +74,11 @@ export class ReferencesEditorComponent implements ControlValueAccessor, OnInit {
.subscribe(dto => { .subscribe(dto => {
this.schema = dto; this.schema = dto;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}, () => { }, () => {
this.isInvalidSchema = true; this.isInvalidSchema = true;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}); });
} }
@ -95,24 +95,24 @@ export class ReferencesEditorComponent implements ControlValueAccessor, OnInit {
this.updateValue(); this.updateValue();
} }
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}, () => { }, () => {
this.contentItems = ImmutableArray.empty(); this.contentItems = ImmutableArray.empty();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}); });
} }
} else { } else {
this.contentItems = ImmutableArray.empty(); this.contentItems = ImmutableArray.empty();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
} }
public setDisabledState(isDisabled: boolean): void { public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled; this.isDisabled = isDisabled;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public registerOnChange(fn: any) { public registerOnChange(fn: any) {
@ -161,6 +161,6 @@ export class ReferencesEditorComponent implements ControlValueAccessor, OnInit {
this.callTouched(); this.callTouched();
this.callChange(ids); this.callChange(ids);
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
} }

22
src/Squidex/app/features/schemas/pages/schema/field.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { onErrorResumeNext } from 'rxjs/operators'; import { onErrorResumeNext } from 'rxjs/operators';
@ -32,7 +32,7 @@ import {
fadeAnimation fadeAnimation
] ]
}) })
export class FieldComponent implements OnInit { export class FieldComponent implements OnChanges {
@Input() @Input()
public field: NestedFieldDto | RootFieldDto; public field: NestedFieldDto | RootFieldDto;
@ -50,7 +50,7 @@ export class FieldComponent implements OnInit {
public isEditing = false; public isEditing = false;
public selectedTab = 0; public selectedTab = 0;
public editForm: EditFieldForm; public editForm = new EditFieldForm(this.formBuilder);
public addFieldDialog = new DialogModel(); public addFieldDialog = new DialogModel();
@ -60,8 +60,8 @@ export class FieldComponent implements OnInit {
) { ) {
} }
public ngOnInit() { public ngOnChanges(changes: SimpleChanges) {
this.editForm = new EditFieldForm(this.formBuilder); if (changes['field']) {
this.editForm.load(this.field.properties); this.editForm.load(this.field.properties);
if (this.field.isLocked) { if (this.field.isLocked) {
@ -69,16 +69,24 @@ export class FieldComponent implements OnInit {
} }
} }
public toggleEditing() { if (changes['schema']) {
this.isEditing = !this.isEditing; this.isEditing = false;
this.selectedTab = 0;
}
} }
public selectTab(tab: number) { public selectTab(tab: number) {
this.selectedTab = tab; this.selectedTab = tab;
} }
public toggleEditing() {
this.isEditing = !this.isEditing;
}
public cancel() { public cancel() {
this.isEditing = false; this.isEditing = false;
this.editForm.load(this.field); this.editForm.load(this.field);
} }

2
src/Squidex/app/framework/angular/forms/control-errors.component.ts

@ -152,6 +152,6 @@ export class ControlErrorsComponent implements OnChanges, OnDestroy {
this.errorMessages = errors; this.errorMessages = errors;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
} }

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

@ -122,7 +122,7 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy,
this.timeControl.enable({ emitEvent: false }); this.timeControl.enable({ emitEvent: false });
} }
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public registerOnChange(fn: any) { public registerOnChange(fn: any) {
@ -144,7 +144,7 @@ export class DateTimeEditorComponent implements ControlValueAccessor, OnDestroy,
this.updateValue(); this.updateValue();
this.touched(); this.touched();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
}); });

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

@ -68,13 +68,13 @@ export class DropdownComponent implements AfterContentInit, ControlValueAccessor
public writeValue(obj: any) { public writeValue(obj: any) {
this.selectIndex(this.items && obj ? this.items.indexOf(obj) : 0); this.selectIndex(this.items && obj ? this.items.indexOf(obj) : 0);
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public setDisabledState(isDisabled: boolean): void { public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled; this.isDisabled = isDisabled;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public registerOnChange(fn: any) { public registerOnChange(fn: any) {

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

@ -59,13 +59,13 @@ export class SliderComponent implements ControlValueAccessor {
this.updateThumbPosition(); this.updateThumbPosition();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public setDisabledState(isDisabled: boolean): void { public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled; this.isDisabled = isDisabled;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public registerOnChange(fn: any) { public registerOnChange(fn: any) {

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

@ -185,7 +185,7 @@ export class TagEditorComponent implements AfterViewInit, ControlValueAccessor,
this.items = []; this.items = [];
} }
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public setDisabledState(isDisabled: boolean): void { public setDisabledState(isDisabled: boolean): void {

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

@ -36,13 +36,13 @@ export class ToggleComponent implements ControlValueAccessor {
public writeValue(obj: any) { public writeValue(obj: any) {
this.isChecked = Types.isBoolean(obj) ? obj : null; this.isChecked = Types.isBoolean(obj) ? obj : null;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public setDisabledState(isDisabled: boolean): void { public setDisabledState(isDisabled: boolean): void {
this.isDisabled = isDisabled; this.isDisabled = isDisabled;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
public registerOnChange(fn: any) { public registerOnChange(fn: any) {

8
src/Squidex/app/framework/angular/modals/dialog-renderer.component.ts

@ -56,7 +56,7 @@ export class DialogRendererComponent implements OnDestroy, OnInit {
if (!isOpen) { if (!isOpen) {
this.cancel(); this.cancel();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
}); });
@ -70,7 +70,7 @@ export class DialogRendererComponent implements OnDestroy, OnInit {
}, notification.displayTime); }, notification.displayTime);
} }
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}); });
this.dialogsSubscription = this.dialogsSubscription =
@ -81,7 +81,7 @@ export class DialogRendererComponent implements OnDestroy, OnInit {
this.dialogRequest = request; this.dialogRequest = request;
this.dialogView.show(); this.dialogView.show();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}); });
} }
@ -107,7 +107,7 @@ export class DialogRendererComponent implements OnDestroy, OnInit {
if (index >= 0) { if (index >= 0) {
this.notifications.splice(index, 1); this.notifications.splice(index, 1);
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
} }
} }

2
src/Squidex/app/framework/angular/modals/modal-dialog.component.ts

@ -64,6 +64,6 @@ export class ModalDialogComponent implements AfterViewInit {
this.hasTabs = this.tabsElement.nativeElement.children.length > 0; this.hasTabs = this.tabsElement.nativeElement.children.length > 0;
this.hasFooter = this.footerElement.nativeElement.children.length > 0; this.hasFooter = this.footerElement.nativeElement.children.length > 0;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
} }

2
src/Squidex/app/framework/angular/modals/onboarding-tooltip.component.ts

@ -75,7 +75,7 @@ export class OnboardingTooltipComponent implements OnDestroy, OnInit {
if (this.isSameOrParent(fromPoint)) { if (this.isSameOrParent(fromPoint)) {
this.tooltipModal.show(); this.tooltipModal.show();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
this.closeTimer = setTimeout(() => { this.closeTimer = setTimeout(() => {
this.hideThis(); this.hideThis();

2
src/Squidex/app/framework/angular/modals/tooltip.component.ts

@ -54,7 +54,7 @@ export class TooltipComponent implements OnDestroy, OnInit {
this.renderer.listen(this.target, 'mouseenter', () => { this.renderer.listen(this.target, 'mouseenter', () => {
this.modal.show(); this.modal.show();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}); });
this.targetMouseLeaveListener = this.targetMouseLeaveListener =

4
src/Squidex/app/shared/components/asset.component.ts

@ -213,7 +213,7 @@ export class AssetComponent implements OnDestroy, OnInit {
private setProgress(progress: number) { private setProgress(progress: number) {
this.progress = progress; this.progress = progress;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
private updateAsset(asset: AssetDto, emitEvent: boolean) { private updateAsset(asset: AssetDto, emitEvent: boolean) {
@ -228,6 +228,6 @@ export class AssetComponent implements OnDestroy, OnInit {
this.renameCancel(); this.renameCancel();
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
} }

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

@ -105,7 +105,7 @@ export class GeolocationEditorComponent implements ControlValueAccessor, AfterVi
this.geolocationForm.enable(); this.geolocationForm.enable();
} }
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
} }
private setDisabledStateOSM(isDisabled: boolean): void { private setDisabledStateOSM(isDisabled: boolean): void {

2
src/Squidex/app/shell/pages/internal/profile-menu.component.ts

@ -57,7 +57,7 @@ export class ProfileMenuComponent implements OnDestroy, OnInit {
this.isAdmin = user!.isAdmin; this.isAdmin = user!.isAdmin;
this.changeDetector.detectChanges(); this.changeDetector.markForCheck();
}); });
} }

Loading…
Cancel
Save