|
|
|
@ -52,7 +52,7 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD |
|
|
|
|
|
|
|
public formContext: any; |
|
|
|
|
|
|
|
public content: ContentDto; |
|
|
|
public content?: ContentDto | null; |
|
|
|
public contentVersion: Version | null; |
|
|
|
public contentForm: EditContentForm; |
|
|
|
public contentFormCompare: EditContentForm | null = null; |
|
|
|
@ -118,9 +118,7 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD |
|
|
|
const autosaved = this.autoSaveService.get(this.autoSaveKey); |
|
|
|
|
|
|
|
if (content) { |
|
|
|
this.content = content; |
|
|
|
|
|
|
|
this.loadContent(this.content.dataDraft, true); |
|
|
|
this.loadContent(content.dataDraft, true); |
|
|
|
} |
|
|
|
|
|
|
|
if (autosaved && this.isOtherContent(content) && this.contentForm.hasChanges(autosaved)) { |
|
|
|
@ -133,6 +131,8 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
this.content = content; |
|
|
|
})); |
|
|
|
|
|
|
|
this.own( |
|
|
|
@ -237,33 +237,45 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD |
|
|
|
} |
|
|
|
|
|
|
|
public discardChanges() { |
|
|
|
if (this.content) { |
|
|
|
this.contentsState.discardDraft(this.content); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public delete() { |
|
|
|
if (this.content) { |
|
|
|
this.contentsState.deleteMany([this.content]).pipe(onErrorResumeNext()) |
|
|
|
.subscribe(() => { |
|
|
|
this.back(); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public publishChanges() { |
|
|
|
const content = this.content; |
|
|
|
|
|
|
|
if (content) { |
|
|
|
this.checkPendingChanges('publish your changes').pipe( |
|
|
|
filter(x => !!x), |
|
|
|
switchMap(_ => this.dueTimeSelector.selectDueTime(status)), |
|
|
|
switchMap(d => this.contentsState.publishDraft(this.content, d)), |
|
|
|
switchMap(d => this.contentsState.publishDraft(content, d)), |
|
|
|
onErrorResumeNext()) |
|
|
|
.subscribe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public changeStatus(status: string) { |
|
|
|
const content = this.content; |
|
|
|
|
|
|
|
if (content) { |
|
|
|
this.checkPendingChanges('change the status').pipe( |
|
|
|
filter(x => !!x), |
|
|
|
switchMap(_ => this.dueTimeSelector.selectDueTime(status)), |
|
|
|
switchMap(d => this.contentsState.changeStatus(this.content, status, d)), |
|
|
|
switchMap(d => this.contentsState.changeStatus(content, status, d)), |
|
|
|
onErrorResumeNext()) |
|
|
|
.subscribe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private checkPendingChanges(action: string) { |
|
|
|
return this.contentForm.hasChanged() ? |
|
|
|
@ -276,12 +288,14 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD |
|
|
|
} |
|
|
|
|
|
|
|
private loadVersion(version: Version | null, compare: boolean) { |
|
|
|
if (!this.content || version === null || version.eq(this.content.version)) { |
|
|
|
const content = this.content; |
|
|
|
|
|
|
|
if (!content || version === null || version.eq(content.version)) { |
|
|
|
this.contentFormCompare = null; |
|
|
|
this.contentVersion = null; |
|
|
|
this.loadContent(this.content.dataDraft, true); |
|
|
|
this.loadContent(content ? content.dataDraft : {}, true); |
|
|
|
} else { |
|
|
|
this.contentsState.loadVersion(this.content, version) |
|
|
|
this.contentsState.loadVersion(content, version) |
|
|
|
.subscribe(dto => { |
|
|
|
if (compare) { |
|
|
|
this.contentFormCompare = new EditContentForm(this.languages, this.schema); |
|
|
|
@ -289,7 +303,7 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD |
|
|
|
this.contentFormCompare.load(dto.payload); |
|
|
|
this.contentFormCompare.setEnabled(false); |
|
|
|
|
|
|
|
this.loadContent(this.content.dataDraft, false); |
|
|
|
this.loadContent(content.dataDraft, false); |
|
|
|
} else { |
|
|
|
this.contentFormCompare = null; |
|
|
|
|
|
|
|
|