Use "target" attribute instead of "targetfilter"
[mkws-moved-to-github.git] / src / mkws-widgets.js
index 435f378..551527c 100644 (file)
@@ -60,7 +60,7 @@ function widget($, team, type, node) {
 
 
 // Utility function for use by all widgets that can invoke autosearch.
-widget.maybeAutosearch = function(widget) {
+widget.autosearch = function(widget) {
     var query = widget.config.autosearch;
     if (query) {
        if (query.match(/^!param!/)) {
@@ -87,6 +87,9 @@ widget.maybeAutosearch = function(widget) {
            var limit = widget.config.limit;
            var targets = widget.config.targets;
            var targetfilter = widget.config.targetfilter;
+           var target = widget.config.target;
+           if (target) targetfilter = 'udb=="' + target + '"';
+
            var s = "running auto search: '" + query + "'";
            if (sortOrder) s += " sorted by '" + sortOrder + "'";
            if (maxrecs) s += " restricted to " + maxrecs + " records";
@@ -214,7 +217,7 @@ mkws.registerWidgetType('Termlists', function() {
        }
     });
 
-    widget.maybeAutosearch(that);
+    widget.autosearch(that);
 });
 
 
@@ -303,14 +306,14 @@ mkws.registerWidgetType('Records', function() {
        $(that.node).html(html.join(''));
 
        function renderSummary(hit) {
-           var template = team.loadTemplate("Summary");
+           var template = team.loadTemplate(that.config.template || "Summary");
            hit._id = team.recordElementId(hit.recid[0]);
            hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;"
            return template(hit);
        }
     });
 
-    widget.maybeAutosearch(that);
+    widget.autosearch(that);
 });