Browse Source

Improvements to tag editor.

pull/382/head
Sebastian Stehle 7 years ago
parent
commit
22df4bda42
  1. 20
      src/Squidex/app/features/settings/pages/workflows/workflow.component.html
  2. 11
      src/Squidex/app/features/settings/pages/workflows/workflow.component.scss
  3. 4
      src/Squidex/app/framework/angular/forms/tag-editor.component.html
  4. 13
      src/Squidex/app/framework/angular/forms/tag-editor.component.scss
  5. 5
      src/Squidex/app/framework/angular/forms/tag-editor.component.ts
  6. 69
      src/Squidex/app/framework/angular/modals/modal-view.directive.ts
  7. 2
      src/Squidex/app/shared/components/asset.component.html

20
src/Squidex/app/features/settings/pages/workflows/workflow.component.html

@ -1,12 +1,21 @@
<div class="table-items-row table-items-row-expandable workflow"> <div class="table-items-row table-items-row-expandable workflow">
<div class="table-items-row-summary" (click)="toggleEditing()"> <div class="table-items-row-summary">
<div class="row no-gutters"> <div class="row no-gutters">
<div class="col"> <div class="col col-name">
{{workflow.displayName}} <span class="workflow-name">{{workflow.displayName}}</span>
</div>
<div class="col col-tags">
<sqx-tag-editor [converter]="schemasSource" [ngModel]="workflow.schemaIds"
placeholder=""
styleGray="true"
styleBlank="true"
singleLine="true"
disabled="true">
</sqx-tag-editor>
</div> </div>
<div class="col-options"> <div class="col-options">
<div class="float-right"> <div class="float-right">
<button type="button" class="btn btn-secondary table-items-edit-button mr-1" [class.active]="isEditing" (click)="toggleEditing()" sqxStopClick> <button type="button" class="btn btn-secondary table-items-edit-button mr-1" [class.active]="isEditing" (click)="toggleEditing()">
<i class="icon-settings"></i> <i class="icon-settings"></i>
</button> </button>
@ -14,8 +23,7 @@
[disabled]="!workflow.canDelete" [disabled]="!workflow.canDelete"
(sqxConfirmClick)="remove()" (sqxConfirmClick)="remove()"
confirmTitle="Remove workflow" confirmTitle="Remove workflow"
confirmText="Do you really want to remove the workflow?" confirmText="Do you really want to remove the workflow?">
sqxStopClick>
<i class="icon-bin2"></i> <i class="icon-bin2"></i>
</button> </button>
</div> </div>

11
src/Squidex/app/features/settings/pages/workflows/workflow.component.scss

@ -7,11 +7,22 @@
} }
} }
.workflow {
&-name {
@include truncate;
}
}
.col-form-label { .col-form-label {
min-width: 4rem; min-width: 4rem;
max-width: 4rem; max-width: 4rem;
} }
.col-tags {
padding: .6rem 1rem;
padding-bottom: 0;
}
.form-group { .form-group {
margin-bottom: 2rem; margin-bottom: 2rem;
margin-left: 2rem; margin-left: 2rem;

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

@ -1,10 +1,10 @@
<ng-container> <ng-container>
<div class="form-control {{class}}" #form (click)="input.focus()" <div class="form-control" [class.blank]="styleBlank" [class.gray]="styleGray" #form (click)="input.focus()"
[class.single-line]="singleLine" [class.single-line]="singleLine"
[class.focus]="snapshot.hasFocus" [class.focus]="snapshot.hasFocus"
[class.disabled]="addInput.disabled"> [class.disabled]="addInput.disabled">
<span class="item" *ngFor="let item of snapshot.items; let i = index" [class.disabled]="addInput.disabled"> <span class="item" *ngFor="let item of snapshot.items; let i = index" [class.disabled]="addInput.disabled">
{{item}} <i class="icon-close" (click)="remove(i)"></i> {{item}} <i class="icon-close" *ngIf="!addInput.disabled" (click)="remove(i)"></i>
</span> </span>
<input type="text" class="blank" #input <input type="text" class="blank" #input

13
src/Squidex/app/framework/angular/forms/tag-editor.component.scss

@ -58,11 +58,24 @@ div {
outline: none; outline: none;
} }
&.disabled,
&:disabled {
background: transparent;
}
&:hover { &:hover {
background: transparent; background: transparent;
} }
} }
.gray {
.item {
background: $color-border;
color: $color-text;
cursor: default;
}
}
.icon-close { .icon-close {
font-size: .6rem; font-size: .6rem;
} }

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

@ -163,7 +163,10 @@ export class TagEditorComponent extends StatefulControlComponent<State, any[]> i
public singleLine = false; public singleLine = false;
@Input() @Input()
public class: string; public styleBlank = false;
@Input()
public styleGray = false;
@Input() @Input()
public placeholder = ', to add tag'; public placeholder = ', to add tag';

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

