Browse Source

Ugly modal fix.

pull/387/head
Sebastian Stehle 7 years ago
parent
commit
56d4fdd9d5
  1. 6
      src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.html
  2. 2
      src/Squidex/app/framework/angular/forms/autocomplete.component.html
  3. 9
      src/Squidex/app/framework/angular/forms/autocomplete.component.ts
  4. 4
      src/Squidex/app/framework/angular/forms/color-picker.component.html
  5. 2
      src/Squidex/app/framework/angular/forms/tag-editor.component.html
  6. 28
      src/Squidex/app/framework/angular/modals/modal.directive.ts

6
src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.html

@ -42,11 +42,11 @@
autocomplete="off" autocomplete="off"
autocorrect="off" autocorrect="off"
autocapitalize="off" autocapitalize="off"
(focus)="patternsModal.show()" (blur)="patternsModal.hide()" /> (focus)="patternsModal.show()" />
<ng-container *ngIf="patterns.length > 0 && (showPatternSuggestions | async)"> <ng-container *ngIf="patterns.length > 0 && (showPatternSuggestions | async)">
<ng-container *sqxModal="patternsModal" position="bottom-left"> <ng-container *sqxModal="patternsModal">
<div class="control-dropdown" [sqxAnchoredTo]="inputPattern" @fade> <div class="control-dropdown" [sqxAnchoredTo]="inputPattern" position="bottom-left" @fade>
<h4>Suggestions</h4> <h4>Suggestions</h4>
<div *ngFor="let pattern of patterns" class="control-dropdown-item control-dropdown-item-selectable" (mousedown)="setPattern(pattern)"> <div *ngFor="let pattern of patterns" class="control-dropdown-item control-dropdown-item-selectable" (mousedown)="setPattern(pattern)">

2
src/Squidex/app/framework/angular/forms/autocomplete.component.html

@ -6,7 +6,7 @@
autocapitalize="off"> autocapitalize="off">
<ng-container *sqxModal="snapshot.suggestedItems.length > 0" position="bottom-left"> <ng-container *sqxModal="snapshot.suggestedItems.length > 0" position="bottom-left">
<div class="control-dropdown" [sqxAnchoredTo]="input" #container> <div class="control-dropdown" [sqxAnchoredTo]="input" positition="bottom-left" #container @fade>
<div *ngFor="let item of snapshot.suggestedItems; let i = index" class="control-dropdown-item control-dropdown-item-selectable" <div *ngFor="let item of snapshot.suggestedItems; let i = index" class="control-dropdown-item control-dropdown-item-selectable"
[class.active]="i === snapshot.suggestedIndex" [class.active]="i === snapshot.suggestedIndex"
[container]="container" [container]="container"

9
src/Squidex/app/framework/angular/forms/autocomplete.component.ts

