2016-09-26 09:28:47 +00:00
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
var Operation = require('./operation');
|
2022-05-30 01:30:33 +00:00
|
|
|
var Value = require('./value');
|
|
|
|
var Field = require('./field');
|
2016-09-26 09:28:47 +00:00
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
/**
|
2022-05-30 01:30:33 +00:00
|
|
|
* 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.
|
2022-05-26 06:08:31 +00:00
|
|
|
*/
|
2022-05-28 19:27:36 +00:00
|
|
|
module.exports = new Class({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Operation
|
2015-01-23 13:09:30 +00:00
|
|
|
,Tag: 'sql-filter-item'
|
2022-05-28 19:27:36 +00:00
|
|
|
,Properties: {
|
2022-05-30 01:30:33 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2015-11-17 10:34:33 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-30 01:30:33 +00:00
|
|
|
|
|
|
|
/**
|
2022-06-06 08:53:59 +00:00
|
|
|
* Checks if parameter name has been defined and if it has a value.
|
2022-05-30 01:30:33 +00:00
|
|
|
*/
|
|
|
|
,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);
|
|
|
|
}
|
|
|
|
|
2022-06-06 08:53:59 +00:00
|
|
|
,findHolders: function() {
|
|
|
|
return this.param ? [this.param] : null;
|
2022-05-30 01:30:33 +00:00
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
});
|