Permalink
Browse files

Adapt to DeepaMehta 4.0.11's topic renderer.

The add_facets_to_page_model() utility method works.
  • Loading branch information...
1 parent cd48e2c commit 208ddc69bc10dbea0335a2dd24afd5404062bbde @jri committed May 12, 2012
Showing with 9 additions and 6 deletions.
  1. +9 −6 src/main/resources/web/script/facets_plugin.js
@@ -9,17 +9,20 @@ function facets_plugin() {
* @param topic The facetted topic the page/form is rendered for. Usually that is the selected topic.
* @param facet_types The facet types to add to the page model (array of topic objects of type "Topic Type").
* @param page_model The page model to extend.
- * @param setting "viewable" or "editable"
+ * @param setting "viewable" or "editable" (string).
*/
this.add_facets_to_page_model = function(topic, facet_types, page_model, setting) {
for (var i = 0; i < facet_types.length; i++) {
var facet_type = dm4c.get_topic_type(facet_types[i].uri)
+ // compare to TopicRenderer.create_page_model
var assoc_def = facet_type.assoc_defs[0]
- var topic_type = dm4c.get_topic_type(assoc_def.part_topic_type_uri)
- var field_uri = dm4c.COMPOSITE_PATH_SEPARATOR + assoc_def.uri
- var value_topic = topic.composite[assoc_def.uri]
- var fields = TopicRenderer.create_fields(topic_type, assoc_def, field_uri, value_topic, topic, setting)
- page_model[assoc_def.uri] = fields
+ var child_topic_type = dm4c.get_topic_type(assoc_def.part_topic_type_uri)
+ var child_field_uri = dm4c.COMPOSITE_PATH_SEPARATOR + assoc_def.uri
+ // ### TODO: cardinality many
+ var child_topic = topic.composite[assoc_def.uri] || dm4c.empty_topic(child_topic_type.uri)
+ var child_model = TopicRenderer.create_page_model(child_topic, assoc_def, child_field_uri, topic, setting)
+ // ### FIXME: child_model may be undefined
+ page_model.add_child(assoc_def.uri, child_model)
}
}
}

0 comments on commit 208ddc6

Please sign in to comment.