Commit 28104c86 authored by Jörg Richter's avatar Jörg Richter

New Webclient extension type: "Icon Renderer" (#386)

parent bf0f7812
Pipeline #10553 passed with stages
in 8 minutes and 30 seconds
......@@ -36,13 +36,13 @@ import java.util.logging.Logger;
* <ol>
* <li>Fire the <code>CoreEvent.SERVICE_RESPONSE_FILTER</code> event to let plugins operate on the response, e.g.
* - the Caching plugin sets the <code>Cache-Control</code> response header
* - the Time plugin sets the <code>Last-Modified</code> response header
* - the Timestamps plugin sets the <code>Last-Modified</code> response header
* <li>Load child topics of the response object(s) if requested with the <code>children</code> and
* <code>assoc_children</code> query parameters.
* <li>Fire the <code>CoreEvent.PRE_SEND_XXX</code> events for all response object(s) and objects contained in response
* directives. This let plugins operate on the response on a per-object basis, e.g.
* - the Geomaps plugin enriches an Address topic with its geo coordinate
* - the Time plugin enriches topics/associations with creation/modification timestamps
* - the Timestamps plugin enriches topics/associations with creation/modification timestamps
* <li>Broadcast directives.
* <li>Remove the (thread-local) directives assembled while request processing.
* </ol>
......@@ -95,7 +95,7 @@ class JerseyResponseFilter implements ContainerResponseFilter {
firePreSend(((DirectivesResponse) entity).getObject());
//
// Note: some plugins rely on the PRE_SEND event to be fired for the individual DMX
// objects contained in the set of directives. E.g. the Time plugin enriches updated objects
// objects contained in the set of directives. E.g. the Timestamps plugin enriches updated objects
// with timestamps. The timestamps in turn are needed at client-side by the Caching plugin
// in order to issue conditional PUT requests.
// ### TODO: don't fire PRE_SEND events for the individual directives but only for the wrapped
......
......@@ -8,7 +8,7 @@
</div>
<div class="field">
<div class="field-label">Released</div>
Jul 20, 2020
Jul 21, 2020
</div>
<div class="field">
<div class="field-label">License</div>
......
......@@ -3,7 +3,7 @@
<el-select v-model="topicmapId">
<el-option-group label="Topicmap">
<el-option v-for="topic in topicmapTopics" :label="topic.value" :value="topic.id" :key="topic.id">
<span class="fa icon">{{icon(topic)}}</span><span>{{topic.value}}</span>
<span class="fa icon">{{topic.icon}}</span><span>{{topic.value}}</span>
</el-option>
</el-option-group>
</el-select>
......@@ -55,11 +55,6 @@ export default {
resetTopicmapViewport () {
this.$store.dispatch('resetTopicmapViewport')
},
icon (topicmapTopic) {
const mapTypeUri = topicmapTopic.children['dmx.topicmaps.topicmap_type_uri'].value
return dm5.typeCache.getTopicType(mapTypeUri).getViewConfig('dmx.webclient.icon')
}
}
}
......
......@@ -9,14 +9,15 @@ import extraElementUI from './element-ui'
import 'font-awesome/css/font-awesome.css'
import './websocket'
console.log('[DMX] 2020/07/20')
console.log('[DMX] 2020/07/21')
// 1) Init dm5 library
// The dm5 library must be inited *before* the dm5-webclient component is instantiated.
// The dm5-webclient component relies on the "typeCache" store module as registered by dm5.init(). ### TODO: still true?
const dm5ready = dm5.init({
store,
onHttpError
onHttpError,
iconRenderers: store.state.iconRenderers
})
// 2) Create Vue root instance
......
......@@ -89,6 +89,9 @@ function initPlugin (pluginConfig) {
registerDetailRenderers(_pluginConfig.objectRenderers, 'object')
registerDetailRenderers(_pluginConfig.valueRenderers, 'value')
//
// icon renderers
registerIconRenderers(_pluginConfig.iconRenderers)
//
// context commands
const contextCommands = _pluginConfig.contextCommands
if (contextCommands) {
......@@ -114,6 +117,12 @@ function registerDetailRenderers (renderers, renderer) {
}
}
function registerIconRenderers (renderers) {
renderers && Object.entries(renderers).forEach(([typeUri, iconFunc]) => {
store.dispatch('registerIconRenderer', {typeUri, iconFunc})
})
}
// --- Fetch from server ---
/**
......
......@@ -21,6 +21,11 @@ const state = {
value: {} // typeUri: component
}, // }
iconRenderers: { // Registered icon renderers:
}, // {
// typeUri: function (topic) => icon
// }
compDefs: {}, // Registered webclient components:
// {
// mount: [compDef]
......@@ -91,12 +96,16 @@ const actions = {
// ---
/**
* @param render "object" or "value"
* @param renderer "object" or "value"
*/
registerDetailRenderer (_, {renderer, typeUri, component}) {
state.detailRenderers[renderer][typeUri] = component
},
registerIconRenderer (_, {typeUri, iconFunc}) {
state.iconRenderers[typeUri] = iconFunc
},
registerComponent (_, compDef) {
const compDefs = state.compDefs[compDef.mount] || (state.compDefs[compDef.mount] = [])
compDef.id = compCount++
......
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