diff --git a/frontend/app/features/schemas/declarations.ts b/frontend/app/features/schemas/declarations.ts index cf20ea5a8..a7edb1979 100644 --- a/frontend/app/features/schemas/declarations.ts +++ b/frontend/app/features/schemas/declarations.ts @@ -34,6 +34,7 @@ export * from './pages/schema/field-wizard.component'; export * from './pages/schema/field.component'; export * from './pages/schema/schema-edit-form.component'; export * from './pages/schema/schema-export-form.component'; +export * from './pages/schema/schema-fields.component'; export * from './pages/schema/schema-page.component'; export * from './pages/schema/schema-preview-urls-form.component'; export * from './pages/schema/schema-scripts-form.component'; diff --git a/frontend/app/features/schemas/module.ts b/frontend/app/features/schemas/module.ts index cb332a012..827398242 100644 --- a/frontend/app/features/schemas/module.ts +++ b/frontend/app/features/schemas/module.ts @@ -39,6 +39,7 @@ import { ReferencesValidationComponent, SchemaEditFormComponent, SchemaExportFormComponent, + SchemaFieldsComponent, SchemaFormComponent, SchemaPageComponent, SchemaPreviewUrlsFormComponent, @@ -57,18 +58,64 @@ const routes: Routes = [ children: [ { path: ':schemaName', - component: SchemaPageComponent, canActivate: [SchemaMustExistGuard], + component: SchemaPageComponent, children: [ { - path: 'help', - component: HelpComponent, - data: { - helpPage: '05-integrated/schemas' - } + path: '', + redirectTo: 'fields' + }, + { + path: 'fields', + children: [ + { + path: 'help', + component: HelpComponent, + data: { + helpPage: '05-integrated/schemas' + } + } + ] + }, + { + path: 'scripts', + children: [ + { + path: 'help', + component: HelpComponent, + data: { + helpPage: '05-integrated/scripts' + } + } + ] + }, + { + path: 'json', + children: [ + { + path: 'help', + component: HelpComponent, + data: { + helpPage: '05-integrated/schema-json' + } + } + ] + }, + { + path: 'more', + children: [ + { + path: 'help', + component: HelpComponent, + data: { + helpPage: '05-integrated/preview' + } + } + ] } ] - }] + } + ] } ]; @@ -90,8 +137,8 @@ const routes: Routes = [ DateTimeUIComponent, DateTimeValidationComponent, FieldComponent, - FieldFormComponent, FieldFormCommonComponent, + FieldFormComponent, FieldFormUIComponent, FieldFormValidationComponent, FieldWizardComponent, @@ -105,6 +152,7 @@ const routes: Routes = [ ReferencesValidationComponent, SchemaEditFormComponent, SchemaExportFormComponent, + SchemaFieldsComponent, SchemaFormComponent, SchemaPageComponent, SchemaPreviewUrlsFormComponent, diff --git a/frontend/app/features/schemas/pages/schema/schema-edit-form.component.html b/frontend/app/features/schemas/pages/schema/schema-edit-form.component.html index 7150a23bf..b57572a8d 100644 --- a/frontend/app/features/schemas/pages/schema/schema-edit-form.component.html +++ b/frontend/app/features/schemas/pages/schema/schema-edit-form.component.html @@ -1,46 +1,45 @@ +
- - - Edit Schema - +
+
Common
- +
- +
- +
- + -
+ If the label is defined it will be shown in the UI instead of the schema name. +
+
- +
- +
- + - + Tags to annotate your schema for automation processes.
-
- - - +
+ + \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/schema-edit-form.component.scss b/frontend/app/features/schemas/pages/schema/schema-edit-form.component.scss index eae569083..71c028eac 100644 --- a/frontend/app/features/schemas/pages/schema/schema-edit-form.component.scss +++ b/frontend/app/features/schemas/pages/schema/schema-edit-form.component.scss @@ -1,6 +1,11 @@ @import '_vars'; @import '_mixins'; +.card-header, +.card-footer { + padding: 1.25rem; +} + textarea { resize: none; } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/schema-edit-form.component.ts b/frontend/app/features/schemas/pages/schema/schema-edit-form.component.ts index ffa2d165b..65bdfa976 100644 --- a/frontend/app/features/schemas/pages/schema/schema-edit-form.component.ts +++ b/frontend/app/features/schemas/pages/schema/schema-edit-form.component.ts @@ -5,10 +5,11 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { FormBuilder } from '@angular/forms'; import { + DialogService, EditSchemaForm, SchemaDetailsDto, SchemasState @@ -22,9 +23,6 @@ import { export class SchemaEditFormComponent implements OnInit { public readonly standalone = { standalone: true }; - @Output() - public complete = new EventEmitter(); - @Input() public schema: SchemaDetailsDto; @@ -33,6 +31,7 @@ export class SchemaEditFormComponent implements OnInit { public isEditable = false; constructor( + private readonly dialogs: DialogService, private readonly formBuilder: FormBuilder, private readonly schemasState: SchemasState ) { @@ -45,10 +44,6 @@ export class SchemaEditFormComponent implements OnInit { this.editForm.setEnabled(this.isEditable); } - public emitComplete() { - this.complete.emit(); - } - public saveSchema() { if (!this.isEditable) { return; @@ -59,7 +54,9 @@ export class SchemaEditFormComponent implements OnInit { if (value) { this.schemasState.update(this.schema, value) .subscribe(() => { - this.emitComplete(); + this.dialogs.notifyInfo('Schema saved successfully.'); + + this.editForm.submitCompleted({ noReset: true }); }, error => { this.editForm.submitFailed(error); }); diff --git a/frontend/app/features/schemas/pages/schema/schema-export-form.component.html b/frontend/app/features/schemas/pages/schema/schema-export-form.component.html index 8d05eb575..0284bd357 100644 --- a/frontend/app/features/schemas/pages/schema/schema-export-form.component.html +++ b/frontend/app/features/schemas/pages/schema/schema-export-form.component.html @@ -1,36 +1,31 @@ -
- - - Export Schema - - - - - - - -
-
-
-
- - -
- -
- - -
+ +
+
+
+
+
+
+ + +
+ +
+ +
-
- -
- - +
+ +
+
+
+ +
+ +
\ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/schema-export-form.component.scss b/frontend/app/features/schemas/pages/schema/schema-export-form.component.scss index de36e4af2..559e9a651 100644 --- a/frontend/app/features/schemas/pages/schema/schema-export-form.component.scss +++ b/frontend/app/features/schemas/pages/schema/schema-export-form.component.scss @@ -1,15 +1,24 @@ @import '_vars'; @import '_mixins'; -:host ::ng-deep { - .modal-body { - padding: 0; - } +:host, +.inner-form, +.inner-main { + @include flex-box; + @include flex-grow(1); + @include flex-direction(column); +} - .modal-content { - height: 100%; - } +.inner-header, +.inner-main { + position: relative; +} +.inner-header { + padding: 1rem $panel-padding; +} + +:host ::ng-deep { .editor { @include absolute(0, 0, 0, 0); } diff --git a/frontend/app/features/schemas/pages/schema/schema-export-form.component.ts b/frontend/app/features/schemas/pages/schema/schema-export-form.component.ts index abdfea678..46e95a935 100644 --- a/frontend/app/features/schemas/pages/schema/schema-export-form.component.ts +++ b/frontend/app/features/schemas/pages/schema/schema-export-form.component.ts @@ -5,10 +5,11 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; +import { Component, Input, OnChanges } from '@angular/core'; import { FormBuilder } from '@angular/forms'; import { + DialogService, SchemaDetailsDto, SchemasState, SynchronizeSchemaForm @@ -20,25 +21,31 @@ import { templateUrl: './schema-export-form.component.html' }) export class SchemaExportFormComponent implements OnChanges { - @Output() - public complete = new EventEmitter(); - @Input() public schema: SchemaDetailsDto; public synchronizeForm = new SynchronizeSchemaForm(this.formBuilder); + public isEditable = false; + constructor( + private readonly dialogs: DialogService, private readonly formBuilder: FormBuilder, private readonly schemasState: SchemasState ) { } public ngOnChanges() { + this.isEditable = this.schema.canUpdateScripts; + this.synchronizeForm.form.get('json')!.setValue(this.schema.export()); } - public synchronizeSchema() { + public synchronize() { + if (!this.isEditable) { + return; + } + const value = this.synchronizeForm.submit(); if (value) { @@ -50,14 +57,12 @@ export class SchemaExportFormComponent implements OnChanges { this.schemasState.synchronize(this.schema, request) .subscribe(() => { - this.synchronizeForm.submitCompleted(); + this.dialogs.notifyInfo('Schema synchronized successfully.'); + + this.synchronizeForm.submitCompleted({ noReset: true }); }, error => { this.synchronizeForm.submitFailed(error); }); } } - - public emitComplete() { - this.complete.emit(); - } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/schema-fields.component.html b/frontend/app/features/schemas/pages/schema/schema-fields.component.html new file mode 100644 index 000000000..45e69c554 --- /dev/null +++ b/frontend/app/features/schemas/pages/schema/schema-fields.component.html @@ -0,0 +1,36 @@ +
+
+ No field created yet. + + +
+ + +
+
+ + + +
+
+ + +
+
+ + + + + \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/schema-fields.component.scss b/frontend/app/features/schemas/pages/schema/schema-fields.component.scss new file mode 100644 index 000000000..0a2241aed --- /dev/null +++ b/frontend/app/features/schemas/pages/schema/schema-fields.component.scss @@ -0,0 +1,22 @@ +@import '_vars'; +@import '_mixins'; + +.fields { + padding: $panel-padding; +} + +.field-button { + & { + @include circle(5.25rem); + @include box-shadow(0, 8px, 16px, .3); + @include absolute(auto, 6rem, 1rem, auto); + } + + &-icon { + font-weight: bold; + } + + &-text { + font-size: .9rem; + } +} \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/schema-fields.component.ts b/frontend/app/features/schemas/pages/schema/schema-fields.component.ts new file mode 100644 index 000000000..2d844b9af --- /dev/null +++ b/frontend/app/features/schemas/pages/schema/schema-fields.component.ts @@ -0,0 +1,60 @@ +/* + * 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>) { + this.schemasState.orderFields(this.schema, sorted(event)).subscribe(); + } + + public trackByField(index: number, field: FieldDto) { + return field.fieldId + this.schema.id; + } +} \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/schema-page.component.html b/frontend/app/features/schemas/pages/schema/schema-page.component.html index 898631fda..680bd2ce5 100644 --- a/frontend/app/features/schemas/pages/schema/schema-page.component.html +++ b/frontend/app/features/schemas/pages/schema/schema-page.component.html @@ -1,15 +1,15 @@ - - - {{schema.displayName}} + + + - -
-