@ -21,9 +21,7 @@ import { RootViewComponent } from './root-view.component';
}) })
export class ModalViewDirective implements OnChanges, OnDestroy { export class ModalViewDirective implements OnChanges, OnDestroy {
private modalSubscription: Subscription | null = null; private modalSubscription: Subscription | null = null;
private documentClickListener: Function | null = null;
private renderedView: EmbeddedViewRef<any> | null = null; private renderedView: EmbeddedViewRef<any> | null = null;
private static clickCounter = 0;
@Input('sqxModalView') @Input('sqxModalView')
public modalView: DialogModel | ModalModel | any; public modalView: DialogModel | ModalModel | any;
@ -44,13 +42,6 @@ export class ModalViewDirective implements OnChanges, OnDestroy {
private readonly templateRef: TemplateRef<any>, private readonly templateRef: TemplateRef<any>,
private readonly viewContainer: ViewContainerRef private readonly viewContainer: ViewContainerRef
) { ) {
if (ModalViewDirective.clickCounter === 0) {
this.renderer.listen('document', 'click', () => {
ModalViewDirective.clickCounter++;
});
ModalViewDirective.clickCounter = 1;
}
} }
public ngOnDestroy() { public ngOnDestroy() {
@ -95,7 +86,7 @@ export class ModalViewDirective implements OnChanges, OnDestroy {
this.renderer.setStyle(this.renderedView.rootNodes[0], 'display', 'block'); this.renderer.setStyle(this.renderedView.rootNodes[0], 'display', 'block');
} }
this.startListening(ModalViewDirective.clickCounter + 1); this.startListening();
this.changeDetector.detectChanges(); this.changeDetector.detectChanges();
} else if (!isOpen && this.renderedView) { } else if (!isOpen && this.renderedView) {
@ -114,40 +105,39 @@ export class ModalViewDirective implements OnChanges, OnDestroy {
return this.placeOnRoot ? this.rootView.viewContainer : this.viewContainer; return this.placeOnRoot ? this.rootView.viewContainer : this.viewContainer;
} }
private startListening(clickCounter: number) { private startListening() {
if (!this.closeAuto) { if (this.closeAuto) {
document.addEventListener('click', this.documentClickListener, true);
}
}
private documentClickListener = (event: MouseEvent) => {
if (!event.target || this.renderedView === null) {
return; return;
} }
this.documentClickListener = if (this.renderedView.rootNodes.length === 0) {
this.renderer.listen('document', 'click', (event: MouseEvent) => { return;
if (!event.target || this.renderedView === null || ModalViewDirective.clickCounter === clickCounter) { }
return;
}
if (this.renderedView.rootNodes.length === 0) { if (this.closeAlways) {
return; this.modalView.hide();
} } else {
try {
const rootNode = this.renderedView.rootNodes[0];
const rootBounds = rootNode.getBoundingClientRect();
if (rootBounds.width > 0 && rootBounds.height > 0) {
const clickedInside = rootNode.contains(event.target);
if (this.closeAlways) { if (!clickedInside && this.modalView) {
this.modalView.hide(); this.modalView.hide();
} else {
try {
const rootNode = this.renderedView.rootNodes[0];
const rootBounds = rootNode.getBoundingClientRect();
if (rootBounds.width > 0 && rootBounds.height > 0) {
const clickedInside = rootNode.contains(event.target);
if (!clickedInside && this.modalView) {
this.modalView.hide();
}
}
} catch (ex) {
return;
} }
} }
}); } catch (ex) {
return;
}
}
} }
private unsubscribeToModal() { private unsubscribeToModal() {
@ -158,9 +148,6 @@ export class ModalViewDirective implements OnChanges, OnDestroy {
} }
private unsubscribeToClick() { private unsubscribeToClick() {
if (this.documentClickListener) { document.removeEventListener('click', this.documentClickListener);
this.documentClickListener();
this.documentClickListener = null;
}
} }
} }

2
src/Squidex/app/shared/components/asset.component.html

@ -69,7 +69,7 @@
</div> </div>
</div> </div>
<div class="file-tags tags"> <div class="file-tags tags">
<sqx-tag-editor [disabled]="true" [ngModel]="asset.tags" class="blank" placeholder="+Tag"></sqx-tag-editor> <sqx-tag-editor [ngModel]="asset.tags" disabled="true" styleBlank="true" placeholder="+Tag"></sqx-tag-editor>
</div> </div>
<div class="file-info"> <div class="file-info">
<ng-container *ngIf="asset.pixelWidth">{{asset.pixelWidth}}x{{asset.pixelHeight}}px, </ng-container> {{asset.fileSize | sqxFileSize}} <ng-container *ngIf="asset.pixelWidth">{{asset.pixelWidth}}x{{asset.pixelHeight}}px, </ng-container> {{asset.fileSize | sqxFileSize}}

Loading…
Cancel
Save