Move auto-searching code out of Records widget into
[mkws-moved-to-github.git] / src / mkws-widgets.js
index 19789bd..4df81d7 100644 (file)
@@ -257,8 +257,7 @@ mkws.registerWidgetType('Records', function() {
        }
        $(that.node).html(html.join(''));
 
-       function renderSummary(hit)
-       {
+       function renderSummary(hit) {
            var template = team.loadTemplate("Summary");
            hit._id = team.recordElementId(hit.recid[0]);
            hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;"
@@ -266,6 +265,11 @@ mkws.registerWidgetType('Records', function() {
        }
     });
 
+    mkws.maybeAutosearch(that);
+});
+
+
+mkws.maybeAutosearch = function(that) {
     var query = that.config.autosearch;
     if (query) {
        if (query.match(/^!param!/)) {
@@ -285,18 +289,24 @@ mkws.registerWidgetType('Records', function() {
            }
        }
 
-       this.team.queue("ready").subscribe(function() {
+       that.team.queue("ready").subscribe(function() {
            var sortOrder = that.config.sort;
+           var perpage = that.config.perpage;
+           var limit = that.config.limit;
            var targets = that.config.targets;
+           var targetfilter = that.config.targetfilter;
            var s = "running auto search: '" + query + "'";
            if (sortOrder) s += " sorted by '" + sortOrder + "'";
+           if (perpage) s += " with " + perpage + " per page";
+           if (limit) s += " limited by '" + limit + "'";
            if (targets) s += " in targets '" + targets + "'";
+           if (targetfilter) s += " constrained by targetfilter '" + targetfilter + "'";
            that.log(s);
 
-           that.team.newSearch(query, sortOrder, targets);
+           that.team.newSearch(query, sortOrder, perpage, limit, targets, targetfilter);
        });
     }
-});
+};
 
 
 mkws.registerWidgetType('Navi', function() {