-
+
+
-
-
+
+
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Squidex/app/features/schemas/pages/schema/field-wizard.component.scss b/src/Squidex/app/features/schemas/pages/schema/field-wizard.component.scss
index dbbbe06da..9097be216 100644
--- a/src/Squidex/app/features/schemas/pages/schema/field-wizard.component.scss
+++ b/src/Squidex/app/features/schemas/pages/schema/field-wizard.component.scss
@@ -15,6 +15,11 @@ $icon-size: 4.5rem;
margin-bottom: 1rem;
}
+.edit-form {
+ margin: -1rem;
+ margin-bottom: 0;
+}
+
.type {
& {
margin-bottom: .5rem;
diff --git a/src/Squidex/app/features/schemas/pages/schema/field-wizard.component.ts b/src/Squidex/app/features/schemas/pages/schema/field-wizard.component.ts
index 304f072db..1562127b1 100644
--- a/src/Squidex/app/features/schemas/pages/schema/field-wizard.component.ts
+++ b/src/Squidex/app/features/schemas/pages/schema/field-wizard.component.ts
@@ -10,11 +10,16 @@ import { FormBuilder } from '@angular/forms';
import {
AddFieldForm,
+ createProperties,
+ EditFieldForm,
+ FieldDto,
fieldTypes,
+ PatternsState,
RootFieldDto,
SchemaDetailsDto,
SchemasState,
- Types
+ Types,
+ UpdateFieldDto
} from '@app/shared';
@Component({
@@ -36,14 +41,20 @@ export class FieldWizardComponent implements OnInit {
public completed = new EventEmitter();
public fieldTypes = fieldTypes;
+ public field: FieldDto;
public addFieldForm = new AddFieldForm(this.formBuilder);
+ public editForm = new EditFieldForm(this.formBuilder);
+
+ public isEditing = false;
+ public selectedTab = 0;
+
constructor(
private readonly formBuilder: FormBuilder,
- private readonly schemasState: SchemasState
- ) {
- }
+ private readonly schemasState: SchemasState,
+ public readonly patternsState: PatternsState
+ ) {}
public ngOnInit() {
if (this.parent) {
@@ -55,18 +66,24 @@ export class FieldWizardComponent implements OnInit {
this.completed.emit();
}
- public addField(next: boolean) {
+ public addField(addNew: boolean, edit: boolean) {
const value = this.addFieldForm.submit();
if (value) {
this.schemasState.addField(this.schema, value, this.parent)
- .subscribe(() => {
+ .subscribe(dto => {
+ this.field = dto;
+
this.addFieldForm.submitCompleted({ type: fieldTypes[0].type });
- if (next) {
+ if (addNew) {
if (Types.isFunction(this.nameInput.nativeElement.focus)) {
this.nameInput.nativeElement.focus();
}
+ } else if (edit) {
+ this.selectTab(0);
+
+ this.isEditing = true;
} else {
this.complete();
}
@@ -75,5 +92,29 @@ export class FieldWizardComponent implements OnInit {
});
}
}
-}
+ public selectTab(tab: number) {
+ this.selectedTab = tab;
+ }
+
+ public save(addNew: boolean) {
+ const value = this.editForm.submit();
+
+ if (value) {
+ const properties = createProperties(this.field.properties['fieldType'], value);
+
+ this.schemasState.updateField(this.schema, this.field as RootFieldDto, new UpdateFieldDto(properties))
+ .subscribe(() => {
+ this.editForm.submitCompleted();
+
+ if (addNew) {
+ this.isEditing = false;
+ } else {
+ this.complete();
+ }
+ }, error => {
+ this.editForm.submitFailed(error);
+ });
+ }
+ }
+}
diff --git a/src/Squidex/app/features/schemas/pages/schema/field.component.ts b/src/Squidex/app/features/schemas/pages/schema/field.component.ts
index 4d211ee35..00c4421f9 100644
--- a/src/Squidex/app/features/schemas/pages/schema/field.component.ts
+++ b/src/Squidex/app/features/schemas/pages/schema/field.component.ts
@@ -68,11 +68,13 @@ export class FieldComponent implements OnChanges {
this.editForm.form.disable();
}
}
+ }
- if (changes['schema']) {
- this.isEditing = false;
+ public toggleEditing() {
+ this.isEditing = !this.isEditing;
- this.selectedTab = 0;
+ if (this.isEditing) {
+ this.editForm.load(this.field.properties);
}
}
@@ -80,10 +82,6 @@ export class FieldComponent implements OnChanges {
this.selectedTab = tab;
}
- public toggleEditing() {
- this.isEditing = !this.isEditing;
- }
-
public cancel() {
this.isEditing = false;
diff --git a/src/Squidex/app/features/schemas/pages/schema/forms/field-form-common.component.ts b/src/Squidex/app/features/schemas/pages/schema/forms/field-form-common.component.ts
index 3598c6d83..51d55dc83 100644
--- a/src/Squidex/app/features/schemas/pages/schema/forms/field-form-common.component.ts
+++ b/src/Squidex/app/features/schemas/pages/schema/forms/field-form-common.component.ts
@@ -5,8 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
-import { Component, Input } from '@angular/core';
-import { FormGroup } from '@angular/forms';
+import { Component, Input, OnChanges } from '@angular/core';
+import { FormControl, FormGroup } from '@angular/forms';
import { FieldDto } from '@app/shared';
@@ -15,7 +15,7 @@ import { FieldDto } from '@app/shared';
styleUrls: ['field-form-common.component.scss'],
templateUrl: 'field-form-common.component.html'
})
-export class FieldFormCommonComponent {
+export class FieldFormCommonComponent implements OnChanges {
@Input()
public editForm: FormGroup;
@@ -27,4 +27,24 @@ export class FieldFormCommonComponent {
@Input()
public field: FieldDto;
+
+ public ngOnChanges() {
+ this.editForm.setControl('isRequired',
+ new FormControl(this.field.properties.isRequired));
+
+ this.editForm.setControl('isListField',
+ new FormControl(this.field.properties.isListField));
+
+ this.editForm.setControl('editorUrl',
+ new FormControl(this.field.properties.editorUrl));
+
+ this.editForm.setControl('hints',
+ new FormControl(this.field.properties.hints));
+
+ this.editForm.setControl('placeholder',
+ new FormControl(this.field.properties.placeholder));
+
+ this.editForm.setControl('label',
+ new FormControl(this.field.properties.label));
+ }
}
\ No newline at end of file