VERSION = $(shell tr -d '\012' < VERSION)
COMPONENTS = mkws-handlebars.js \
- mkws-core.js mkws-team.js mkws-widgets.js mkws-widget-termlists.js \
+ mkws-core.js mkws-team.js mkws-filter.js \
+ mkws-widgets.js mkws-widget-termlists.js \
mkws-widget-authname.js mkws-widget-categories.js mkws-widget-log.js \
mkws-widget-record.js mkws-widget-builder.js
mkws.teams[tname].limitQuery(field, value);
};
+mkws.limitCategory = function(tname, id) {
+ mkws.teams[tname].limitCategory(id);
+};
+
mkws.delimitTarget = function(tname, id) {
mkws.teams[tname].delimitTarget(id);
};
--- /dev/null
+// Factory function for filters. These can be of several types.
+function filter(id, field, value) {
+ var res;
+
+ if (id) {
+ res = { id: id, name: name };
+ } else {
+ res = { field: field, value: value };
+ }
+
+ return res;
+}
// Some functions are visible as member-functions to be called from
// outside code -- specifically, from generated HTML. These functions
// are that.switchView(), showDetails(), limitTarget(), limitQuery(),
-// delimitTarget(), delimitQuery(), showPage(), pagerPrev(),
-// pagerNext().
+// limitCategory(), delimitTarget(), delimitQuery(), showPage(),
+// pagerPrev(), pagerNext().
//
function team($, teamName) {
var that = {};
};
+ that.limitCategory = function(id) {
+ log("limitCategory(id=" + id + ")");
+ m_filters.push({ category: id });
+ //triggerSearch();
+ return false;
+ };
+
+
that.delimitTarget = function(id) {
log("delimitTarget(id=" + id + ")");
removeMatchingFilters(function(f) { return f.id });
that.log("got categories: " + data);
var text = [];
- text.push("<p><b>Categories for " + realm + "</b></p>");
- text.push("<ul>");
+ text.push("Select category: ");
+ text.push("<select name='mkwsCategory' " +
+ "onchange='mkws.limitCategory(\"" + that.team.name() + "\", this.value)'>");
+ text.push("<option value=''>[All]</option>");
$(data).find('category').each(function() {
var name = $(this).find('categoryName').text();
var id = $(this).find('categoryId').text();
- text.push("<li>");
- text.push('<a href="#" onclick="mkws.setCategory(' + "'" + id + "'" + ')">' + name + '</a>');
- text.push("</li>");
+ text.push("<option value='", id, "'>", name, "</option>");
});
- text.push("</ul>");
+ text.push("</select>");
$(that.node).html(text.join(''));
});
});
var text = "";
for (var i in filters) {
+ var filter = filters[i];
if (text) {
text += " | ";
}
- var filter = filters[i];
if (filter.id) {
text += M('source') + ': <a class="crossout" href="#" onclick="mkws.delimitTarget(\'' + teamName +
"', '" + filter.id + "'" + ');return false;">' + filter.name + '</a>';
it("check for active clients after limited author search", function () {
waitsFor(function () {
var clients = $("div.mkwsStat span.clients");
- //debug("clients: " + clients.text());
- return clients.length == 1 && clients.text().match("/[1-9]+[0-9]+$");
- }, "wait for Active clients: x/y", 5 * jasmine_config.second);
+ // debug("clients: " + clients.text());
+ return clients.length == 1 && clients.text().match("/[1-9]+[0-9]*$");
+ }, "wait for Active clients: x/y", 5.5 * jasmine_config.second);
runs(function () {
var clients = $("div.mkwsStat span.clients");
debug("span.clients: " + clients.text());
- expect(clients.text()).toMatch("/[1-9]+[0-9]+$");
+ expect(clients.text()).toMatch("/[1-9]+[0-9]*$");
// exact match of active clients (e.g. a SP misconfiguration)
if (jasmine_config.active_clients) {