/
expression_cell.rb
48 lines (42 loc) · 1.29 KB
/
expression_cell.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module CriteriaOperator
module UiComponent
class ExpressionCell < BaseCell
def show(options = {})
@locator = options.has_key?(:locator) ? options[:locator] : ''
render
end
private
def property_name
if model.kind_of?(BinaryOperator) && model.left_operand.kind_of?(OperandProperty)
model.left_operand.property_name
else
''
end
end
def value
if model.kind_of?(BinaryOperator) && model.right_operand.kind_of?(OperandValue)
model.right_operand.value
else
''
end
end
def operator_type
if model.kind_of?(BinaryOperator)
model.operator_type
else
0
end
end
def operators
ops = []
ops << { value: BinaryOperatorType::EQUAL, text: 'equal to' }
ops << { value: BinaryOperatorType::NOT_EQUAL, text: 'not equal to' }
ops << { value: BinaryOperatorType::GREATER, text: 'greater than' }
ops << { value: BinaryOperatorType::GREATER_OR_EQUAL, text: 'greater than or equal to' }
ops << { value: BinaryOperatorType::LESS, text: 'less than' }
ops << { value: BinaryOperatorType::LESS_OR_EQUAL, text: 'less than or equal to' }
ops
end
end
end
end