Browse Source

Improved modal view.

pull/380/head
Sebastian Stehle 7 years ago
parent
commit
0695b082ef
  1. 2
      src/Squidex/app/features/settings/pages/workflows/workflows-page.component.ts
  2. 3
      src/Squidex/app/framework/angular/forms/dropdown.component.ts
  3. 18
      src/Squidex/app/framework/angular/modals/modal-view.directive.ts

2
src/Squidex/app/features/settings/pages/workflows/workflows-page.component.ts

@ -57,7 +57,7 @@ export class WorkflowsPageComponent implements OnInit {
public addStep() { public addStep() {
let index = this.workflow.steps.length; let index = this.workflow.steps.length;
for (let i = index; ;i++) { for (let i = index; i < index + 100; i++) {
const name = `Step${i}`; const name = `Step${i}`;
if (!this.workflow.getStep(name)) { if (!this.workflow.getStep(name)) {

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

@ -118,6 +118,9 @@ export class DropdownComponent extends StatefulControlComponent<State, any[]> im
if (value !== this.snapshot.selectedItem) { if (value !== this.snapshot.selectedItem) {
selectedIndex = selectedIndex; selectedIndex = selectedIndex;
this.callChange(value);
this.callTouched();
this.next(s => ({ ...s, selectedIndex, selectedItem: value })); this.next(s => ({ ...s, selectedIndex, selectedItem: value }));
} }

18
src/Squidex/app/framework/angular/modals/modal-view.directive.ts

@ -6,7 +6,7 @@
*/ */
import { ChangeDetectorRef, Directive, EmbeddedViewRef, Input, OnChanges, OnDestroy, Renderer2, SimpleChanges, TemplateRef, ViewContainerRef } from '@angular/core'; import { ChangeDetectorRef, Directive, EmbeddedViewRef, Input, OnChanges, OnDestroy, Renderer2, SimpleChanges, TemplateRef, ViewContainerRef } from '@angular/core';
import { Subscription } from 'rxjs'; import { Subscription, timer } from 'rxjs';
import { import {
DialogModel, DialogModel,
@ -22,6 +22,7 @@ import { RootViewComponent } from './root-view.component';
export class ModalViewDirective implements OnChanges, OnDestroy { export class ModalViewDirective implements OnChanges, OnDestroy {
private subscription: Subscription | null = null; private subscription: Subscription | null = null;
private documentClickListener: Function | null = null; private documentClickListener: Function | null = null;
private documentClickTimer: Subscription | null = null;
private renderedView: EmbeddedViewRef<any> | null = null; private renderedView: EmbeddedViewRef<any> | null = null;
@Input('sqxModalView') @Input('sqxModalView')
@ -76,6 +77,8 @@ export class ModalViewDirective implements OnChanges, OnDestroy {
return; return;
} }
this.unsubscribeToClick();
if (isOpen && !this.renderedView) { if (isOpen && !this.renderedView) {
const container = this.getContainer(); const container = this.getContainer();
@ -85,9 +88,9 @@ export class ModalViewDirective implements OnChanges, OnDestroy {
this.renderer.setStyle(this.renderedView.rootNodes[0], 'display', 'block'); this.renderer.setStyle(this.renderedView.rootNodes[0], 'display', 'block');
} }
setTimeout(() => { this.documentClickTimer = timer(1000, 0).subscribe(() => {
this.startListening(); this.startListening();
}, 1000); });
this.changeDetector.detectChanges(); this.changeDetector.detectChanges();
} else if (!isOpen && this.renderedView) { } else if (!isOpen && this.renderedView) {
@ -98,8 +101,6 @@ export class ModalViewDirective implements OnChanges, OnDestroy {
this.renderedView = null; this.renderedView = null;
this.unsubscribeToClick();
this.changeDetector.detectChanges(); this.changeDetector.detectChanges();
} }
} }
@ -113,6 +114,8 @@ export class ModalViewDirective implements OnChanges, OnDestroy {
return; return;
} }
this.unsubscribeToClick();
this.documentClickListener = this.documentClickListener =
this.renderer.listen('document', 'click', (event: MouseEvent) => { this.renderer.listen('document', 'click', (event: MouseEvent) => {
if (!event.target || this.renderedView === null) { if (!event.target || this.renderedView === null) {
@ -156,5 +159,10 @@ export class ModalViewDirective implements OnChanges, OnDestroy {
this.documentClickListener(); this.documentClickListener();
this.documentClickListener = null; this.documentClickListener = null;
} }
if (this.documentClickTimer) {
this.documentClickTimer.unsubscribe();
this.documentClickTimer = null;
}
} }
} }
Loading…
Cancel
Save