Skip to content

Commit

Permalink
Publishing Report widget stops rendering after switching from Archive…
Browse files Browse the repository at this point in the history
… to Content #1111

-Need to differentiate containers of the widget in studio and archive by using separate container ids
  • Loading branch information
ashklianko committed Oct 30, 2023
1 parent f9f6510 commit e2c1493
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<widget id="cs-plus-widget-publish-report">
<widget id="{{containerId}}">
{{#isNoIdMode}}
<div class="error">Select an item - and we'll show you the details!</div>
{{/isNoIdMode}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const contentLib = require('/lib/xp/content');
const contextLib = require('/lib/xp/context');
const mustache = require('/lib/mustache');


const defaultContainerId = 'cs-plus-widget-publish-report';

const handleGet = (req) => {
return renderWidgetView(req);
}
Expand All @@ -19,7 +22,8 @@ const getContentId = (req) => {

const makeParamsNoContentId = () => {
return {
isNoIdMode: true
isNoIdMode: true,
containerId: defaultContainerId,
}
}

Expand All @@ -37,6 +41,7 @@ const makeParams = (content, isArchived) => {
publishFirst: content.publish.first,
isNormalMode: !!content.publish.first,
isNoPublishMode: !content.publish.first,
containerId: defaultContainerId + (isArchived ? '-archived' : ''),
isArchived
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/assets/js/widgets/publish-report/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ void (async () => {

const contentId = document.currentScript.getAttribute('data-content-id');
const publishFirstAsString = document.currentScript.getAttribute('data-publish-first');
const isArchived = document.currentScript.getAttribute('data-archived');
const isArchivedAttrValue = document.currentScript.getAttribute('data-archived');
const isArchived = Boolean(isArchivedAttrValue == 'true');

await CONFIG.init(configServiceUrl);
await i18nInit(CONFIG.getString('services.i18nUrlStudio'));
await i18nAdd(CONFIG.getString('services.i18nUrl'));

const widgetContainer = document.getElementById(AppHelper.getPublishReportWidgetClass());
const containerId = AppHelper.getPublishReportWidgetClass() + (isArchived ? '-archived' : '');
const widgetContainer = document.getElementById(containerId);

if (widgetContainer) {
const widgetContainerEl = Element.fromHtmlElement((widgetContainer), true);
Expand All @@ -27,7 +29,7 @@ void (async () => {
const widget: PublishReportWidget =
PublishReportWidget.get()
.setPublishFirstDateString(publishFirstAsString)
.setIsContentArchived(Boolean(isArchived == 'true'));
.setIsContentArchived(isArchived);

widget.setContentId(contentId);

Expand Down

0 comments on commit e2c1493

Please sign in to comment.