@ -10,7 +10,11 @@ import { FormControl, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { catchError, debounceTime, distinctUntilChanged, filter, map, switchMap, tap } from 'rxjs/operators'; import { catchError, debounceTime, distinctUntilChanged, filter, map, switchMap, tap } from 'rxjs/operators';
import { Keys, StatefulControlComponent } from '@app/framework/internal'; import {
fadeAnimation,
Keys,
StatefulControlComponent
} from '@app/framework/internal';
export interface AutocompleteSource { export interface AutocompleteSource {
find(query: string): Observable<any[]>; find(query: string): Observable<any[]>;
@ -32,6 +36,9 @@ interface State {
styleUrls: ['./autocomplete.component.scss'], styleUrls: ['./autocomplete.component.scss'],
templateUrl: './autocomplete.component.html', templateUrl: './autocomplete.component.html',
providers: [SQX_AUTOCOMPLETE_CONTROL_VALUE_ACCESSOR], providers: [SQX_AUTOCOMPLETE_CONTROL_VALUE_ACCESSOR],
animations: [
fadeAnimation
],
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class AutocompleteComponent extends StatefulControlComponent<State, any[]> implements OnInit { export class AutocompleteComponent extends StatefulControlComponent<State, any[]> implements OnInit {

4
src/Squidex/app/framework/angular/forms/color-picker.component.html

@ -16,8 +16,8 @@
<ng-container *sqxModal="modal"> <ng-container *sqxModal="modal">
<div [sqxAnchoredTo]="input" position="bottom-left" <div [sqxAnchoredTo]="input" position="bottom-left"
[style.height]="'228px'" [style.height]="'280px'"
[style.width]="'130px'"> [style.width]="'230px'">
<div [style.background]="snapshot.value" <div [style.background]="snapshot.value"
[cpToggle]="true" [cpToggle]="true"
[cpDialogDisplay]="'inline'" [cpDialogDisplay]="'inline'"

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

@ -23,7 +23,7 @@
</div> </div>
<ng-container *sqxModal="snapshot.suggestedItems.length > 0"> <ng-container *sqxModal="snapshot.suggestedItems.length > 0">
<div class="control-dropdown" [sqxAnchoredTo]="form" #container @fade> <div class="control-dropdown" [sqxAnchoredTo]="form" position="bottom-left" #container @fade>
<div *ngFor="let item of snapshot.suggestedItems; let i = index" class="control-dropdown-item control-dropdown-item-selectable" <div *ngFor="let item of snapshot.suggestedItems; let i = index" class="control-dropdown-item control-dropdown-item-selectable"
[class.active]="i === snapshot.suggestedIndex" [class.active]="i === snapshot.suggestedIndex"
[container]="container" [container]="container"

28
src/Squidex/app/framework/angular/modals/modal.directive.ts

@ -60,7 +60,7 @@ export class ModalDirective implements OnDestroy {
} }
public ngOnDestroy() { public ngOnDestroy() {
hideModal(this.currentModel); this.hideModal(this.currentModel);
this.eventsView.unsubscribeAll(); this.eventsView.unsubscribeAll();
this.eventsModel.unsubscribeAll(); this.eventsModel.unsubscribeAll();
@ -122,11 +122,13 @@ export class ModalDirective implements OnDestroy {
private subscribeToView() { private subscribeToView() {
if (this.closeAuto) { if (this.closeAuto) {
document.addEventListener('click', this.documentClickListener, true); this.eventsView.own(timer(500).subscribe(() => {
document.addEventListener('click', this.documentClickListener, true);
this.eventsView.own(() => { this.eventsView.own(() => {
document.removeEventListener('click', this.documentClickListener); document.removeEventListener('click', this.documentClickListener, true);
}); });
}));
} }
if (this.closeAlways && this.renderRoots) { if (this.closeAlways && this.renderRoots) {
@ -138,7 +140,7 @@ export class ModalDirective implements OnDestroy {
private elementListener = (event: MouseEvent) => { private elementListener = (event: MouseEvent) => {
if (this.isClickedInside(event)) { if (this.isClickedInside(event)) {
hideModal(this.currentModel); this.hideModal(this.currentModel);
} }
} }
@ -146,8 +148,8 @@ export class ModalDirective implements OnDestroy {
const model = this.currentModel; const model = this.currentModel;
if (!this.isClickedInside(event)) { if (!this.isClickedInside(event)) {
this.eventsView.own(timer(0, 100).subscribe(() => { this.eventsView.own(timer(100).subscribe(() => {
hideModal(model); this.hideModal(model);
})); }));
} }
} }
@ -169,11 +171,13 @@ export class ModalDirective implements OnDestroy {
return false; return false;
} }
} }
}
function hideModal(model: Model) { private hideModal(model: Model) {
if (model && isModalModel(model)) { if (model && isModalModel(model)) {
model.hide(); model.hide();
this.eventsView.unsubscribeAll();
}
} }
} }

Loading…
Cancel
Save