|
|
|
@ -12,7 +12,7 @@ import { Subscription } from 'rxjs'; |
|
|
|
|
|
|
|
import { |
|
|
|
ContentCreated, |
|
|
|
ContentDeleted, |
|
|
|
ContentRemoved, |
|
|
|
ContentUpdated |
|
|
|
} from './../messages'; |
|
|
|
|
|
|
|
@ -57,6 +57,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy |
|
|
|
public languageParameter: string; |
|
|
|
|
|
|
|
public isReadOnly = false; |
|
|
|
public isArchive = false; |
|
|
|
|
|
|
|
public columnWidth: number; |
|
|
|
|
|
|
|
@ -112,13 +113,6 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy |
|
|
|
return { content, schemaId: this.schema.id }; |
|
|
|
} |
|
|
|
|
|
|
|
public search() { |
|
|
|
this.contentsQuery = this.contentsFilter.value; |
|
|
|
this.contentsPager = new Pager(0); |
|
|
|
|
|
|
|
this.load(); |
|
|
|
} |
|
|
|
|
|
|
|
public publishContent(content: ContentDto) { |
|
|
|
this.appNameOnce() |
|
|
|
.switchMap(app => this.contentsService.publishContent(app, this.schema.name, content.id, content.version)) |
|
|
|
@ -139,14 +133,35 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public archiveContent(content: ContentDto) { |
|
|
|
this.appNameOnce() |
|
|
|
.switchMap(app => this.contentsService.archiveContent(app, this.schema.name, content.id, content.version)) |
|
|
|
.subscribe(() => { |
|
|
|
content = content.archive(this.authService.user!.token); |
|
|
|
|
|
|
|
this.removeContent(content); |
|
|
|
}, error => { |
|
|
|
this.notifyError(error); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public restoreContent(content: ContentDto) { |
|
|
|
this.appNameOnce() |
|
|
|
.switchMap(app => this.contentsService.restoreContent(app, this.schema.name, content.id, content.version)) |
|
|
|
.subscribe(() => { |
|
|
|
content = content.restore(this.authService.user!.token); |
|
|
|
|
|
|
|
this.removeContent(content); |
|
|
|
}, error => { |
|
|
|
this.notifyError(error); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public deleteContent(content: ContentDto) { |
|
|
|
this.appNameOnce() |
|
|
|
.switchMap(app => this.contentsService.deleteContent(app, this.schema.name, content.id, content.version)) |
|
|
|
.subscribe(() => { |
|
|
|
this.contentItems = this.contentItems.removeAll(x => x.id === content.id); |
|
|
|
this.contentsPager = this.contentsPager.decrementCount(); |
|
|
|
|
|
|
|
this.emitContentDeleted(content); |
|
|
|
this.removeContent(content); |
|
|
|
}, error => { |
|
|
|
this.notifyError(error); |
|
|
|
}); |
|
|
|
@ -154,7 +169,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy |
|
|
|
|
|
|
|
public load(showInfo = false) { |
|
|
|
this.appNameOnce() |
|
|
|
.switchMap(app => this.contentsService.getContents(app, this.schema.name, this.contentsPager.pageSize, this.contentsPager.skip, this.contentsQuery)) |
|
|
|
.switchMap(app => this.contentsService.getContents(app, this.schema.name, this.contentsPager.pageSize, this.contentsPager.skip, this.contentsQuery, null, this.isArchive)) |
|
|
|
.subscribe(dtos => { |
|
|
|
this.contentItems = ImmutableArray.of(dtos.items); |
|
|
|
this.contentsPager = this.contentsPager.setCount(dtos.total); |
|
|
|
@ -167,8 +182,22 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public selectLanguage(language: AppLanguageDto) { |
|
|
|
this.languageSelected = language; |
|
|
|
public updateArchive(isArchive: boolean) { |
|
|
|
this.contentsQuery = this.contentsFilter.value; |
|
|
|
this.contentsPager = new Pager(0); |
|
|
|
|
|
|
|
this.isArchive = isArchive; |
|
|
|
|
|
|
|
this.searchModal.hide(); |
|
|
|
|
|
|
|
this.load(); |
|
|
|
} |
|
|
|
|
|
|
|
public search() { |
|
|
|
this.contentsQuery = this.contentsFilter.value; |
|
|
|
this.contentsPager = new Pager(0); |
|
|
|
|
|
|
|
this.load(); |
|
|
|
} |
|
|
|
|
|
|
|
public goNext() { |
|
|
|
@ -183,8 +212,12 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy |
|
|
|
this.load(); |
|
|
|
} |
|
|
|
|
|
|
|
private emitContentDeleted(content: ContentDto) { |
|
|
|
this.messageBus.emit(new ContentDeleted(content)); |
|
|
|
public selectLanguage(language: AppLanguageDto) { |
|
|
|
this.languageSelected = language; |
|
|
|
} |
|
|
|
|
|
|
|
private emitContentRemoved(content: ContentDto) { |
|
|
|
this.messageBus.emit(new ContentRemoved(content)); |
|
|
|
} |
|
|
|
|
|
|
|
private resetContents() { |
|
|
|
@ -196,6 +229,13 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy |
|
|
|
this.loadFields(); |
|
|
|
} |
|
|
|
|
|
|
|
private removeContent(content: ContentDto) { |
|
|
|
this.contentItems = this.contentItems.removeAll(x => x.id === content.id); |
|
|
|
this.contentsPager = this.contentsPager.decrementCount(); |
|
|
|
|
|
|
|
this.emitContentRemoved(content); |
|
|
|
} |
|
|
|
|
|
|
|
private loadFields() { |
|
|
|
this.contentFields = this.schema.fields.filter(x => x.properties.isListField); |
|
|
|
|
|
|
|
@ -203,6 +243,10 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy |
|
|
|
this.contentFields = [this.schema.fields[0]]; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.contentFields.length === 0) { |
|
|
|
this.contentFields = [<any>{}]; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.contentFields.length > 0) { |
|
|
|
this.columnWidth = 100 / this.contentFields.length; |
|
|
|
} else { |
|
|
|
|