mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
CE-1115 Moving widget helpContent to be map of list, to support multiple roles per slot (e.g., view screen vs edit screen)
This commit is contained in:
@ -149,8 +149,7 @@ public class QInstanceHelpContentManager
|
||||
}
|
||||
else if(StringUtils.hasContent(widgetName))
|
||||
{
|
||||
processHelpContentForWidget(key, widgetName, slotName, helpContent);
|
||||
|
||||
processHelpContentForWidget(key, widgetName, slotName, roles, helpContent);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
@ -252,7 +251,7 @@ public class QInstanceHelpContentManager
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private static void processHelpContentForWidget(String key, String widgetName, String slotName, QHelpContent helpContent)
|
||||
private static void processHelpContentForWidget(String key, String widgetName, String slotName, Set<HelpRole> roles, QHelpContent helpContent)
|
||||
{
|
||||
QWidgetMetaDataInterface widget = QContext.getQInstance().getWidget(widgetName);
|
||||
if(!StringUtils.hasContent(slotName))
|
||||
@ -265,22 +264,14 @@ public class QInstanceHelpContentManager
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<String, QHelpContent> widgetHelpContent = widget.getHelpContent();
|
||||
if(widgetHelpContent == null)
|
||||
{
|
||||
widgetHelpContent = new HashMap<>();
|
||||
}
|
||||
|
||||
if(helpContent != null)
|
||||
{
|
||||
widgetHelpContent.put(slotName, helpContent);
|
||||
widget.withHelpContent(slotName, helpContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
widgetHelpContent.remove(slotName);
|
||||
widget.removeHelpContent(slotName, roles);
|
||||
}
|
||||
|
||||
widget.setHelpContent(widgetHelpContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,15 @@ package com.kingsrook.qqq.backend.core.model.metadata.dashboard;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import com.kingsrook.qqq.backend.core.instances.QInstanceHelpContentManager;
|
||||
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.WidgetType;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.help.HelpRole;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.help.QHelpContent;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.permissions.QPermissionRules;
|
||||
@ -61,7 +65,7 @@ public class QWidgetMetaData implements QWidgetMetaDataInterface
|
||||
|
||||
protected Map<String, QIcon> icons;
|
||||
|
||||
protected Map<String, QHelpContent> helpContent;
|
||||
protected Map<String, List<QHelpContent>> helpContent;
|
||||
|
||||
protected Map<String, Serializable> defaultValues = new LinkedHashMap<>();
|
||||
|
||||
@ -691,10 +695,11 @@ public class QWidgetMetaData implements QWidgetMetaDataInterface
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for helpContent
|
||||
*******************************************************************************/
|
||||
public Map<String, QHelpContent> getHelpContent()
|
||||
public Map<String, List<QHelpContent>> getHelpContent()
|
||||
{
|
||||
return (this.helpContent);
|
||||
}
|
||||
@ -704,7 +709,7 @@ public class QWidgetMetaData implements QWidgetMetaDataInterface
|
||||
/*******************************************************************************
|
||||
** Setter for helpContent
|
||||
*******************************************************************************/
|
||||
public void setHelpContent(Map<String, QHelpContent> helpContent)
|
||||
public void setHelpContent(Map<String, List<QHelpContent>> helpContent)
|
||||
{
|
||||
this.helpContent = helpContent;
|
||||
}
|
||||
@ -714,11 +719,49 @@ public class QWidgetMetaData implements QWidgetMetaDataInterface
|
||||
/*******************************************************************************
|
||||
** Fluent setter for helpContent
|
||||
*******************************************************************************/
|
||||
public QWidgetMetaData withHelpContent(Map<String, QHelpContent> helpContent)
|
||||
public QWidgetMetaData withHelpContent(Map<String, List<QHelpContent>> helpContent)
|
||||
{
|
||||
this.helpContent = helpContent;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for adding 1 helpContent (for a slot)
|
||||
*******************************************************************************/
|
||||
public QWidgetMetaData withHelpContent(String slot, QHelpContent helpContent)
|
||||
{
|
||||
if(this.helpContent == null)
|
||||
{
|
||||
this.helpContent = new HashMap<>();
|
||||
}
|
||||
|
||||
List<QHelpContent> listForSlot = this.helpContent.computeIfAbsent(slot, (k) -> new ArrayList<>());
|
||||
QInstanceHelpContentManager.putHelpContentInList(helpContent, listForSlot);
|
||||
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** remove a helpContent for a slot based on its set of roles
|
||||
*******************************************************************************/
|
||||
public void removeHelpContent(String slot, Set<HelpRole> roles)
|
||||
{
|
||||
if(this.helpContent == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<QHelpContent> listForSlot = this.helpContent.get(slot);
|
||||
if(listForSlot == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QInstanceHelpContentManager.removeHelpContentByRoleSetFromList(roles, listForSlot);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,10 +25,12 @@ package com.kingsrook.qqq.backend.core.model.metadata.dashboard;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.TopLevelMetaDataInterface;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.help.HelpRole;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.help.QHelpContent;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.permissions.MetaDataWithPermissionRules;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.permissions.QPermissionRules;
|
||||
@ -235,7 +237,7 @@ public interface QWidgetMetaDataInterface extends MetaDataWithPermissionRules, T
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
default Map<String, QHelpContent> getHelpContent()
|
||||
default Map<String, List<QHelpContent>> getHelpContent()
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
@ -244,11 +246,29 @@ public interface QWidgetMetaDataInterface extends MetaDataWithPermissionRules, T
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
default void setHelpContent(Map<String, QHelpContent> helpContent)
|
||||
default void setHelpContent(Map<String, List<QHelpContent>> helpContent)
|
||||
{
|
||||
LOG.debug("Setting help content in a widgetMetaData type that doesn't support it (because it didn't override the getter/setter)");
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
default QWidgetMetaDataInterface withHelpContent(String slot, QHelpContent helpContent)
|
||||
{
|
||||
LOG.debug("Setting help content in a widgetMetaData type that doesn't support it (because it didn't override the getter/setter)");
|
||||
return (this);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
** remove a helpContent for a slot based on its set of roles
|
||||
*******************************************************************************/
|
||||
default void removeHelpContent(String slot, Set<HelpRole> roles)
|
||||
{
|
||||
LOG.debug("Setting help content in a widgetMetaData type that doesn't support it (because it didn't override the getter/setter)");
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
@ -59,9 +59,9 @@ public class QFrontendWidgetMetaData
|
||||
private boolean showReloadButton = false;
|
||||
private boolean showExportButton = false;
|
||||
|
||||
protected Map<String, QIcon> icons;
|
||||
protected Map<String, QHelpContent> helpContent;
|
||||
protected Map<String, Serializable> defaultValues;
|
||||
protected Map<String, QIcon> icons;
|
||||
protected Map<String, List<QHelpContent>> helpContent;
|
||||
protected Map<String, Serializable> defaultValues;
|
||||
|
||||
private final boolean hasPermission;
|
||||
|
||||
@ -273,7 +273,7 @@ public class QFrontendWidgetMetaData
|
||||
** Getter for helpContent
|
||||
**
|
||||
*******************************************************************************/
|
||||
public Map<String, QHelpContent> getHelpContent()
|
||||
public Map<String, List<QHelpContent>> getHelpContent()
|
||||
{
|
||||
return helpContent;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ class QInstanceHelpContentManagerTest extends BaseTest
|
||||
// now - post-insert customizer should have automatically added help content to the instance //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
assertTrue(widget.getHelpContent().containsKey("label"));
|
||||
assertEquals("i need somebody", widget.getHelpContent().get("label").getContent());
|
||||
assertEquals("i need somebody", widget.getHelpContent().get("label").get(0).getContent());
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user