X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=281f5b241a8cd180f03fb61100033efd09aeeb2e;hb=1f6d6e7fc2d7dac0337296569145d4bb0e7ace97;hp=1a80b106afd260b04d9c73df5e9c616306b75344;hpb=1164a77a52550a7a69d432c3a8b27af43aff44a3;p=mkws-moved-to-github.git diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 1a80b10..281f5b2 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -193,6 +193,9 @@ Handlebars.registerHelper('commaList', function(items, options) { } } +mkws.sort = mkws_config.sort_default; +debug("copied mkws_config.sort_default '" + mkws_config.sort_default + "' to mkws.sort"); + if (mkws_config.query_width < 5 || mkws_config.query_width > 150) { debug("Reset query width: " + mkws_config.query_width); mkws_config.query_width = 50; @@ -414,7 +417,7 @@ function onFormSubmitEventHandler() return false; } -function newSearch(query) +function newSearch(query, sort, targets) { if (!mkws.authenticated) { alert("searching before authentication"); @@ -425,7 +428,7 @@ function newSearch(query) redraw_navi(); resetPage(); loadSelect(); - triggerSearch(query); + triggerSearch(query, sort, targets); mkws.switchView('records'); // In case it's configured to start off as hidden submitted = true; } @@ -445,22 +448,34 @@ function resetPage() totalRec = 0; } -function triggerSearch (query) +function triggerSearch (query, sort, targets) { var pp2filter = ""; var pp2limit = ""; - // Re-use previous query if a new one is not specified + // Re-use previous query/sort if new ones are not specified if (query) { mkws.query = query; } + if (sort) { + mkws.sort = sort; + } + if (targets) { + // ### should support multiple |-separated targets + mkws.filters.push({ id: targets, name: targets }); + } for (var i in mkws.filters) { var filter = mkws.filters[i]; if (filter.id) { if (pp2filter) pp2filter += ","; - pp2filter += 'pz:id=' + filter.id; + if (filter.id.match(/^[a-z:]+[=~]/)) { + debug("filter '" + filter.id + "' already begins with SETTING OP"); + } else { + filter.id = 'pz:id=' + filter.id; + } + pp2filter += filter.id; } else { if (pp2limit) pp2limit += ","; @@ -917,9 +932,12 @@ function run_auto_searches() { if (node.attr('autosearch')) { var query = node.attr('autosearch'); var sort = node.attr('sort'); - debug("running auto search: '" + query + "' sorted by '" + sort + "'"); - // ### currently ignoring sort - newSearch(query); + var targets = node.attr('targets'); + var s = "running auto search: '" + query + "'"; + if (sort) s += " sorted by '" + sort + "'"; + if (targets) s += " in targets '" + targets + "'"; + debug(s); + newSearch(query, sort, targets); } } @@ -952,7 +970,7 @@ function mkws_html_switch() { } function mkws_html_sort() { - debug("HTML sort"); + debug("HTML sort, mkws.sort = '" + mkws.sort + "'"); var sort_html = '