X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-team.js;h=ac427e5bd0a9a57f01047dce3257f5ab88891501;hb=0110825c865a30c5684711b4af596e4910b598af;hp=2e2485462ca3ae5574abb3a385e801ef556bda85;hpb=b3ad811d9b8569c4bc5a05c9150aa77a89dc27aa;p=mkws-moved-to-github.git diff --git a/src/mkws-team.js b/src/mkws-team.js index 2e24854..ac427e5 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -26,7 +26,8 @@ function team($, teamName) { "last": $.now() }; var m_paz; // will be initialised below - var m_template = {}; + var m_tempateText = {}; // widgets can register tempates to be compiled + var m_template = {}; // compiled templates, from any source var m_config = mkws.objectInheritingFrom(mkws.config); var m_widgets = {}; // Maps widget-type to object @@ -35,6 +36,7 @@ function team($, teamName) { // Accessor methods for individual widgets: readers that.name = function() { return m_teamName; }; that.submitted = function() { return m_submitted; }; + that.sortOrder = function() { return m_sortOrder; }; that.perpage = function() { return m_perpage; }; that.totalRecordCount = function() { return m_totalRecordCount; }; that.currentPage = function() { return m_currentPage; }; @@ -170,7 +172,7 @@ function team($, teamName) { that.limitTarget = function(id, name) { log("limitTarget(id=" + id + ", name=" + name + ")"); m_filterSet.add(targetFilter(id, name)); - triggerSearch(); + if (m_query) triggerSearch(); return false; }; @@ -178,31 +180,34 @@ function team($, teamName) { that.limitQuery = function(field, value) { log("limitQuery(field=" + field + ", value=" + value + ")"); m_filterSet.add(fieldFilter(field, value)); - triggerSearch(); + if (m_query) triggerSearch(); return false; }; that.limitCategory = function(id) { log("limitCategory(id=" + id + ")"); - // ### Add a filter - // ### triggerSearch() if there's a query + // Only one category filter at a time + m_filterSet.removeMatching(function(f) { return f.type === 'category' }); + if (id !== '') m_filterSet.add(categoryFilter(id)); + if (m_query) triggerSearch(); return false; }; that.delimitTarget = function(id) { log("delimitTarget(id=" + id + ")"); - m_filterSet.removeMatching(function(f) { return f.id }); - triggerSearch(); + m_filterSet.removeMatching(function(f) { return f.type === 'target' }); + if (m_query) triggerSearch(); return false; }; that.delimitQuery = function(field, value) { log("delimitQuery(field=" + field + ", value=" + value + ")"); - m_filterSet.removeMatching(function(f) { return f.field && field == f.field && value == f.value }); - triggerSearch(); + m_filterSet.removeMatching(function(f) { return f.type == 'field' && + field == f.field && value == f.value }); + if (m_query) triggerSearch(); return false; }; @@ -248,7 +253,7 @@ function team($, teamName) { return; } - m_filterSet = filterSet(that); + m_filterSet.removeMatching(function(f) { return f.type !== 'category' }); triggerSearch(query, sortOrder, maxrecs, perpage, limit, targets, torusquery); switchView('records'); // In case it's configured to start off as hidden m_submitted = true; @@ -260,15 +265,18 @@ function team($, teamName) { resetPage(); queue("navi").publish(); - // Continue to use previous query/sort-order unless new ones are specified if (query) m_query = query; if (sortOrder) m_sortOrder = sortOrder; if (perpage) m_perpage = perpage; - if (targets) m_filterSet.add(targetFilter(id, id)); + if (targets) m_filterSet.add(targetFilter(targets, targets)); var pp2filter = m_filterSet.pp2filter(); var pp2limit = m_filterSet.pp2limit(limit); + var pp2catLimit = m_filterSet.pp2catLimit(); + if (pp2catLimit) { + pp2filter = pp2filter ? pp2filter + "," + pp2catLimit : pp2catLimit; + } var params = {}; if (pp2limit) params.limit = pp2limit; @@ -346,75 +354,7 @@ function team($, teamName) { */ function mkwsHtmlAll() { mkwsSetLang(); - if (m_config.show_lang) - mkwsHtmlLang(); - - log("HTML search form"); - findnode('.mkwsSearch').html('\ -
'); - - log("HTML records"); - // If the team has a .mkwsResults, populate it in the usual - // way. If not, assume that it's a smarter application that - // defines its own subcomponents, some or all of the - // following: - // .mkwsTermlists - // .mkwsRanking - // .mkwsPager - // .mkwsNavi - // .mkwsRecords - findnode(".mkwsResults").html('\ -\ - \ - | \ -\ - \ - \ - \ - \ - | \ -
\ - \ - | \ -