hedera-web/js/sql/filter-item.js

63 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

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
/**
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
,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
}
}
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
*/
2022-11-16 01:46:44 +00:00
,isReady(params) {
2022-05-30 01:30:33 +00:00
return this.param != null && params != null && params[this.param] != null;
}
2022-11-16 01:46:44 +00:00
,render(params) {
2022-05-30 01:30:33 +00:00
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-11-16 01:46:44 +00:00
,findHolders() {
2022-06-06 08:53:59 +00:00
return this.param ? [this.param] : null;
2022-05-30 01:30:33 +00:00
}
});