var Operation = require('./operation'); var Value = require('./value'); var Field = require('./field'); /** * Objects to be used as an operands of @Sql.Filter. It represents a two * expressions basic operation composed by a table column, the operator and the * value extracted from the rendering paramerers. */ module.exports = new Class({ Extends: Operation ,Tag: 'sql-filter-item' ,Properties: { /** * The column name. */ field: { type: String, value: null }, /** * The source table name or its alias if it has been specified. */ target: { type: String, value: null }, /** * The parameter name. */ param: { type: String, value: null } } /** * Checks if parameter name has been defined and if it has a value. */ ,isReady: function(params) { return this.param != null && params != null && params[this.param] != null; } ,render: function(params) { var newOp = new Operation({type: this.type}); newOp.push(new Field({ name: this.field, target: this.target })); var value = params[this.param]; newOp.push(new Value({value: value})); return newOp.render(params); } ,findHolders: function() { return this.param ? [this.param] : null; } });