);
};
+ /* This helps convert things that pcrud won't accept ("not between", "not
+ * like") into proper JSON query expressions later in this file.
+ * It returns false if a clause doesn't have any such negative operator,
+ * or it returns true AND gets rid of the "not " part in the clause
+ * object itself. It's up to the caller to wrap it in {"-not": {}} in
+ * the right place. */
+ function _clause_was_negative(clause) {
+ /* clause objects really only ever have one property */
+ var ops = openils.Util.objectProperties(clause);
+ var op = ops.pop();
+ var matches = op.match(/^not (\w+)$/);
+ if (matches) {
+ clause[matches[1]] = clause[op];
+ delete clause[op];
+ return true;
+ }
+ return false;
+ }
+
/* This is not the dijit per se. Search further in this file for
* "dojo.declare" for the beginning of the dijit. */
function PCrudFilterRowManager() {
var list = first_pass[field];
if (list.length == 1) {
var obj = {};
- obj[field] = list.pop();
+ var clause = list.pop();
+ if (_clause_was_negative(clause)) {
+ obj["-not"] = {};
+ obj["-not"][field] = clause;
+ } else {
+ obj[field] = clause;
+ }
and.push(obj);
} else {
var or = list.map(
- function(expr) {
- var obj = {}; obj[field] = expr; return obj;
+ function(clause) {
+ var obj = {};
+ if (_clause_was_negative(clause)) {
+ obj["-not"] = {};
+ obj["-not"][field] = clause;
+ } else {
+ obj[field] = clause;
+ }
+ return obj;
}
);
and.push({"-or": or});
this._remove_operator_selector = function() {
if (this.operator_selector) {
- var old_value = this.operator_selector.attr("value");
+ var old_value = this.operator_selector.getValue();
this.operator_selector.destroy();
dojo.empty(this.operator_slot);
{
"identity": old_operator,
"onItem": function(item) {
- if (item) { /* sic, necessary */
- self.operator_selector.attr(
- "value", old_operator
- );
- }
+ if (item) /* sic, necessary */
+ self.operator_selector.setValue(old_operator);
}
}
);