mirror of https://github.com/Squidex/squidex.git
41 changed files with 1170 additions and 1053 deletions
@ -1,69 +0,0 @@ |
|||||
/* |
|
||||
* Squidex Headless CMS |
|
||||
* |
|
||||
* @license |
|
||||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|
||||
*/ |
|
||||
|
|
||||
import { Injectable } from '@angular/core'; |
|
||||
import { ActivatedRoute } from '@angular/router'; |
|
||||
import { Observable } from 'rxjs'; |
|
||||
|
|
||||
import { MessageBus } from '@app/framework'; |
|
||||
|
|
||||
import { |
|
||||
AppDto, |
|
||||
AppsState, |
|
||||
AuthService, |
|
||||
DialogService, |
|
||||
ErrorDto, |
|
||||
Profile |
|
||||
} from '@app/shared/internal'; |
|
||||
|
|
||||
@Injectable() |
|
||||
export class AppContext { |
|
||||
public get app(): AppDto { |
|
||||
return this.appsState.snapshot.selectedApp!; |
|
||||
} |
|
||||
|
|
||||
public get appChanges(): Observable<AppDto | null> { |
|
||||
return this.appsState.selectedApp; |
|
||||
} |
|
||||
|
|
||||
public get appName(): string { |
|
||||
return this.app.name; |
|
||||
} |
|
||||
|
|
||||
public get userToken(): string { |
|
||||
return this.authService.user!.token; |
|
||||
} |
|
||||
|
|
||||
public get userId(): string { |
|
||||
return this.authService.user!.id; |
|
||||
} |
|
||||
|
|
||||
public get user(): Profile { |
|
||||
return this.authService.user!; |
|
||||
} |
|
||||
|
|
||||
constructor( |
|
||||
public readonly dialogs: DialogService, |
|
||||
public readonly authService: AuthService, |
|
||||
public readonly appsState: AppsState, |
|
||||
public readonly route: ActivatedRoute, |
|
||||
public readonly bus: MessageBus |
|
||||
) { |
|
||||
} |
|
||||
|
|
||||
public confirmUnsavedChanges(): Observable<boolean> { |
|
||||
return this.dialogs.confirmUnsavedChanges(); |
|
||||
} |
|
||||
|
|
||||
public notifyInfo(error: string) { |
|
||||
this.dialogs.notifyInfo(error); |
|
||||
} |
|
||||
|
|
||||
public notifyError(error: string | ErrorDto) { |
|
||||
this.dialogs.notifyError(error); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,62 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { Router } from '@angular/router'; |
||||
|
import { Observable } from 'rxjs'; |
||||
|
import { IMock, Mock, Times } from 'typemoq'; |
||||
|
|
||||
|
import { ContentDto } from './../services/contents.service'; |
||||
|
import { ContentsState } from './../state/contents.state'; |
||||
|
import { ContentMustExistGuard } from './content-must-exist.guard'; |
||||
|
|
||||
|
describe('ContentMustExistGuard', () => { |
||||
|
const route: any = { |
||||
|
params: { |
||||
|
contentId: '123' |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
let contentsState: IMock<ContentsState>; |
||||
|
let router: IMock<Router>; |
||||
|
let contentGuard: ContentMustExistGuard; |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
router = Mock.ofType<Router>(); |
||||
|
contentsState = Mock.ofType<ContentsState>(); |
||||
|
contentGuard = new ContentMustExistGuard(contentsState.object, router.object); |
||||
|
}); |
||||
|
|
||||
|
it('should load content and return true when found', () => { |
||||
|
contentsState.setup(x => x.select('123')) |
||||
|
.returns(() => Observable.of(<ContentDto>{})); |
||||
|
|
||||
|
let result: boolean; |
||||
|
|
||||
|
contentGuard.canActivate(route).subscribe(x => { |
||||
|
result = x; |
||||
|
}).unsubscribe(); |
||||
|
|
||||
|
expect(result!).toBeTruthy(); |
||||
|
|
||||
|
contentsState.verify(x => x.select('123'), Times.once()); |
||||
|
}); |
||||
|
|
||||
|
it('should load content and return false when not found', () => { |
||||
|
contentsState.setup(x => x.select('123')) |
||||
|
.returns(() => Observable.of(null)); |
||||
|
|
||||
|
let result: boolean; |
||||
|
|
||||
|
contentGuard.canActivate(route).subscribe(x => { |
||||
|
result = x; |
||||
|
}).unsubscribe(); |
||||
|
|
||||
|
expect(result!).toBeFalsy(); |
||||
|
|
||||
|
router.verify(x => x.navigate(['/404']), Times.once()); |
||||
|
}); |
||||
|
}); |
||||
@ -0,0 +1,38 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { Injectable } from '@angular/core'; |
||||
|
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router'; |
||||
|
import { Observable } from 'rxjs'; |
||||
|
|
||||
|
import { allParams } from '@app/framework'; |
||||
|
|
||||
|
import { ContentsState } from './../state/contents.state'; |
||||
|
|
||||
|
@Injectable() |
||||
|
export class ContentMustExistGuard implements CanActivate { |
||||
|
constructor( |
||||
|
private readonly contentsState: ContentsState, |
||||
|
private readonly router: Router |
||||
|
) { |
||||
|
} |
||||
|
|
||||
|
public canActivate(route: ActivatedRouteSnapshot): Observable<boolean> { |
||||
|
const contentId = allParams(route)['contentId']; |
||||
|
|
||||
|
const result = |
||||
|
this.contentsState.select(contentId) |
||||
|
.do(dto => { |
||||
|
if (!dto) { |
||||
|
this.router.navigate(['/404']); |
||||
|
} |
||||
|
}) |
||||
|
.map(u => u !== null); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
@ -1,46 +0,0 @@ |
|||||
/* |
|
||||
* Squidex Headless CMS |
|
||||
* |
|
||||
* @license |
|
||||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|
||||
*/ |
|
||||
|
|
||||
import { Injectable } from '@angular/core'; |
|
||||
import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router'; |
|
||||
import { Observable } from 'rxjs'; |
|
||||
|
|
||||
import { allParams } from '@app/framework'; |
|
||||
|
|
||||
import { ContentDto, ContentsService } from './../services/contents.service'; |
|
||||
|
|
||||
@Injectable() |
|
||||
export class ResolveContentGuard implements Resolve<ContentDto | null> { |
|
||||
constructor( |
|
||||
private readonly contentsService: ContentsService, |
|
||||
private readonly router: Router |
|
||||
) { |
|
||||
} |
|
||||
|
|
||||
public resolve(route: ActivatedRouteSnapshot): Observable<ContentDto | null> { |
|
||||
const params = allParams(route); |
|
||||
|
|
||||
const appName = params['appName']; |
|
||||
const contentId = params['contentId']; |
|
||||
const schemaName = params['schemaName']; |
|
||||
|
|
||||
const result = |
|
||||
this.contentsService.getContent(appName, schemaName, contentId) |
|
||||
.do(dto => { |
|
||||
if (!dto) { |
|
||||
this.router.navigate(['/404']); |
|
||||
} |
|
||||
}) |
|
||||
.catch(error => { |
|
||||
this.router.navigate(['/404']); |
|
||||
|
|
||||
return Observable.of(null); |
|
||||
}); |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,37 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { Observable } from 'rxjs'; |
||||
|
import { IMock, Mock, Times } from 'typemoq'; |
||||
|
|
||||
|
import { ContentsState } from './../state/contents.state'; |
||||
|
import { UnsetContentGuard } from './unset-content.guard'; |
||||
|
|
||||
|
describe('UnsetContentGuard', () => { |
||||
|
let contentsState: IMock<ContentsState>; |
||||
|
let contentGuard: UnsetContentGuard; |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
contentsState = Mock.ofType<ContentsState>(); |
||||
|
contentGuard = new UnsetContentGuard(contentsState.object); |
||||
|
}); |
||||
|
|
||||
|
it('should unset content', () => { |
||||
|
contentsState.setup(x => x.select(null)) |
||||
|
.returns(() => Observable.of(null)); |
||||
|
|
||||
|
let result: boolean; |
||||
|
|
||||
|
contentGuard.canActivate().subscribe(x => { |
||||
|
result = x; |
||||
|
}).unsubscribe(); |
||||
|
|
||||
|
expect(result!).toBeTruthy(); |
||||
|
|
||||
|
contentsState.verify(x => x.select(null), Times.once()); |
||||
|
}); |
||||
|
}); |
||||
@ -0,0 +1,24 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { Injectable } from '@angular/core'; |
||||
|
import { CanActivate } from '@angular/router'; |
||||
|
import { Observable } from 'rxjs'; |
||||
|
|
||||
|
import { ContentsState } from './../state/contents.state'; |
||||
|
|
||||
|
@Injectable() |
||||
|
export class UnsetContentGuard implements CanActivate { |
||||
|
constructor( |
||||
|
private readonly usersState: ContentsState |
||||
|
) { |
||||
|
} |
||||
|
|
||||
|
public canActivate(): Observable<boolean> { |
||||
|
return this.usersState.select(null).map(u => u === null); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,382 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { Injectable } from '@angular/core'; |
||||
|
import { FormControl, FormGroup } from '@angular/forms'; |
||||
|
import { Observable } from 'rxjs'; |
||||
|
|
||||
|
import '@app/framework/utils/rxjs-extensions'; |
||||
|
|
||||
|
import { |
||||
|
DateTime, |
||||
|
DialogService, |
||||
|
ErrorDto, |
||||
|
Form, |
||||
|
ImmutableArray, |
||||
|
Pager, |
||||
|
State, |
||||
|
Version, |
||||
|
Versioned |
||||
|
} from '@app/framework'; |
||||
|
|
||||
|
import { AppLanguageDto } from './../services/app-languages.service'; |
||||
|
import { AuthService } from './../services/auth.service'; |
||||
|
import { fieldInvariant, SchemaDetailsDto, SchemaDto } from './../services/schemas.service'; |
||||
|
import { AppsState } from './apps.state'; |
||||
|
import { SchemasState } from './schemas.state'; |
||||
|
|
||||
|
import { |
||||
|
ContentDto, |
||||
|
ContentsService |
||||
|
} from './../services/contents.service'; |
||||
|
|
||||
|
export class EditContentForm extends Form<FormGroup> { |
||||
|
constructor( |
||||
|
private readonly schema: SchemaDetailsDto, |
||||
|
private readonly languages: ImmutableArray<AppLanguageDto> |
||||
|
) { |
||||
|
super(new FormGroup({})); |
||||
|
|
||||
|
for (const field of schema.fields) { |
||||
|
const fieldForm = new FormGroup({}); |
||||
|
|
||||
|
const defaultValue = field.defaultValue(); |
||||
|
|
||||
|
if (field.isLocalizable) { |
||||
|
for (let language of this.languages.values) { |
||||
|
fieldForm.setControl(language.iso2Code, new FormControl(defaultValue, field.createValidators(language.isOptional))); |
||||
|
} |
||||
|
} else { |
||||
|
fieldForm.setControl(fieldInvariant, new FormControl(defaultValue, field.createValidators(false))); |
||||
|
} |
||||
|
|
||||
|
this.form.setControl(field.name, fieldForm); |
||||
|
} |
||||
|
|
||||
|
this.enableContentForm(); |
||||
|
} |
||||
|
|
||||
|
public submitCompleted(newValue?: any) { |
||||
|
super.submitCompleted(newValue); |
||||
|
|
||||
|
this.enableContentForm(); |
||||
|
} |
||||
|
|
||||
|
public submitFailed(error?: string | ErrorDto) { |
||||
|
super.submitFailed(error); |
||||
|
|
||||
|
this.enableContentForm(); |
||||
|
} |
||||
|
|
||||
|
private enableContentForm() { |
||||
|
if (this.schema.fields.length === 0) { |
||||
|
this.form.enable(); |
||||
|
} else { |
||||
|
for (const field of this.schema.fields) { |
||||
|
const fieldForm = this.form.controls[field.name]; |
||||
|
|
||||
|
if (field.isDisabled) { |
||||
|
fieldForm.disable(); |
||||
|
} else { |
||||
|
fieldForm.enable(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export class PatchContentForm extends Form<FormGroup> { |
||||
|
constructor( |
||||
|
private readonly schema: SchemaDetailsDto, |
||||
|
private readonly language: AppLanguageDto |
||||
|
) { |
||||
|
super(new FormGroup({})); |
||||
|
|
||||
|
for (let field of this.schema.listFields) { |
||||
|
if (field.properties && field.properties['inlineEditable']) { |
||||
|
this.form.setControl(field.name, new FormControl(undefined, field.createValidators(this.language.isOptional))); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public submit() { |
||||
|
const result = super.submit(); |
||||
|
|
||||
|
if (result) { |
||||
|
const request = {}; |
||||
|
|
||||
|
for (let field of this.schema.listFields) { |
||||
|
if (field.properties['inlineEditable']) { |
||||
|
const value = result[field.name]; |
||||
|
|
||||
|
if (field.isLocalizable) { |
||||
|
request[field.name] = { [this.language.iso2Code]: value }; |
||||
|
} else { |
||||
|
request[field.name] = { iv: value }; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return request; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
interface Snapshot { |
||||
|
contents: ImmutableArray<ContentDto>; |
||||
|
contentsPager: Pager; |
||||
|
contentsQuery?: string; |
||||
|
|
||||
|
isLoaded?: boolean; |
||||
|
isArchive?: boolean; |
||||
|
|
||||
|
selectedContent?: ContentDto | null; |
||||
|
} |
||||
|
|
||||
|
export abstract class ContentsStateBase extends State<Snapshot> { |
||||
|
public selectedContent = |
||||
|
this.changes.map(x => x.selectedContent) |
||||
|
.distinctUntilChanged(); |
||||
|
|
||||
|
public contents = |
||||
|
this.changes.map(x => x.contents) |
||||
|
.distinctUntilChanged(); |
||||
|
|
||||
|
public contentsPager = |
||||
|
this.changes.map(x => x.contentsPager) |
||||
|
.distinctUntilChanged(); |
||||
|
|
||||
|
public contentsQuery = |
||||
|
this.changes.map(x => x.contentsQuery) |
||||
|
.distinctUntilChanged(); |
||||
|
|
||||
|
public isLoaded = |
||||
|
this.changes.map(x => !!x.isLoaded) |
||||
|
.distinctUntilChanged(); |
||||
|
|
||||
|
public isArchive = |
||||
|
this.changes.map(x => !!x.isArchive) |
||||
|
.distinctUntilChanged(); |
||||
|
|
||||
|
constructor( |
||||
|
private readonly appsState: AppsState, |
||||
|
private readonly authState: AuthService, |
||||
|
private readonly contentsService: ContentsService, |
||||
|
private readonly dialogs: DialogService |
||||
|
) { |
||||
|
super({ contents: ImmutableArray.of(), contentsPager: new Pager(0) }); |
||||
|
} |
||||
|
|
||||
|
public select(id: string | null): Observable<ContentDto | null> { |
||||
|
return this.loadContent(id) |
||||
|
.do(content => { |
||||
|
this.next(s => { |
||||
|
const contents = content ? s.contents.replaceBy('id', content) : s.contents; |
||||
|
|
||||
|
return { ...s, selectedContent: content, contents }; |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private loadContent(id: string | null) { |
||||
|
return !id ? |
||||
|
Observable.of(null) : |
||||
|
Observable.of(this.snapshot.contents.find(x => x.id === id)) |
||||
|
.switchMap(content => { |
||||
|
if (!content) { |
||||
|
return this.contentsService.getContent(this.appName, this.schemaName, id).catch(() => Observable.of(null)); |
||||
|
} else { |
||||
|
return Observable.of(content); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public load(notifyLoad = false): Observable<any> { |
||||
|
return this.contentsService.getContents(this.appName, this.schemaName, |
||||
|
this.snapshot.contentsPager.pageSize, |
||||
|
this.snapshot.contentsPager.skip, |
||||
|
this.snapshot.contentsQuery, undefined, |
||||
|
this.snapshot.isArchive) |
||||
|
.do(dtos => { |
||||
|
if (notifyLoad) { |
||||
|
this.dialogs.notifyInfo('Contents reloaded.'); |
||||
|
} |
||||
|
|
||||
|
return this.next(s => { |
||||
|
const contents = ImmutableArray.of(dtos.items); |
||||
|
const contentsPager = s.contentsPager.setCount(dtos.total); |
||||
|
|
||||
|
let selectedContent = s.selectedContent; |
||||
|
|
||||
|
if (selectedContent) { |
||||
|
selectedContent = contents.find(x => x.id === selectedContent!.id) || selectedContent; |
||||
|
} |
||||
|
|
||||
|
return { ...s, contents, contentsPager, selectedContent, isLoaded: true }; |
||||
|
}); |
||||
|
}) |
||||
|
.notify(this.dialogs); |
||||
|
} |
||||
|
|
||||
|
public create(request: any, publish: boolean, now?: DateTime) { |
||||
|
return this.contentsService.postContent(this.appName, this.schemaName, request, publish) |
||||
|
.do(dto => { |
||||
|
this.dialogs.notifyInfo('Contents created successfully.'); |
||||
|
|
||||
|
return this.next(s => { |
||||
|
const contents = s.contents.pushFront(dto); |
||||
|
const contentsPager = s.contentsPager.incrementCount(); |
||||
|
|
||||
|
return { ...s, contents, contentsPager }; |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public changeStatus(contents: ContentDto[], action: string, dueTime: string | null): Observable<any> { |
||||
|
return Observable.forkJoin( |
||||
|
contents.map(c => |
||||
|
this.contentsService.changeContentStatus(this.appName, this.schemaName, c.id, action, dueTime, c.version) |
||||
|
.catch(error => Observable.of(error)))) |
||||
|
.do(results => { |
||||
|
const error = results.find(x => !!x.error); |
||||
|
|
||||
|
if (error) { |
||||
|
this.dialogs.notifyError(error); |
||||
|
} |
||||
|
|
||||
|
return Observable.of(error); |
||||
|
}) |
||||
|
.switchMap(() => this.load()); |
||||
|
} |
||||
|
|
||||
|
public delete(contents: ContentDto[]): Observable<any> { |
||||
|
return Observable.forkJoin( |
||||
|
contents.map(c => |
||||
|
this.contentsService.deleteContent(this.appName, this.schemaName, c.id, c.version) |
||||
|
.catch(error => Observable.of(error)))) |
||||
|
.do(results => { |
||||
|
const error = results.find(x => !!x.error); |
||||
|
|
||||
|
if (error) { |
||||
|
this.dialogs.notifyError(error); |
||||
|
} |
||||
|
|
||||
|
return Observable.of(error); |
||||
|
}) |
||||
|
.switchMap(() => this.load()); |
||||
|
} |
||||
|
|
||||
|
public update(content: ContentDto, request: any, now?: DateTime): Observable<any> { |
||||
|
return this.contentsService.putContent(this.appName, this.schemaName, content.id, request, content.version) |
||||
|
.do(dto => { |
||||
|
this.dialogs.notifyInfo('Contents updated successfully.'); |
||||
|
|
||||
|
this.replaceContent(updateData(content, request, this.user, dto.version, now)); |
||||
|
}) |
||||
|
.notify(this.dialogs); |
||||
|
} |
||||
|
|
||||
|
public patch(content: ContentDto, request: any, now?: DateTime): Observable<any> { |
||||
|
return this.contentsService.patchContent(this.appName, this.schemaName, content.id, request, content.version) |
||||
|
.do(dto => { |
||||
|
this.dialogs.notifyInfo('Contents updated successfully.'); |
||||
|
|
||||
|
this.replaceContent(updateData(content, request, this.user, dto.version, now)); |
||||
|
}) |
||||
|
.notify(this.dialogs); |
||||
|
} |
||||
|
|
||||
|
private replaceContent(content: ContentDto) { |
||||
|
return this.next(s => { |
||||
|
const contents = s.contents.replaceBy('id', content); |
||||
|
const selectedContent = s.selectedContent && s.selectedContent.id === content.id ? content : s.selectedContent; |
||||
|
|
||||
|
return { ...s, contents, selectedContent }; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public goArchive(isArchive: boolean): Observable<any> { |
||||
|
this.next(s => ({ ...s, contentsPager: new Pager(0), contentsQuery: undefined, isArchive })); |
||||
|
|
||||
|
return this.load(); |
||||
|
} |
||||
|
|
||||
|
public search(query: string): Observable<any> { |
||||
|
this.next(s => ({ ...s, contentsPager: new Pager(0), contentsQuery: query })); |
||||
|
|
||||
|
return this.load(); |
||||
|
} |
||||
|
|
||||
|
public goNext(): Observable<any> { |
||||
|
this.next(s => ({ ...s, contentsPager: s.contentsPager.goNext() })); |
||||
|
|
||||
|
return this.load(); |
||||
|
} |
||||
|
|
||||
|
public goPrev(): Observable<any> { |
||||
|
this.next(s => ({ ...s, contentsPager: s.contentsPager.goPrev() })); |
||||
|
|
||||
|
return this.load(); |
||||
|
} |
||||
|
|
||||
|
public loadVersion(content: ContentDto, version: Version): Observable<Versioned<any>> { |
||||
|
return this.contentsService.getVersionData(this.appName, this.schemaName, content.id, new Version(version.toString())) |
||||
|
.notify(this.dialogs); |
||||
|
} |
||||
|
|
||||
|
private get appName() { |
||||
|
return this.appsState.appName; |
||||
|
} |
||||
|
|
||||
|
private get user() { |
||||
|
return this.authState.user!.token; |
||||
|
} |
||||
|
|
||||
|
protected abstract get schemaName(): string; |
||||
|
} |
||||
|
|
||||
|
@Injectable() |
||||
|
export class ContentsState extends ContentsStateBase { |
||||
|
constructor(appsState: AppsState, authState: AuthService, contentsService: ContentsService, dialogs: DialogService, |
||||
|
private readonly schemasState: SchemasState |
||||
|
) { |
||||
|
super(appsState, authState, contentsService, dialogs); |
||||
|
} |
||||
|
|
||||
|
protected get schemaName() { |
||||
|
return this.schemasState.schemaName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Injectable() |
||||
|
export class ManualContentsState extends ContentsStateBase { |
||||
|
public schema: SchemaDto; |
||||
|
|
||||
|
constructor( |
||||
|
appsState: AppsState, authState: AuthService, contentsService: ContentsService, dialogs: DialogService |
||||
|
) { |
||||
|
super(appsState, authState, contentsService, dialogs); |
||||
|
} |
||||
|
|
||||
|
protected get schemaName() { |
||||
|
return this.schema.name; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const updateData = (content: ContentDto, data: any, user: string, version: Version, now?: DateTime) => |
||||
|
new ContentDto( |
||||
|
content.id, |
||||
|
content.status, |
||||
|
content.createdBy, user, |
||||
|
content.created, now || DateTime.now(), |
||||
|
content.scheduledTo, |
||||
|
content.scheduledBy, |
||||
|
content.scheduledAt, |
||||
|
data, |
||||
|
version); |
||||
Loading…
Reference in new issue