Sha256: 13a620754d9e489457a218e14f2143d7a00f9785c7363f2fa49a1d2629bb626a

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
criteria_operator-ui_component-0.3.1 app/cells/criteria_operator/ui_component/expression_cell.rb
criteria_operator-ui_component-0.3.0 app/cells/criteria_operator/ui_component/expression_cell.rb
criteria_operator-ui_component-0.2.2 app/cells/criteria_operator/ui_component/expression_cell.rb
criteria_operator-ui_component-0.2.1 app/cells/criteria_operator/ui_component/expression_cell.rb
criteria_operator-ui_component-0.2.0 app/cells/criteria_operator/ui_component/expression_cell.rb