|
|
@ -14,11 +14,13 @@ import { |
|
|
value$ |
|
|
value$ |
|
|
} from '@app/framework'; |
|
|
} from '@app/framework'; |
|
|
|
|
|
|
|
|
|
|
|
import { AddFieldDto } from '../services/schemas.service'; |
|
|
|
|
|
|
|
|
import { createProperties } from './../services/schemas.types'; |
|
|
import { createProperties } from './../services/schemas.types'; |
|
|
|
|
|
|
|
|
const FALLBACK_NAME = 'my-schema'; |
|
|
const FALLBACK_NAME = 'my-schema'; |
|
|
|
|
|
|
|
|
export class CreateCategoryForm extends Form<FormGroup> { |
|
|
export class CreateCategoryForm extends Form<FormGroup, { name: string }> { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
super(formBuilder.group({ |
|
|
super(formBuilder.group({ |
|
|
name: [''] |
|
|
name: [''] |
|
|
@ -26,7 +28,7 @@ export class CreateCategoryForm extends Form<FormGroup> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export class CreateSchemaForm extends Form<FormGroup> { |
|
|
export class CreateSchemaForm extends Form<FormGroup, { name: string, isSingleton?: boolean, import: any }> { |
|
|
public schemaName = |
|
|
public schemaName = |
|
|
value$(this.form.controls['name']).pipe(n => n || FALLBACK_NAME); |
|
|
value$(this.form.controls['name']).pipe(n => n || FALLBACK_NAME); |
|
|
|
|
|
|
|
|
@ -45,7 +47,7 @@ export class CreateSchemaForm extends Form<FormGroup> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export class AddPreviewUrlForm extends Form<FormGroup> { |
|
|
export class AddPreviewUrlForm extends Form<FormGroup, { name: string, url: string }> { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
super(formBuilder.group({ |
|
|
super(formBuilder.group({ |
|
|
name: ['', |
|
|
name: ['', |
|
|
@ -62,7 +64,7 @@ export class AddPreviewUrlForm extends Form<FormGroup> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export class ConfigurePreviewUrlsForm extends Form<FormArray> { |
|
|
export class ConfigurePreviewUrlsForm extends Form<FormArray, { [name: string]: string }> { |
|
|
constructor( |
|
|
constructor( |
|
|
private readonly formBuilder: FormBuilder |
|
|
private readonly formBuilder: FormBuilder |
|
|
) { |
|
|
) { |
|
|
@ -89,7 +91,9 @@ export class ConfigurePreviewUrlsForm extends Form<FormArray> { |
|
|
this.form.removeAt(index); |
|
|
this.form.removeAt(index); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public load(value?: any) { |
|
|
public transformLoad(value: { [name: string]: string }) { |
|
|
|
|
|
const result: { name: string, url: string }[] = []; |
|
|
|
|
|
|
|
|
if (Types.isObject(value)) { |
|
|
if (Types.isObject(value)) { |
|
|
const length = Object.keys(value).length; |
|
|
const length = Object.keys(value).length; |
|
|
|
|
|
|
|
|
@ -101,38 +105,28 @@ export class ConfigurePreviewUrlsForm extends Form<FormArray> { |
|
|
this.remove(this.form.controls.length - 1); |
|
|
this.remove(this.form.controls.length - 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const array: any[] = []; |
|
|
|
|
|
|
|
|
|
|
|
for (let key in value) { |
|
|
for (let key in value) { |
|
|
if (value.hasOwnProperty(key)) { |
|
|
if (value.hasOwnProperty(key)) { |
|
|
array.push({ name: key, url: value[key] }); |
|
|
result.push({ name: key, url: value[key] }); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
value = array; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
super.load(value); |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public submit() { |
|
|
public transformSubmit(value: { name: string, url: string }[]): { [name: string]: string } { |
|
|
let result = super.submit(); |
|
|
const result: { [name: string]: string } = {}; |
|
|
|
|
|
|
|
|
if (result) { |
|
|
|
|
|
const hash: { [name: string]: string } = {}; |
|
|
|
|
|
|
|
|
|
|
|
for (let item of result) { |
|
|
for (let item of value) { |
|
|
hash[item.name] = item.url; |
|
|
result[item.name] = item.url; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
result = hash; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export class EditScriptsForm extends Form<FormGroup> { |
|
|
export class EditScriptsForm extends Form<FormGroup, { query?: string, create?: string, change?: string, delete?: string, update?: string }> { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
super(formBuilder.group({ |
|
|
super(formBuilder.group({ |
|
|
query: '', |
|
|
query: '', |
|
|
@ -144,7 +138,7 @@ export class EditScriptsForm extends Form<FormGroup> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export class EditFieldForm extends Form<FormGroup> { |
|
|
export class EditFieldForm extends Form<FormGroup, { label?: string, hints?: string, placeholder?: string, editorUrl?: string, isRequired: boolean, isListField: boolean }> { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
super(formBuilder.group({ |
|
|
super(formBuilder.group({ |
|
|
label: ['', |
|
|
label: ['', |
|
|
@ -169,7 +163,7 @@ export class EditFieldForm extends Form<FormGroup> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export class EditSchemaForm extends Form<FormGroup> { |
|
|
export class EditSchemaForm extends Form<FormGroup, { label?: string, hints?: string }> { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
super(formBuilder.group({ |
|
|
super(formBuilder.group({ |
|
|
label: ['', |
|
|
label: ['', |
|
|
@ -186,7 +180,7 @@ export class EditSchemaForm extends Form<FormGroup> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export class AddFieldForm extends Form<FormGroup> { |
|
|
export class AddFieldForm extends Form<FormGroup, AddFieldDto> { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
constructor(formBuilder: FormBuilder) { |
|
|
super(formBuilder.group({ |
|
|
super(formBuilder.group({ |
|
|
type: ['String', |
|
|
type: ['String', |
|
|
@ -205,16 +199,16 @@ export class AddFieldForm extends Form<FormGroup> { |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public submit() { |
|
|
public transformLoad(value: AddFieldDto) { |
|
|
const value = super.submit(); |
|
|
const isLocalizable = value.partitioning === 'language'; |
|
|
|
|
|
|
|
|
|
|
|
return { name: value.name, isLocalizable, type: value.properties.fieldType }; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (value) { |
|
|
public transformSubmit(value: any): AddFieldDto { |
|
|
const properties = createProperties(value.type); |
|
|
const properties = createProperties(value.type); |
|
|
const partitioning = value.isLocalizable ? 'language' : 'invariant'; |
|
|
const partitioning = value.isLocalizable ? 'language' : 'invariant'; |
|
|
|
|
|
|
|
|
return { name: value.name, partitioning, properties }; |
|
|
return { name: value.name, partitioning, properties }; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |