X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-termlists.js;h=fef616f71ae8e6991ce7416ffcbcdfdd0a60267a;hb=206d9d7e2781cd2a66a0d3d83ab4fcacf4f11912;hp=c0dd4746254a49cfe63fdf9f1b476fef5514610c;hpb=a15196a348127af2a44431d42e64a74bdb94ac7e;p=mkws-moved-to-github.git diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js index c0dd474..fef616f 100644 --- a/src/mkws-widget-termlists.js +++ b/src/mkws-widget-termlists.js @@ -39,29 +39,40 @@ mkws.registerWidgetType('Facet', function() { return '[Widget ' + that.team.name() + ':' + that.type + '(' + name + ')]'; }; + var t2 = that.team.loadTemplate('Facet-' + caption); + that.log("template for Facet-" + caption + " is " + !!t2); + if (!t2) { + that.log("no " + caption + "-specific template, falling back"); + t2 = that.team.loadTemplate('Facet'); + } + that.log("template for Facet is " + !!t2); + that.team.queue("termlists").subscribe(function(data) { data = data[name]; + var t1 = that.team.loadTemplate('facetTitle-' + caption, mkws.M(caption)) + var title = t1({ query: that.config.query }); + var acc = []; + acc.push('
', title, '
'); var teamName = that.team.name(); - var acc = []; - var template = that.team.loadTemplate('facetTitle-' + caption, mkws.M(caption)) - var title = template({ query: that.config.query }); - acc.push('
' + title + '
'); for (var i = 0; i < data.length && i < max; i++) { - acc.push('
'); - acc.push('' + data[i].name + '' - + ' ' + data[i].freq + ''); - acc.push('
'); + + var s = t2({ + team: teamName, + fn: fn, + field: field, + term: data[i].name, + count: data[i].freq, + query: that.config.query + }); + acc.push('
', s, '
'); } that.node.html(acc.join(''));