Commit 58d10370 authored by Jörg Richter's avatar Jörg Richter

Maptype-specific icons for canvas and topic lists (#386)

parent 28104c86
Pipeline #10560 passed with stages
in 8 minutes and 18 seconds
......@@ -14,6 +14,7 @@ import systems.dmx.core.model.topicmaps.ViewTopic;
import systems.dmx.core.model.topicmaps.ViewProps;
import systems.dmx.core.osgi.PluginActivator;
import systems.dmx.core.service.Transactional;
import systems.dmx.core.service.event.PreSendTopic;
import systems.dmx.core.util.DMXUtils;
import systems.dmx.core.util.IdList;
......@@ -41,7 +42,7 @@ import java.util.logging.Logger;
@Path("/topicmaps")
@Consumes("application/json")
@Produces("application/json")
public class TopicmapsPlugin extends PluginActivator implements TopicmapsService {
public class TopicmapsPlugin extends PluginActivator implements TopicmapsService, ViewmodelCustomizer, PreSendTopic {
// ---------------------------------------------------------------------------------------------- Instance Variables
......@@ -64,6 +65,9 @@ public class TopicmapsPlugin extends PluginActivator implements TopicmapsService
// Note: registering the default topicmap type in the init() hook would be too late.
// The topicmap type is already needed at install-in-DB time ### Still true? Use preInstall() hook?
registerTopicmapType(new DefaultTopicmapType());
//
registerViewmodelCustomizer(this);
// ### FIXME: unregister is missing
}
......@@ -414,6 +418,44 @@ public class TopicmapsPlugin extends PluginActivator implements TopicmapsService
// ***************************
// *** ViewmodelCustomizer ***
// ***************************
/**
* Note: as Topicmap is not a DMXObject no PRE_SEND event is fired, so for customizing the topicmap we use a
* ViewmodelCustomizer.
*/
@Override
public void enrichViewProps(RelatedTopic topic, ViewProps viewProps) {
if (topic.getTypeUri().equals(TOPICMAP)) {
topic.loadChildTopics();
}
}
// *****************
// *** Listeners ***
// *****************
/**
* Always send a Topicmap topic complete with child topics. Clients need them in order to render a maptype specific
* icon.
*/
@Override
public void preSendTopic(Topic topic) {
if (topic.getTypeUri().equals(TOPICMAP)) {
topic.loadChildTopics();
}
}
// *************
// *** Hooks ***
// *************
......
......@@ -77,6 +77,13 @@ export default ({store, dm5}) => {
]
},
iconRenderers: {
'dmx.topicmaps.topicmap': topic => {
const mapTypeUri = topic.children['dmx.topicmaps.topicmap_type_uri'].value
return dm5.typeCache.getTopicType(mapTypeUri).getViewConfig('dmx.webclient.icon')
}
},
topicmapType: {
uri: 'dmx.topicmaps.topicmap',
name: 'Topicmap',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment