Skip to content

Commit

Permalink
Load new widget type contentstudio.preview #7868
Browse files Browse the repository at this point in the history
  • Loading branch information
pmi committed Oct 18, 2024
1 parent 015b637 commit 56debc7
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {IssueType} from '../issue/IssueType';
import {MenuButton} from '@enonic/lib-admin-ui/ui/button/MenuButton';
import {Action} from '@enonic/lib-admin-ui/ui/Action';
import {ContentId} from '../content/ContentId';
import {GetWidgetsByInterfaceRequest} from '../resource/GetWidgetsByInterfaceRequest';
import {Widget} from '@enonic/lib-admin-ui/content/Widget';

export class ContentItemPreviewToolbar
extends ContentStatusToolbar {
Expand All @@ -21,6 +23,7 @@ export class ContentItemPreviewToolbar
private mainAction: Action;
private issueActionsList: Action[];
private debouncedFetch: (id: ContentId) => void;
private liveViewWidgets: Promise<Widget[]>;

constructor() {
super({className: 'content-item-preview-toolbar'});
Expand All @@ -29,6 +32,8 @@ export class ContentItemPreviewToolbar
protected initElements(): void {
super.initElements();

this.liveViewWidgets = this.fetchLiveViewWidgets();

this.mainAction = new Action();
this.issueButton = new MenuButton(this.mainAction);
}
Expand Down Expand Up @@ -64,12 +69,28 @@ export class ContentItemPreviewToolbar

doRender(): Q.Promise<boolean> {
return super.doRender().then(rendered => {

this.liveViewWidgets.then((widgets: Widget[]) => {
console.log('Live view widgets:', widgets);
});

this.issueButton.addClass('transparent');
this.addContainer(this.issueButton, this.issueButton.getChildControls());
return rendered;
});
}

private async fetchLiveViewWidgets(): Promise<Widget[]> {
return new GetWidgetsByInterfaceRequest('contentstudio.preview').sendAndParse()
.then((widgets: Widget[]) => {
return widgets.sort((a: Widget, b: Widget) => a.getConfig()['order'] - b.getConfig()['order']);
})
.catch((e) => {
DefaultErrorHandler.handle(e);
return [];
});
}


setItem(item: ContentSummaryAndCompareStatus): void {
if (this.getItem() !== item) {
Expand All @@ -86,7 +107,7 @@ export class ContentItemPreviewToolbar
}

protected foldOrExpand(): void {
//
//
}

private fetchIssues(id: ContentId): Q.Promise<void> {
Expand Down

0 comments on commit 56debc7

Please sign in to comment.