diff --git a/src/Squidex/app/features/rules/pages/rules/rule-wizard.component.html b/src/Squidex/app/features/rules/pages/rules/rule-wizard.component.html index fa6797778..7514457ea 100644 --- a/src/Squidex/app/features/rules/pages/rules/rule-wizard.component.html +++ b/src/Squidex/app/features/rules/pages/rules/rule-wizard.component.html @@ -63,7 +63,7 @@
-

{{ruleActions[actionType].display}}

+

{{ruleActions[actionType].display}}

diff --git a/src/Squidex/app/features/schemas/declarations.ts b/src/Squidex/app/features/schemas/declarations.ts index d88a5eee1..7082aa204 100644 --- a/src/Squidex/app/features/schemas/declarations.ts +++ b/src/Squidex/app/features/schemas/declarations.ts @@ -32,6 +32,7 @@ export * from './pages/schema/field.component'; export * from './pages/schema/field-wizard.component'; export * from './pages/schema/schema-edit-form.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'; export * from './pages/schemas/schema-form.component'; diff --git a/src/Squidex/app/features/schemas/module.ts b/src/Squidex/app/features/schemas/module.ts index a6ede84cb..0db0eef25 100644 --- a/src/Squidex/app/features/schemas/module.ts +++ b/src/Squidex/app/features/schemas/module.ts @@ -39,6 +39,7 @@ import { SchemaEditFormComponent, SchemaFormComponent, SchemaPageComponent, + SchemaPreviewUrlsFormComponent, SchemaScriptsFormComponent, SchemasPageComponent, StringUIComponent, @@ -102,6 +103,7 @@ const routes: Routes = [ SchemaEditFormComponent, SchemaFormComponent, SchemaPageComponent, + SchemaPreviewUrlsFormComponent, SchemaScriptsFormComponent, SchemasPageComponent, StringUIComponent, diff --git a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html index 20a20c689..bf516c461 100644 --- a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html +++ b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html @@ -25,12 +25,19 @@ -
+
@@ -19,7 +19,7 @@
-
+
@@ -32,7 +32,7 @@
-
+
diff --git a/src/Squidex/app/shared/state/schemas.forms.ts b/src/Squidex/app/shared/state/schemas.forms.ts index e3866789c..4cb084851 100644 --- a/src/Squidex/app/shared/state/schemas.forms.ts +++ b/src/Squidex/app/shared/state/schemas.forms.ts @@ -5,10 +5,14 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { map, startWith } from 'rxjs/operators'; -import { Form, ValidatorsEx } from '@app/framework'; +import { + Form, + Types, + ValidatorsEx +} from '@app/framework'; import { createProperties } from './../services/schemas.types'; @@ -42,6 +46,93 @@ export class CreateSchemaForm extends Form { } } +export class AddPreviewUrlForm extends Form { + constructor(formBuilder: FormBuilder) { + super(formBuilder.group({ + name: ['', + [ + Validators.required + ] + ], + url: ['', + [ + Validators.required + ] + ] + })); + } +} + +export class ConfigurePreviewUrlsForm extends Form { + constructor( + private readonly formBuilder: FormBuilder + ) { + super(formBuilder.array([])); + } + + public add(value: any) { + this.form.push( + this.formBuilder.group({ + name: [value.name, + [ + Validators.required + ] + ], + url: [value.url, + [ + Validators.required + ] + ] + })); + } + + public remove(index: number) { + this.form.removeAt(index); + } + + public load(value?: any) { + if (Types.isObject(value)) { + const length = Object.keys(value).length; + + while (this.form.controls.length < length) { + this.add({}); + } + + while (this.form.controls.length > length) { + this.remove(this.form.controls.length - 1); + } + + const array: any[] = []; + + for (let key in value) { + if (value.hasOwnProperty(key)) { + array.push({ name: key, url: value[key] }); + } + } + + value = array; + } + + super.load(value); + } + + public submit() { + let result = super.submit(); + + if (result) { + const hash: { [name: string]: string } = {}; + + for (let item of result) { + hash[item.name] = item.url; + } + + result = hash; + } + + return result; + } +} + export class EditScriptsForm extends Form { constructor(formBuilder: FormBuilder) { super(formBuilder.group({