|
|
@ -8,12 +8,17 @@ |
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
import { Injectable } from '@angular/core'; |
|
|
import { Injectable } from '@angular/core'; |
|
|
import { Observable } from 'rxjs'; |
|
|
import { Observable } from 'rxjs'; |
|
|
import { map, tap } from 'rxjs/operators'; |
|
|
import { map } from 'rxjs/operators'; |
|
|
import { AnalyticsService, ApiUrlConfig, DateTime, hasAnyLink, HTTP, pretifyError, Resource, ResourceLinks, StringHelper, Types, Version, Versioned } from '@app/framework'; |
|
|
import { ApiUrlConfig, DateTime, hasAnyLink, HTTP, pretifyError, Resource, ResourceLinks, StringHelper, Types, Version, Versioned } from '@app/framework'; |
|
|
import { QueryModel } from './query'; |
|
|
import { QueryModel } from './query'; |
|
|
import { createProperties, FieldPropertiesDto } from './schemas.types'; |
|
|
import { createProperties, FieldPropertiesDto } from './schemas.types'; |
|
|
|
|
|
|
|
|
export const MetaFields = { |
|
|
export type FieldRuleAction = 'Disable' | 'Hide' | 'Require'; |
|
|
|
|
|
export type SchemaType = 'Default' | 'Singleton' | 'Component'; |
|
|
|
|
|
export type SchemaScripts = Record<string, string | null>; |
|
|
|
|
|
export type PreviewUrls = Record<string, string>; |
|
|
|
|
|
|
|
|
|
|
|
export const META_FIELDS = { |
|
|
empty: { |
|
|
empty: { |
|
|
name: '', |
|
|
name: '', |
|
|
label: '', |
|
|
label: '', |
|
|
@ -64,17 +69,19 @@ export const MetaFields = { |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export type SchemaType = 'Default' | 'Singleton' | 'Component'; |
|
|
export const FIELD_RULE_ACTIONS: ReadonlyArray<FieldRuleAction> = [ |
|
|
export type SchemaScripts = Record<string, string | null>; |
|
|
'Disable', |
|
|
export type PreviewUrls = Record<string, string>; |
|
|
'Hide', |
|
|
|
|
|
'Require', |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
export class SchemaDto { |
|
|
export class SchemaDto { |
|
|
public readonly _links: ResourceLinks; |
|
|
public readonly _links: ResourceLinks; |
|
|
|
|
|
|
|
|
public readonly canAddField: boolean; |
|
|
public readonly canAddField: boolean; |
|
|
public readonly canContentsRead: boolean; |
|
|
|
|
|
public readonly canContentsCreate: boolean; |
|
|
public readonly canContentsCreate: boolean; |
|
|
public readonly canContentsCreateAndPublish: boolean; |
|
|
public readonly canContentsCreateAndPublish: boolean; |
|
|
|
|
|
public readonly canContentsRead: boolean; |
|
|
public readonly canDelete: boolean; |
|
|
public readonly canDelete: boolean; |
|
|
public readonly canOrderFields: boolean; |
|
|
public readonly canOrderFields: boolean; |
|
|
public readonly canPublish: boolean; |
|
|
public readonly canPublish: boolean; |
|
|
@ -83,10 +90,10 @@ export class SchemaDto { |
|
|
public readonly canUnpublish: boolean; |
|
|
public readonly canUnpublish: boolean; |
|
|
public readonly canUpdate: boolean; |
|
|
public readonly canUpdate: boolean; |
|
|
public readonly canUpdateCategory: boolean; |
|
|
public readonly canUpdateCategory: boolean; |
|
|
|
|
|
public readonly canUpdateRules: boolean; |
|
|
public readonly canUpdateScripts: boolean; |
|
|
public readonly canUpdateScripts: boolean; |
|
|
public readonly canUpdateUIFields: boolean; |
|
|
public readonly canUpdateUIFields: boolean; |
|
|
public readonly canUpdateUrls: boolean; |
|
|
public readonly canUpdateUrls: boolean; |
|
|
public readonly canUpdateRules: boolean; |
|
|
|
|
|
|
|
|
|
|
|
public readonly displayName: string; |
|
|
public readonly displayName: string; |
|
|
|
|
|
|
|
|
@ -108,8 +115,8 @@ export class SchemaDto { |
|
|
public readonly isPublished: boolean, |
|
|
public readonly isPublished: boolean, |
|
|
public readonly properties: SchemaPropertiesDto, |
|
|
public readonly properties: SchemaPropertiesDto, |
|
|
public readonly fields: ReadonlyArray<RootFieldDto> = [], |
|
|
public readonly fields: ReadonlyArray<RootFieldDto> = [], |
|
|
public readonly fieldsInLists: Tags = [], |
|
|
public readonly fieldsInLists: ReadonlyArray<string> = [], |
|
|
public readonly fieldsInReferences: Tags = [], |
|
|
public readonly fieldsInReferences: ReadonlyArray<string> = [], |
|
|
public readonly fieldRules: ReadonlyArray<FieldRule> = [], |
|
|
public readonly fieldRules: ReadonlyArray<FieldRule> = [], |
|
|
public readonly previewUrls: PreviewUrls = {}, |
|
|
public readonly previewUrls: PreviewUrls = {}, |
|
|
public readonly scripts: SchemaScripts = {}, |
|
|
public readonly scripts: SchemaScripts = {}, |
|
|
@ -117,9 +124,9 @@ export class SchemaDto { |
|
|
this._links = links; |
|
|
this._links = links; |
|
|
|
|
|
|
|
|
this.canAddField = hasAnyLink(links, 'fields/add'); |
|
|
this.canAddField = hasAnyLink(links, 'fields/add'); |
|
|
this.canContentsRead = hasAnyLink(links, 'contents'); |
|
|
|
|
|
this.canContentsCreate = hasAnyLink(links, 'contents/create'); |
|
|
this.canContentsCreate = hasAnyLink(links, 'contents/create'); |
|
|
this.canContentsCreateAndPublish = hasAnyLink(links, 'contents/create/publish'); |
|
|
this.canContentsCreateAndPublish = hasAnyLink(links, 'contents/create/publish'); |
|
|
|
|
|
this.canContentsRead = hasAnyLink(links, 'contents'); |
|
|
this.canDelete = hasAnyLink(links, 'delete'); |
|
|
this.canDelete = hasAnyLink(links, 'delete'); |
|
|
this.canOrderFields = hasAnyLink(links, 'fields/order'); |
|
|
this.canOrderFields = hasAnyLink(links, 'fields/order'); |
|
|
this.canPublish = hasAnyLink(links, 'publish'); |
|
|
this.canPublish = hasAnyLink(links, 'publish'); |
|
|
@ -128,49 +135,53 @@ export class SchemaDto { |
|
|
this.canUnpublish = hasAnyLink(links, 'unpublish'); |
|
|
this.canUnpublish = hasAnyLink(links, 'unpublish'); |
|
|
this.canUpdate = hasAnyLink(links, 'update'); |
|
|
this.canUpdate = hasAnyLink(links, 'update'); |
|
|
this.canUpdateCategory = hasAnyLink(links, 'update/category'); |
|
|
this.canUpdateCategory = hasAnyLink(links, 'update/category'); |
|
|
|
|
|
this.canUpdateRules = hasAnyLink(links, 'update/rules'); |
|
|
this.canUpdateScripts = hasAnyLink(links, 'update/scripts'); |
|
|
this.canUpdateScripts = hasAnyLink(links, 'update/scripts'); |
|
|
this.canUpdateUIFields = hasAnyLink(links, 'fields/ui'); |
|
|
this.canUpdateUIFields = hasAnyLink(links, 'fields/ui'); |
|
|
this.canUpdateUrls = hasAnyLink(links, 'update/urls'); |
|
|
this.canUpdateUrls = hasAnyLink(links, 'update/urls'); |
|
|
this.canUpdateRules = hasAnyLink(links, 'update/rules'); |
|
|
|
|
|
|
|
|
|
|
|
this.displayName = StringHelper.firstNonEmpty(this.properties.label, this.name); |
|
|
this.displayName = StringHelper.firstNonEmpty(this.properties.label, this.name); |
|
|
|
|
|
|
|
|
|
|
|
function tableField(rootField: RootFieldDto) { |
|
|
|
|
|
return { name: rootField.name, label: rootField.displayName, rootField }; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (fields) { |
|
|
if (fields) { |
|
|
this.contentFields = fields.filter(x => x.properties.isContentField).map(tableField); |
|
|
this.contentFields = fields.filter(x => x.properties.isContentField).map(tableField); |
|
|
|
|
|
|
|
|
function tableFields(names: ReadonlyArray<string>, fields: ReadonlyArray<RootFieldDto>): TableField[] { |
|
|
function tableFields(names: ReadonlyArray<string>, fields: ReadonlyArray<RootFieldDto>): TableField[] { |
|
|
const result: TableField[] = []; |
|
|
const result: TableField[] = []; |
|
|
|
|
|
|
|
|
for (const name of names) { |
|
|
for (const name of names) { |
|
|
const metaField = MetaFields[name]; |
|
|
const metaField = META_FIELDS[name]; |
|
|
|
|
|
|
|
|
if (metaField) { |
|
|
if (metaField) { |
|
|
result.push(metaField); |
|
|
result.push(metaField); |
|
|
} else { |
|
|
} else { |
|
|
const field = fields.find(x => x.name === name && x.properties.isContentField); |
|
|
const field = fields.find(x => x.name === name && x.properties.isContentField); |
|
|
|
|
|
|
|
|
if (field) { |
|
|
if (field) { |
|
|
result.push(tableField(field)); |
|
|
result.push(tableField(field)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const listFields = tableFields(fieldsInLists, fields); |
|
|
const listFields = tableFields(fieldsInLists, fields); |
|
|
|
|
|
|
|
|
if (listFields.length === 0) { |
|
|
if (listFields.length === 0) { |
|
|
listFields.push(MetaFields.lastModifiedByAvatar); |
|
|
listFields.push(META_FIELDS.lastModifiedByAvatar); |
|
|
|
|
|
|
|
|
if (fields.length > 0) { |
|
|
if (fields.length > 0) { |
|
|
listFields.push(tableField(this.fields[0])); |
|
|
listFields.push(tableField(this.fields[0])); |
|
|
} else { |
|
|
} else { |
|
|
listFields.push(MetaFields.empty); |
|
|
listFields.push(META_FIELDS.empty); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
listFields.push(MetaFields.statusColor); |
|
|
listFields.push(META_FIELDS.statusColor); |
|
|
listFields.push(MetaFields.lastModified); |
|
|
listFields.push(META_FIELDS.lastModified); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.defaultListFields = listFields; |
|
|
this.defaultListFields = listFields; |
|
|
@ -181,7 +192,7 @@ export class SchemaDto { |
|
|
if (fields.length > 0) { |
|
|
if (fields.length > 0) { |
|
|
referenceFields.push(tableField(this.fields[0])); |
|
|
referenceFields.push(tableField(this.fields[0])); |
|
|
} else { |
|
|
} else { |
|
|
referenceFields.push(MetaFields.empty); |
|
|
referenceFields.push(META_FIELDS.empty); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -246,10 +257,6 @@ export class SchemaDto { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function tableField(rootField: RootFieldDto) { |
|
|
|
|
|
return { name: rootField.name, label: rootField.displayName, rootField }; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export class FieldDto { |
|
|
export class FieldDto { |
|
|
public readonly _links: ResourceLinks; |
|
|
public readonly _links: ResourceLinks; |
|
|
|
|
|
|
|
|
@ -341,52 +348,135 @@ export class SchemaPropertiesDto { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export const FIELD_RULE_ACTIONS: ReadonlyArray<FieldRuleAction> = [ |
|
|
export type TableField = Readonly<{ |
|
|
'Disable', |
|
|
// The name of the table field.
|
|
|
'Hide', |
|
|
name: string; |
|
|
'Require', |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
type Tags = readonly string[]; |
|
|
// The label for the table header.
|
|
|
|
|
|
label: string; |
|
|
|
|
|
|
|
|
export type TableField = { name: string; label: string; rootField?: RootFieldDto }; |
|
|
// The reference to the root field.
|
|
|
|
|
|
rootField?: RootFieldDto; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
export type FieldRuleAction = 'Disable' | 'Hide' | 'Require'; |
|
|
export type FieldRule = Readonly<{ |
|
|
export type FieldRule = { field: string; action: FieldRuleAction; condition: string }; |
|
|
// The path to the field to update when the rule is valid.
|
|
|
|
|
|
field: string; |
|
|
|
|
|
|
|
|
|
|
|
// The action to invoke.
|
|
|
|
|
|
action: FieldRuleAction; |
|
|
|
|
|
|
|
|
|
|
|
//The condition as javascript expression.
|
|
|
|
|
|
condition: string; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
|
|
|
export type SchemaCompletions = ReadonlyArray<{ |
|
|
|
|
|
// The autocompletion path.
|
|
|
|
|
|
path: string; |
|
|
|
|
|
|
|
|
export type SchemaCompletions = |
|
|
// The description of the autocompletion field.
|
|
|
ReadonlyArray<{ path: string; description: string; type: string }>; |
|
|
description: string; |
|
|
|
|
|
|
|
|
export type SchemasDto = |
|
|
// The type of the autocompletion field.
|
|
|
Readonly<{ items: ReadonlyArray<SchemaDto>; canCreate: boolean } & Resource>; |
|
|
type: string; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
export type AddFieldDto = |
|
|
export type SchemasDto = Readonly<{ |
|
|
Readonly<{ name: string; partitioning?: string; properties: FieldPropertiesDto }>; |
|
|
// The list of schemas.
|
|
|
|
|
|
items: ReadonlyArray<SchemaDto>; |
|
|
|
|
|
|
|
|
export type UpdateUIFields = |
|
|
// True, if the user has permissions to create a new schema.
|
|
|
Readonly<{ fieldsInLists?: Tags; fieldsInReferences?: Tags }>; |
|
|
canCreate?: boolean; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
export type CreateSchemaDto = |
|
|
export type AddFieldDto = Readonly<{ |
|
|
Readonly<{ name: string; fields?: ReadonlyArray<RootFieldDto>; category?: string; type?: string; isPublished?: boolean; properties?: SchemaPropertiesDto }>; |
|
|
// The name of the field.
|
|
|
|
|
|
name: string; |
|
|
|
|
|
|
|
|
export type UpdateSchemaCategoryDto = |
|
|
// The partitioning of the field.
|
|
|
Readonly<{ name?: string }>; |
|
|
partitioning?: string; |
|
|
|
|
|
|
|
|
export type UpdateFieldDto = |
|
|
// The field properties.
|
|
|
Readonly<{ properties: FieldPropertiesDto }>; |
|
|
properties: FieldPropertiesDto; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
export type SynchronizeSchemaDto = |
|
|
export type UpdateUIFields = Readonly<{ |
|
|
Readonly<{ noFieldDeletiong?: boolean; noFieldRecreation?: boolean; [key: string]: any }>; |
|
|
// The names of all fields that should be shown in the list.
|
|
|
|
|
|
fieldsInLists?: ReadonlyArray<string>; |
|
|
|
|
|
|
|
|
export type UpdateSchemaDto = |
|
|
// The names of all fields that should be shown in the reference list.
|
|
|
Readonly<{ label?: string; hints?: string; contentsSidebarUrl?: string; contentSidebarUrl?: string; contentEditorUrl?: string; validateOnPublish?: boolean; tags?: Tags }>; |
|
|
fieldsInReferences?: ReadonlyArray<string>; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
|
|
|
export type CreateSchemaDto = Readonly<{ |
|
|
|
|
|
// The name of the schema.
|
|
|
|
|
|
name: string; |
|
|
|
|
|
|
|
|
|
|
|
// The initial fields of the schema.
|
|
|
|
|
|
fields?: ReadonlyArray<RootFieldDto>; |
|
|
|
|
|
|
|
|
|
|
|
// The category name.
|
|
|
|
|
|
category?: string; |
|
|
|
|
|
|
|
|
|
|
|
// The type of the schema.
|
|
|
|
|
|
type?: string; |
|
|
|
|
|
|
|
|
|
|
|
// The initial published state.
|
|
|
|
|
|
isPublished?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
// The initial schema properties.
|
|
|
|
|
|
properties?: SchemaPropertiesDto; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
|
|
|
export type UpdateSchemaCategoryDto = Readonly<{ |
|
|
|
|
|
// The name of the category.
|
|
|
|
|
|
name?: string; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
|
|
|
export type UpdateFieldDto = Readonly<{ |
|
|
|
|
|
// The field properties.
|
|
|
|
|
|
properties: FieldPropertiesDto; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
|
|
|
export type SynchronizeSchemaDto = Readonly<{ |
|
|
|
|
|
// True, to not delete fields when synchronizing.
|
|
|
|
|
|
noFieldDeletiong?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
// True, to not recreate fields when synchronizing.
|
|
|
|
|
|
noFieldRecreation?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
// The additional properties.
|
|
|
|
|
|
[key: string]: any; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
|
|
|
export type UpdateSchemaDto = Readonly<{ |
|
|
|
|
|
// The label of the schema.
|
|
|
|
|
|
label?: string; |
|
|
|
|
|
|
|
|
|
|
|
// The hints to explain the schema.
|
|
|
|
|
|
hints?: string; |
|
|
|
|
|
|
|
|
|
|
|
// The URL to the contents sidebar plugin.
|
|
|
|
|
|
contentsSidebarUrl?: string; |
|
|
|
|
|
|
|
|
|
|
|
// The URL to the content sidebar plugin.
|
|
|
|
|
|
contentSidebarUrl?: string; |
|
|
|
|
|
|
|
|
|
|
|
// The URL to an editor to replace the editor.
|
|
|
|
|
|
contentEditorUrl?: string; |
|
|
|
|
|
|
|
|
|
|
|
// True, if the content should be validated on publishing.
|
|
|
|
|
|
validateOnPublish?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
// The tags.
|
|
|
|
|
|
tags?: ReadonlyArray<string>; |
|
|
|
|
|
}>; |
|
|
|
|
|
|
|
|
@Injectable() |
|
|
@Injectable() |
|
|
export class SchemasService { |
|
|
export class SchemasService { |
|
|
constructor( |
|
|
constructor( |
|
|
private readonly http: HttpClient, |
|
|
private readonly http: HttpClient, |
|
|
private readonly apiUrl: ApiUrlConfig, |
|
|
private readonly apiUrl: ApiUrlConfig, |
|
|
private readonly analytics: AnalyticsService, |
|
|
|
|
|
) { |
|
|
) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -417,9 +507,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'Created', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.createFailed')); |
|
|
pretifyError('i18n:schemas.createFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -432,9 +519,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'ScriptsConfigured', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.updateScriptsFailed')); |
|
|
pretifyError('i18n:schemas.updateScriptsFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -447,9 +531,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'RulesConfigured', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.updateRulesFailed')); |
|
|
pretifyError('i18n:schemas.updateRulesFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -462,9 +543,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'Updated', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.synchronizeFailed')); |
|
|
pretifyError('i18n:schemas.synchronizeFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -477,9 +555,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'Updated', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.updateFailed')); |
|
|
pretifyError('i18n:schemas.updateFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -492,9 +567,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'CategoryChanged', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.changeCategoryFailed')); |
|
|
pretifyError('i18n:schemas.changeCategoryFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -507,9 +579,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'PreviewUrlsConfigured', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.updatePreviewUrlsFailed')); |
|
|
pretifyError('i18n:schemas.updatePreviewUrlsFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -522,9 +591,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'Published', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.publishFailed')); |
|
|
pretifyError('i18n:schemas.publishFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -537,9 +603,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'Unpublished', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.unpublishFailed')); |
|
|
pretifyError('i18n:schemas.unpublishFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -552,9 +615,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'FieldCreated', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.addFieldFailed')); |
|
|
pretifyError('i18n:schemas.addFieldFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -567,9 +627,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'UIFieldsConfigured', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.updateUIFieldsFailed')); |
|
|
pretifyError('i18n:schemas.updateUIFieldsFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -582,9 +639,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'FieldsReordered', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.reorderFieldsFailed')); |
|
|
pretifyError('i18n:schemas.reorderFieldsFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -597,9 +651,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'FieldUpdated', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.updateFieldFailed')); |
|
|
pretifyError('i18n:schemas.updateFieldFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -612,9 +663,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'FieldLocked', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.lockFieldFailed')); |
|
|
pretifyError('i18n:schemas.lockFieldFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -627,9 +675,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'FieldEnabled', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.enableFieldFailed')); |
|
|
pretifyError('i18n:schemas.enableFieldFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -642,9 +687,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'FieldDisabled', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.disableFieldFailed')); |
|
|
pretifyError('i18n:schemas.disableFieldFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -657,9 +699,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'FieldShown', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.showFieldFailed')); |
|
|
pretifyError('i18n:schemas.showFieldFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -672,9 +711,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'FieldHidden', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.hideFieldFailed')); |
|
|
pretifyError('i18n:schemas.hideFieldFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -687,9 +723,6 @@ export class SchemasService { |
|
|
map(({ payload }) => { |
|
|
map(({ payload }) => { |
|
|
return parseSchema(payload.body); |
|
|
return parseSchema(payload.body); |
|
|
}), |
|
|
}), |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'FieldDeleted', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.deleteFieldFailed')); |
|
|
pretifyError('i18n:schemas.deleteFieldFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -699,9 +732,6 @@ export class SchemasService { |
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version).pipe( |
|
|
return HTTP.requestVersioned(this.http, link.method, url, version).pipe( |
|
|
tap(() => { |
|
|
|
|
|
this.analytics.trackEvent('Schema', 'Deleted', appName); |
|
|
|
|
|
}), |
|
|
|
|
|
pretifyError('i18n:schemas.deleteFailed')); |
|
|
pretifyError('i18n:schemas.deleteFailed')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -719,11 +749,12 @@ export class SchemasService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function parseSchemas(response: { items: any[] } & Resource) { |
|
|
function parseSchemas(response: { items: any[] } & Resource) { |
|
|
const items = response.items.map(parseSchema); |
|
|
const { items: list, _links } = response; |
|
|
|
|
|
const items = list.map(parseSchema); |
|
|
|
|
|
|
|
|
const _links = response._links; |
|
|
const canCreate = hasAnyLink(_links, 'create'); |
|
|
|
|
|
|
|
|
return { items, _links, canCreate: hasAnyLink(_links, 'create') }; |
|
|
return { items, canCreate }; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function parseSchema(response: any) { |
|
|
function parseSchema(response: any) { |
|
|
|