Commit 3a1ffbb8 authored by Jörg Richter's avatar Jörg Richter

Type Cache: add `getAllTopicTypes()` method and 3 more

See dmx-platform/dmx-platform#284
parent 7699d7b0
Pipeline #8290 passed with stage
in 3 seconds
This diff is collapsed.
......@@ -6,7 +6,7 @@ import typeCache from './type-cache'
import permCache from './permission-cache'
import utils from './utils'
console.log('[DMX] Client API 2019/08/26')
console.log('[DMX] Client API 2019/10/22')
export default {
......
......@@ -696,9 +696,20 @@ class Topicmap extends Topic {
}
/**
* Adds a topic to this topicmap resp. set it to visible.
*
* @param topic a dm5.Topic
* @param pos Optional: the topic position (an object with "x", "y" properties).
* If not given it's up to the topicmap renderer to position the topic.
*
* @return an "op" object which tells the caller what type of operation has been performed.
* Its "type" property is one of these:
* - "add": the topic was not contained in the topicmap before, and now has been added.
* - "show": the topic is already contained in the topicmap but was hidden; now it is set to visible
* and its original position is restored (a possibly given "pos" argument is not used).
* - undefined: the topic is already contained in the topicmap and is visible; nothing was performed
* (a possibly given "pos" argument is not used).
* In case of "add" and "show": the op's "viewTopic" property contains the topic added/set to visible.
*/
revealTopic (topic, pos) {
const op = {}
......
......@@ -159,6 +159,28 @@ function getTypeById (id) {
// ---
function getAllTopicTypes () {
return getAllTypes('topicTypes')
}
function getAllAssocTypes () {
return getAllTypes('assocTypes')
}
function getAllDataTypes () {
return getAllTypes('dataTypes')
}
function getAllRoleTypes () {
return getAllTypes('roleTypes')
}
function getAllTypes (prop) {
return Object.values(state[prop])
}
// ---
function putTopicType (topicType) {
_putTopicType(new TopicType(topicType))
}
......@@ -229,5 +251,9 @@ export default {
getAssocType,
getDataType,
getRoleType,
getTypeById
getTypeById,
getAllTopicTypes,
getAllAssocTypes,
getAllDataTypes,
getAllRoleTypes
}
......@@ -34,10 +34,12 @@ function _instantiateChild (child) {
// ---
// TODO: drop; export directly
function clone (o) {
return _clone(o)
}
// TODO: drop; export directly
function debounce (func, delay, immediate) {
return _debounce(func, delay, immediate)
}
......
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