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.
60 lines
1.4 KiB
60 lines
1.4 KiB
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
// tslint:disable:no-shadowed-variable
|
|
|
|
import { CdkDragDrop } from '@angular/cdk/drag-drop';
|
|
import { Component, Input, OnInit } from '@angular/core';
|
|
|
|
import {
|
|
DialogModel,
|
|
fadeAnimation,
|
|
FieldDto,
|
|
fieldTypes,
|
|
PatternsState,
|
|
SchemaDetailsDto,
|
|
SchemasState,
|
|
sorted
|
|
} from '@app/shared';
|
|
|
|
@Component({
|
|
selector: 'sqx-schema-fields',
|
|
styleUrls: ['./schema-fields.component.scss'],
|
|
templateUrl: './schema-fields.component.html',
|
|
animations: [
|
|
fadeAnimation
|
|
]
|
|
})
|
|
export class SchemaFieldsComponent implements OnInit {
|
|
public fieldTypes = fieldTypes;
|
|
|
|
@Input()
|
|
public schema: SchemaDetailsDto;
|
|
|
|
public addFieldDialog = new DialogModel();
|
|
|
|
public trackByFieldFn: (index: number, field: FieldDto) => any;
|
|
|
|
constructor(
|
|
public readonly schemasState: SchemasState,
|
|
public readonly patternsState: PatternsState
|
|
) {
|
|
this.trackByFieldFn = this.trackByField.bind(this);
|
|
}
|
|
|
|
public ngOnInit() {
|
|
this.patternsState.load();
|
|
}
|
|
|
|
public sortFields(event: CdkDragDrop<ReadonlyArray<FieldDto>>) {
|
|
this.schemasState.orderFields(this.schema, sorted(event)).subscribe();
|
|
}
|
|
|
|
public trackByField(index: number, field: FieldDto) {
|
|
return field.fieldId + this.schema.id;
|
|
}
|
|
}
|