mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.1 KiB
72 lines
2.1 KiB
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
|
|
|
import { QueryModel, QuerySorting } from '@app/shared/internal';
|
|
|
|
@Component({
|
|
selector: 'sqx-sorting',
|
|
template: `
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="form-inline">
|
|
<sqx-dropdown [items]="model.fields | sqxKeys" [ngModel]="sorting.path" (ngModelChange)="changePath($event)" [canSearch]="false" separated="true">
|
|
<ng-template let-field="$implicit">
|
|
<div>{{model.fields[field].displayName}}</div>
|
|
|
|
<sqx-form-hint>{{model.fields[field].description}}</sqx-form-hint>
|
|
</ng-template>
|
|
|
|
<ng-template let-field="$implicit">
|
|
{{model.fields[field].displayName}}
|
|
</ng-template>
|
|
</sqx-dropdown>
|
|
|
|
<select class="form-control ml-1" [ngModel]="sorting.order" (ngModelChange)="changeOrder($event)">
|
|
<option>ascending</option>
|
|
<option>descending</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-auto pl-2">
|
|
<button type="button" class="btn btn-text-danger" (click)="remove.emit()">
|
|
<i class="icon-bin2"></i>
|
|
</button>
|
|
</div>
|
|
</div>`,
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
})
|
|
export class SortingComponent {
|
|
@Output()
|
|
public change = new EventEmitter();
|
|
|
|
@Output()
|
|
public remove = new EventEmitter();
|
|
|
|
@Input()
|
|
public model: QueryModel;
|
|
|
|
@Input()
|
|
public sorting: QuerySorting;
|
|
|
|
public changeOrder(order: any) {
|
|
this.sorting.order = order;
|
|
|
|
this.emitChange();
|
|
}
|
|
|
|
public changePath(path: string) {
|
|
this.sorting.path = path;
|
|
|
|
this.emitChange();
|
|
}
|
|
|
|
private emitChange() {
|
|
this.change.emit();
|
|
}
|
|
}
|