diff --git a/src/Squidex/app/features/schemas/declarations.ts b/src/Squidex/app/features/schemas/declarations.ts index 34cd94e63..fccbd067f 100644 --- a/src/Squidex/app/features/schemas/declarations.ts +++ b/src/Squidex/app/features/schemas/declarations.ts @@ -37,6 +37,4 @@ export * from './pages/schema/schema-page.component'; export * from './pages/schema/schema-scripts-form.component'; export * from './pages/schemas/schema-form.component'; -export * from './pages/schemas/schemas-page.component'; - -export * from './state/schemas.state'; \ No newline at end of file +export * from './pages/schemas/schemas-page.component'; \ No newline at end of file diff --git a/src/Squidex/app/features/schemas/guards/schema-must-exist.guard.ts b/src/Squidex/app/features/schemas/guards/schema-must-exist.guard.ts index fe4ae3462..9c939729f 100644 --- a/src/Squidex/app/features/schemas/guards/schema-must-exist.guard.ts +++ b/src/Squidex/app/features/schemas/guards/schema-must-exist.guard.ts @@ -9,9 +9,7 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; -import { allParams } from '@app/framework'; - -import { SchemasState } from './../state/schemas.state'; +import { allParams, SchemasState } from '@app/shared'; @Injectable() export class SchemaMustExistGuard implements CanActivate { diff --git a/src/Squidex/app/features/schemas/module.ts b/src/Squidex/app/features/schemas/module.ts index c57b3e749..36197a511 100644 --- a/src/Squidex/app/features/schemas/module.ts +++ b/src/Squidex/app/features/schemas/module.ts @@ -40,7 +40,6 @@ import { SchemaPageComponent, SchemasPageComponent, SchemaScriptsFormComponent, - SchemasState, StringUIComponent, StringValidationComponent, TagsUIComponent, @@ -68,8 +67,7 @@ const routes: Routes = [ RouterModule.forChild(routes) ], providers: [ - SchemaMustExistGuard, - SchemasState + SchemaMustExistGuard ], declarations: [ FieldComponent, 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 b1dc9e58c..7f1b32832 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 @@ -8,9 +8,12 @@ import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core'; import { FormBuilder } from '@angular/forms'; -import { fieldTypes, SchemaDetailsDto } from '@app/shared'; - -import { SchemasState, AddFieldForm } from './../../state/schemas.state'; +import { + AddFieldForm, + fieldTypes, + SchemaDetailsDto, + SchemasState +} from '@app/shared'; @Component({ selector: 'sqx-field-wizard', 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 7fd322eca..ce2132cb5 100644 --- a/src/Squidex/app/features/schemas/pages/schema/field.component.ts +++ b/src/Squidex/app/features/schemas/pages/schema/field.component.ts @@ -11,15 +11,15 @@ import { FormBuilder } from '@angular/forms'; import { AppPatternDto, createProperties, + EditFieldForm, fadeAnimation, FieldDto, ModalView, SchemaDetailsDto, + SchemasState, UpdateFieldDto } from '@app/shared'; -import { SchemasState, EditFieldForm } from './../../state/schemas.state'; - @Component({ selector: 'sqx-field', styleUrls: ['./field.component.scss'], diff --git a/src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts b/src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts index 6d7a0402e..d84a15cdf 100644 --- a/src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts +++ b/src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts @@ -8,8 +8,11 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormBuilder } from '@angular/forms'; -import { SchemaDetailsDto } from '@app/shared'; -import { SchemasState, EditSchemaForm } from './../../state/schemas.state'; +import { + EditSchemaForm, + SchemaDetailsDto, + SchemasState +} from '@app/shared'; @Component({ selector: 'sqx-schema-edit-form', diff --git a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts index 1379e03ec..d3112f080 100644 --- a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts +++ b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts @@ -18,15 +18,14 @@ import { fieldTypes, MessageBus, ModalView, - SchemaDetailsDto + SchemaDetailsDto, + SchemasState } from '@app/shared'; import { SchemaCloning } from './../messages'; -import { SchemasState } from './../../state/schemas.state'; - @Component({ selector: 'sqx-schema-page', styleUrls: ['./schema-page.component.scss'], diff --git a/src/Squidex/app/features/schemas/pages/schema/schema-scripts-form.component.ts b/src/Squidex/app/features/schemas/pages/schema/schema-scripts-form.component.ts index a03a0d602..fe3900e63 100644 --- a/src/Squidex/app/features/schemas/pages/schema/schema-scripts-form.component.ts +++ b/src/Squidex/app/features/schemas/pages/schema/schema-scripts-form.component.ts @@ -8,8 +8,11 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormBuilder } from '@angular/forms'; -import { SchemaDetailsDto } from '@app/shared'; -import { SchemasState, EditScriptsForm } from './../../state/schemas.state'; +import { + EditScriptsForm, + SchemaDetailsDto, + SchemasState +} from '@app/shared'; @Component({ selector: 'sqx-schema-scripts-form', diff --git a/src/Squidex/app/features/schemas/pages/schema/types/references-validation.component.ts b/src/Squidex/app/features/schemas/pages/schema/types/references-validation.component.ts index 6783c18cf..996140219 100644 --- a/src/Squidex/app/features/schemas/pages/schema/types/references-validation.component.ts +++ b/src/Squidex/app/features/schemas/pages/schema/types/references-validation.component.ts @@ -8,9 +8,7 @@ import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { ReferencesFieldPropertiesDto } from '@app/shared'; - -import { SchemasState } from './../../../state/schemas.state'; +import { ReferencesFieldPropertiesDto, SchemasState } from '@app/shared'; @Component({ selector: 'sqx-references-validation', diff --git a/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts b/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts index 927037353..a9ec44827 100644 --- a/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts +++ b/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts @@ -8,9 +8,12 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormBuilder } from '@angular/forms'; -import { ApiUrlConfig, AppsState } from '@app/shared'; - -import { CreateForm, SchemasState } from './../../state/schemas.state'; +import { + ApiUrlConfig, + AppsState, + CreateSchemaForm, + SchemasState +} from '@app/shared'; @Component({ selector: 'sqx-schema-form', @@ -24,7 +27,7 @@ export class SchemaFormComponent implements OnInit { @Input() public import: any; - public createForm: CreateForm; + public createForm: CreateSchemaForm; public showImport = false; @@ -33,7 +36,7 @@ export class SchemaFormComponent implements OnInit { public readonly appsState: AppsState, private readonly schemasState: SchemasState ) { - this.createForm = new CreateForm(formBuilder); + this.createForm = new CreateSchemaForm(formBuilder); } public ngOnInit() { diff --git a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts index af7dad9b2..5a2782667 100644 --- a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts +++ b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts @@ -14,13 +14,12 @@ import { AppsState, MessageBus, ModalView, - SchemaDto + SchemaDto, + SchemasState } from '@app/shared'; import { SchemaCloning } from './../messages'; -import { SchemasState } from './../../state/schemas.state'; - @Component({ selector: 'sqx-schemas-page', styleUrls: ['./schemas-page.component.scss'], diff --git a/src/Squidex/app/shared/internal.ts b/src/Squidex/app/shared/internal.ts index eff7fd697..1bbfb958b 100644 --- a/src/Squidex/app/shared/internal.ts +++ b/src/Squidex/app/shared/internal.ts @@ -39,6 +39,7 @@ export * from './services/users-provider.service'; export * from './services/users.service'; export * from './state/apps.state'; +export * from './state/schemas.state'; export * from './utils/messages'; diff --git a/src/Squidex/app/shared/module.ts b/src/Squidex/app/shared/module.ts index cefb9697f..4d17ddba3 100644 --- a/src/Squidex/app/shared/module.ts +++ b/src/Squidex/app/shared/module.ts @@ -60,7 +60,8 @@ import { UserPictureRefPipe, UsersProviderService, UsersService, - RichEditorComponent + RichEditorComponent, + SchemasState } from './declarations'; @NgModule({ @@ -139,6 +140,7 @@ export class SqxSharedModule { ResolveSchemaGuard, RulesService, SchemasService, + SchemasState, UIService, UnsetAppGuard, UsagesService, diff --git a/src/Squidex/app/features/schemas/state/schemas.state.spec.ts b/src/Squidex/app/shared/state/schemas.state.spec.ts similarity index 99% rename from src/Squidex/app/features/schemas/state/schemas.state.spec.ts rename to src/Squidex/app/shared/state/schemas.state.spec.ts index ccffa1403..69421f2c4 100644 --- a/src/Squidex/app/features/schemas/state/schemas.state.spec.ts +++ b/src/Squidex/app/shared/state/schemas.state.spec.ts @@ -8,21 +8,25 @@ import { Observable } from 'rxjs'; import { IMock, It, Mock, Times } from 'typemoq'; -import { AuthService, DialogService, Versioned, AddFieldDto, CreateSchemaDto, UpdateFieldDto } from '@app/shared'; - import { SchemasState } from './schemas.state'; import { + AddFieldDto, AppsState, + AuthService, createProperties, + CreateSchemaDto, + DialogService, DateTime, FieldDto, SchemaDetailsDto, SchemaDto, SchemasService, + UpdateFieldDto, UpdateSchemaDto, UpdateSchemaScriptsDto, - Version + Version, + Versioned } from '@app/shared'; describe('SchemasState', () => { diff --git a/src/Squidex/app/features/schemas/state/schemas.state.ts b/src/Squidex/app/shared/state/schemas.state.ts similarity index 98% rename from src/Squidex/app/features/schemas/state/schemas.state.ts rename to src/Squidex/app/shared/state/schemas.state.ts index 0e8a85e4c..fcecacac2 100644 --- a/src/Squidex/app/features/schemas/state/schemas.state.ts +++ b/src/Squidex/app/shared/state/schemas.state.ts @@ -12,32 +12,36 @@ import { Observable } from 'rxjs'; import '@app/framework/utils/rxjs-extensions'; import { - AddFieldDto, - AppsState, - AuthService, - createProperties, - CreateSchemaDto, DateTime, DialogService, - FieldDto, Form, ImmutableArray, + State, + ValidatorsEx, + Version +} from '@app/framework'; + +import { AppsState } from './apps.state'; +import { AuthService } from './../services/auth.service'; + +import { + AddFieldDto, + createProperties, + CreateSchemaDto, + FieldDto, SchemaDto, SchemaDetailsDto, SchemasService, - State, UpdateFieldDto, UpdateSchemaScriptsDto, UpdateSchemaDto, - ValidatorsEx, - Version, SchemaPropertiesDto, FieldPropertiesDto -} from '@app/shared'; +} from './../services/schemas.service'; const FALLBACK_NAME = 'my-schema'; -export class CreateForm extends Form { +export class CreateSchemaForm extends Form { public schemaName = this.form.controls['name'].valueChanges.map(n => n || FALLBACK_NAME) .startWith(FALLBACK_NAME);