[Sitemap] Accept an optional icon for each value/label mapping (#3809)
* [Sitemap] Accept an optional icon for each value/label mapping When set by the user, the icon can be used by UIs for switch element with mappings to render a button with the icon rather than the label. Related to #3441 Signed-off-by: Laurent Garnier <lg.hc@free.fr>pull/3819/head
parent
fffa968263
commit
f7d176570c
|
@ -134,6 +134,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
* @author Laurent Garnier - Added support for icon color
|
||||
* @author Mark Herwege - Added pattern and unit fields
|
||||
* @author Laurent Garnier - Added support for new sitemap element Buttongrid
|
||||
* @author Laurent Garnier - Added icon field for mappings used for switch element
|
||||
*/
|
||||
@Component(service = { RESTResource.class, EventSubscriber.class })
|
||||
@JaxrsResource
|
||||
|
@ -558,6 +559,7 @@ public class SitemapResource
|
|||
MappingDTO mappingBean = new MappingDTO();
|
||||
mappingBean.command = mapping.getCmd();
|
||||
mappingBean.label = mapping.getLabel();
|
||||
mappingBean.icon = mapping.getIcon();
|
||||
bean.mappings.add(mappingBean);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ Button:
|
|||
position=INT ':' cmd=Command '=' label=(ID | STRING) ('=' icon=Icon)?;
|
||||
|
||||
Mapping:
|
||||
cmd=Command '=' label=(ID | STRING);
|
||||
cmd=Command '=' label=(ID | STRING) ('=' icon=Icon)?;
|
||||
|
||||
VisibilityRule:
|
||||
(item=ID) (condition=('==' | '>' | '<' | '>=' | '<=' | '!=')) (sign=('-' | '+'))? (state=XState);
|
||||
|
|
|
@ -79,6 +79,7 @@ import org.slf4j.LoggerFactory;
|
|||
* @author Yannick Schaus - Initial contribution
|
||||
* @author Laurent Garnier - icon color support for all widgets
|
||||
* @author Laurent Garnier - Added support for new element Buttongrid
|
||||
* @author Laurent Garnier - Added icon field for mappings
|
||||
*/
|
||||
@NonNullByDefault
|
||||
@Component(service = SitemapProvider.class)
|
||||
|
@ -331,11 +332,14 @@ public class UIComponentSitemapProvider implements SitemapProvider, RegistryChan
|
|||
if (component.getConfig().get("mappings") instanceof Collection<?>) {
|
||||
for (Object sourceMapping : (Collection<?>) component.getConfig().get("mappings")) {
|
||||
if (sourceMapping instanceof String) {
|
||||
String cmd = sourceMapping.toString().split("=")[0].trim();
|
||||
String label = sourceMapping.toString().split("=")[1].trim();
|
||||
String[] splitMapping = sourceMapping.toString().split("=");
|
||||
String cmd = splitMapping[0].trim();
|
||||
String label = splitMapping[1].trim();
|
||||
String icon = splitMapping.length < 3 ? null : splitMapping[2].trim();
|
||||
MappingImpl mapping = (MappingImpl) SitemapFactory.eINSTANCE.createMapping();
|
||||
mapping.setCmd(cmd);
|
||||
mapping.setLabel(label);
|
||||
mapping.setIcon(icon);
|
||||
mappings.add(mapping);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue