@@ -1798,7 +1804,7 @@
["Country", "Country", "country", "value"],
["__langs__", "Language", "languages", "langnum"],
["__oca__", "OCA member", "oca", "oca"],
- ["odoo4projects_clients", "Clients on ODOO4projects", "clients", "min"]
+ ["odoo4projects_clients", "Clients on ODOO4projects", "clients", "yes"]
];
var LIVE_ALIASES = { Country: ["country"] };
@@ -1899,9 +1905,11 @@
function liveAttrValue(rec, pair) {
var field = pair[0], kind = pair[3];
- if (kind === "min") {
+ if (kind === "yes") {
+ // "Has clients on ODOO4projects": a count above zero. A 0 or an absent
+ // count is the empty value, so the card drops out on "Yes".
var n = parseInt(rec[field], 10);
- return isNaN(n) ? "" : String(n);
+ return (isNaN(n) || n <= 0) ? "" : "yes";
}
if (kind === "oca") return liveOcaLink(rec) ? "1" : "";
if (kind === "langnum") return liveLangsDeclared(rec).map(fold).join("|");
@@ -2050,16 +2058,15 @@
var field = pair[0], label = pair[1], attr = pair[2], kind = pair[3];
var options = null;
- if (kind === "min") {
- var counts = [];
+ if (kind === "yes") {
+ // Print only when the list holds both kinds of record — one with clients and
+ // one without — so the facet can actually narrow. "Yes" == "All" otherwise.
+ var hasYes = false, hasNo = false;
records.forEach(function (r) {
var n = parseInt(r[field], 10);
- if (!isNaN(n) && counts.indexOf(n) === -1) counts.push(n);
+ if (!isNaN(n) && n > 0) hasYes = true; else hasNo = true;
});
- counts.sort(function (a, b) { return a - b; });
- if (counts.length >= 2) {
- options = counts.slice(1).map(function (c) { return [String(c), c + "+ clients"]; });
- }
+ if (hasYes && hasNo) options = [["yes", "Yes"]];
} else if (kind === "oca") {
if (records.some(function (r) { return liveOcaLink(r); })) {
options = [["1", "OCA member"]];
@@ -2100,7 +2107,6 @@
var sel = document.createElement("select");
sel.id = id;
sel.setAttribute("data-field", attr);
- if (kind === "min") sel.setAttribute("data-match", "min");
sel.appendChild(new Option("All", ""));
options.forEach(function (o) { sel.appendChild(new Option(o[1], o[0])); });
wrap.appendChild(lbl);
@@ -2185,12 +2191,9 @@
var want = sel.value;
if (!want) return;
var have = card.getAttribute("data-" + sel.getAttribute("data-field")) || "";
- if (sel.getAttribute("data-match") === "min") {
- var n = parseInt(have, 10);
- if (isNaN(n) || n < parseInt(want, 10)) ok = false;
- } else if (have.split("|").indexOf(want) === -1) {
- ok = false;
- }
+ // Every facet is an exact membership test against the card's value —
+ // including "yes" (the card carries "yes" only for a count above zero).
+ if (have.split("|").indexOf(want) === -1) ok = false;
});
}
card.hidden = !ok;