Merge remote branch 'origin/master' into wosch
authorWolfram Schneider <wosch@indexdata.dk>
Wed, 23 Apr 2014 12:18:03 +0000 (12:18 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Wed, 23 Apr 2014 12:18:03 +0000 (12:18 +0000)
src/Makefile
src/mkws-core.js
src/mkws-filter.js [new file with mode: 0644]
src/mkws-team.js
src/mkws-widget-categories.js
src/mkws-widgets.js
test/spec/mkws-pazpar2.js

index 749d205..fc5673f 100644 (file)
@@ -12,7 +12,8 @@ JQUERY_UI_URL =       http://code.jquery.com/ui/1.10.3/jquery-ui.js
 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
 
index d6433f4..11a4889 100644 (file)
@@ -182,6 +182,10 @@ mkws.limitQuery  = function(tname, field, value) {
     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);
 };
diff --git a/src/mkws-filter.js b/src/mkws-filter.js
new file mode 100644 (file)
index 0000000..c62235e
--- /dev/null
@@ -0,0 +1,12 @@
+// 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;
+}
index b9d899b..aa84176 100644 (file)
@@ -5,8 +5,8 @@
 // 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 = {};
@@ -189,6 +189,14 @@ function team($, teamName) {
     };
 
 
+    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 });
index afb3875..6ce09fe 100644 (file)
@@ -19,16 +19,16 @@ mkws.registerWidgetType('Categories', function() {
            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(''));
        });
     });
index 19f1066..f135aa0 100644 (file)
@@ -271,10 +271,10 @@ mkws.registerWidgetType('Navi', function() {
        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>';
index 3eaa120..4b3117e 100644 (file)
@@ -284,14 +284,14 @@ describe("Check active clients author", function () {
     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) {