lib/js/app/stores/ExplorerStore.js
function _prepareFilterUpdates(explorer, filter, updates) {
  if (updates.property_name && updates.property_name !== filter.property_name) {
    if (filter.operator === 'exists') {
      updates.coercion_type = 'Boolean';
    } else {
      // No need to update the operator - we allow any operator for any property type right now.
      updates.coercion_type = _getDefaultFilterCoercionType(explorer, _.merge({}, filter, updates));
    }
  }
  else if (updates.operator && updates.operator !== filter.operator) {
    var newOp = updates.operator;
    if (newOp === 'in') updates.coercion_type = 'List';
    if (newOp === 'exists') updates.coercion_type = 'Boolean';
    if (newOp === 'within') updates.coercion_type = 'Geo';

    // If it's not any of these operators, we still need to make sure that the current coercion_type is available
    // as an option for this new operator.
    var coercionOptions = _.find(ProjectUtils.getConstant('FILTER_OPERATORS'), { value: updates.operator }).canBeCoeredTo;
    var coercion_type = updates.coercion_type || filter.coercion_type;
    if (!_.includes(coercionOptions, coercion_type)) {
      updates.coercion_type = coercionOptions[0];
    }
  }

  if (updates.coercion_type === 'Geo' && filter.coercion_type !== 'Geo') {
    updates.property_value = _defaultGeoFilter();
  }

  updates.property_value = FilterUtils.getCoercedValue(_.merge({}, filter, updates));

  return updates;
}
function _prepareFilterUpdates(explorer, filter, updates) {
  if (updates.property_name && updates.property_name !== filter.property_name) {
    if (filter.operator === 'exists') {
      updates.coercion_type = 'Boolean';
    } else {
      // No need to update the operator - we allow any operator for any property type right now.
      updates.coercion_type = _getDefaultFilterCoercionType(explorer, _.merge({}, filter, updates));
    }
  }
  else if (updates.operator && updates.operator !== filter.operator) {
    var newOp = updates.operator;
    if (newOp === 'in') updates.coercion_type = 'List';
    if (newOp === 'exists') updates.coercion_type = 'Boolean';
    if (newOp === 'within') updates.coercion_type = 'Geo';

    // If it's not any of these operators, we still need to make sure that the current coercion_type is available
    // as an option for this new operator.
    var coercionOptions = _.find(ProjectUtils.getConstant('FILTER_OPERATORS'), { value: updates.operator }).canBeCoeredTo;
    var coercion_type = updates.coercion_type || filter.coercion_type;
    if (!_.includes(coercionOptions, coercion_type)) {
      updates.coercion_type = coercionOptions[0];
    }
  }

  if (updates.coercion_type === 'Geo' && filter.coercion_type !== 'Geo') {
    updates.property_value = _defaultGeoFilter();
  }

  updates.property_value = FilterUtils.getCoercedValue(_.merge({}, filter, updates));

  return updates;
}
function _prepareFilterUpdates ( explorer , filter , updates ) { if ( updates . property_name && updates . property_name !== filter . property_name ) { if ( filter . operator === 'exists' ) { updates . coercion_type = 'Boolean' ; } else { // No need to update the operator - we allow any operator for any property type right now. updates . coercion_type = _getDefaultFilterCoercionType ( explorer , _ . merge ( { } , filter , updates ) ) ; } } else if ( updates . operator && updates . operator !== filter . operator ) { var newOp = updates . operator ; if ( newOp === 'in' ) updates . coercion_type = 'List' ; if ( newOp === 'exists' ) updates . coercion_type = 'Boolean' ; if ( newOp === 'within' ) updates . coercion_type = 'Geo' ; // If it's not any of these operators, we still need to make sure that the current coercion_type is available // as an option for this new operator. var coercionOptions = _ . find ( ProjectUtils . getConstant ( 'FILTER_OPERATORS' ) , { value : updates . operator } ) . canBeCoeredTo ; var coercion_type = updates . coercion_type || filter . coercion_type ; if ( ! _ . includes ( coercionOptions , coercion_type ) ) { updates . coercion_type = coercionOptions [ 0 ] ; } } if ( updates . coercion_type === 'Geo' && filter . coercion_type !== 'Geo' ) { updates . property_value = _defaultGeoFilter ( ) ; } updates . property_value = FilterUtils . getCoercedValue ( _ . merge ( { } , filter , updates ) ) ; return updates ; }
Looks at updates about to be made to a filter and performs a series of operations to
change the filter values depending on the coercion_type, operator and type of property_value.
@param  {Object} explorer  The explorer model that owns the filter to be updated
@param  {Object} filter    The filter to be updated
@param  {Object} updates   The updates to be made to the filter
@return {Object}           The updated version of the filter after the changes have been made to it.
Looks at updates about to be made to a filter and performs a series of operations to change the filter values depending on the coercion_type operator and type of property_value .