Commit f46cb8ea authored by Jörg Richter's avatar Jörg Richter

Model: fix TopicType's newTopicModel() (init all typeUris)

See dmx-platform/dmx-platform#307
parent 70a2972f
Pipeline #8367 passed with stage
in 4 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/10/23')
console.log('[DMX] Client API 2019/10/31')
export default {
......
......@@ -457,27 +457,29 @@ class Type extends Topic {
class TopicType extends Type {
/**
* TODO: drop this method.
* For topic creation use emptyInstance() instead and fill in the default value(s) afterwards.
*
* @returns a plain object.
*/
newTopicModel (simpleValue) {
const topic = _newTopicModel(this.uri)
topic.typeUri = this.uri
return topic
return _newTopicModel(this.uri)
function _newTopicModel (typeUri) {
const topic = {typeUri}
const type = typeCache.getTopicType(typeUri)
if (type.isSimple()) {
return {
value: simpleValue
}
topic.value = simpleValue
} else {
const compDef = type.compDefs[0]
const child = _newTopicModel(compDef.childTypeUri)
return {
children: {
[compDef.compDefUri]: compDef.isOne() ? child : [child]
}
topic.children = {
[compDef.compDefUri]: compDef.isOne() ? child : [child]
}
}
return topic
}
}
......
......@@ -55,9 +55,10 @@ export default {
* Performs a fulltext search.
*
* @param query A Lucene search query.
* @param topicTypeUri Only topics of this type are searched. If null all topics are searched.
* @param searchChildTopics If true the topic's child topics are searched as well. Works only if "topicTypeUri" is
* given.
* @param topicTypeUri Optional: only topics of this type are searched. If not given (falsish) all topics are
* searched.
* @param searchChildTopics Optional: if true the topic's child topics are searched as well. Works only if
* "topicTypeUri" is given.
*/
queryTopicsFulltext (query, topicTypeUri, searchChildTopics) {
// suppress error handler as for incremental search the query might be (temporarily) syntactically incorrect
......
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