From 50faac760e3a603c5506991b3bbe08192504f99f Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Tue, 29 Oct 2024 13:23:00 +0100 Subject: [PATCH] fix: Preserve Data when duplicating SNV Portlet - MEED-7687 - Meeds-io/MIPs#165 (#1188) Prior to this change, when the SNV Portlet doesn't have been initialized/displayed yet in a page, like the default Space Templates, the 'data.init' preference isn't used to initialize the portlet yet and thus when duplicating the page template, the 'data.init' has to be reused instead of generated only when the CMS portlet is initialized. --- .../layout/renderer/NoteSingleViewRenderPlugin.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/notes-service/src/main/java/io/meeds/notes/plugin/layout/renderer/NoteSingleViewRenderPlugin.java b/notes-service/src/main/java/io/meeds/notes/plugin/layout/renderer/NoteSingleViewRenderPlugin.java index 871a05db81..49a004d23f 100644 --- a/notes-service/src/main/java/io/meeds/notes/plugin/layout/renderer/NoteSingleViewRenderPlugin.java +++ b/notes-service/src/main/java/io/meeds/notes/plugin/layout/renderer/NoteSingleViewRenderPlugin.java @@ -54,7 +54,13 @@ public String getPortletName() { public List generatePreferences(Application application, Portlet preferences) { String settingName = getCmsSettingName(preferences); if (StringUtils.isBlank(settingName)) { - return Collections.emptyList(); + if (preferences != null && preferences.getPreference(DATA_INIT_PREFERENCE_NAME) != null) { + return Collections.singletonList(new PortletInstancePreference(DATA_INIT_PREFERENCE_NAME, + preferences.getPreference(DATA_INIT_PREFERENCE_NAME) + .getValue())); + } else { + return Collections.emptyList(); + } } NotePageData notePageData = notePageViewService.getNotePageData(settingName); return Collections.singletonList(new PortletInstancePreference(DATA_INIT_PREFERENCE_NAME,