<commit_before>
var assign = require('object-assign');
var fieldBehaviourMixin = {
  /**
   * Build the field properties.
   * @param {string} name - property name.
   * @param {object} options - An object which contains all options for the built of the field
   * @param {object} context - Function context, this by default.
   * @returns {object} - The constructed props for the field.
   */
  _buildFieldProps: function buildFieldProps(name, options, context){
    options = options || {};
    context = context || this;
    //Properties.
    var isEdit = options.isEdit !== undefined ? options.isEdit : context.state.isEdit;
    var value = options.value !== undefined ? options.value : context.state[name];
    var def = (context.definition && context.definition[name]) ? context.definition[name] : {};
    var listName = options.listName || def.listName;
    //hasLabel
    var hasLabel = function hasLabel(){
      if(options.hasLabel !== undefined){
        return options.hasLabel;
      }
      if(def.hasLabel !== undefined){
        return options.hasLabel;
      } return true;
    }();
    //Build a container for the props.
      var name = options.name || `${this.definitionPath}.${name}`;
    var propsContainer = {
      name: name,
      label: def.label || name,
      ref: name,
      value: value,
      error: context.state.error ? context.state.error[name] : undefined,
      //Mode
      isEdit: isEdit,
      hasLabel: hasLabel,
      isRequired: def.isRequired,
      //Style
      style: options.style,
      //Methods
      validator: def.validator,
      formatter: def.formatter,
      //Component
      FieldComponent: def.FieldComponent,
      InputLabelComponent: def.InputLabelComponent,
      InputComponent: def.InputComponent,
      TextComponent: def.TextComponent,
      DisplayComponent: def.DisplayComponent
    };
    // Values list.
    var refContainer = options.refContainer || context.state.reference;
    if(refContainer && refContainer[listName]){
      assign(propsContainer, {values: refContainer[listName]});
    }
    return propsContainer;
  }
};


module.exports = fieldBehaviourMixin;<commit_msg> [field] Props build from options in order to be softer on options..<commit_after>
var assign = require('object-assign');
var fieldBehaviourMixin = {
  /**
   * Build the field properties.
   * @param {string} name - property name.
   * @param {object} options - An object which contains all options for the built of the field
   * @param {object} context - Function context, this by default.
   * @returns {object} - The constructed props for the field.
   */
  _buildFieldProps: function buildFieldProps(name, options, context){
    options = options || {};
    context = context || this;
    //Properties.
    var isEdit = options.isEdit !== undefined ? options.isEdit : context.state.isEdit;
    var value = options.value !== undefined ? options.value : context.state[name];
    var def = (context.definition && context.definition[name]) ? context.definition[name] : {};
    var listName = options.listName || def.listName;
    //hasLabel
    var hasLabel = function hasLabel(){
      if(options.hasLabel !== undefined){
        return options.hasLabel;
      }
      if(def.hasLabel !== undefined){
        return options.hasLabel;
      } return true;
    }();
    //Build a container for the props.
    name = options.name || `${this.definitionPath}.${name}`;
    var propsContainer = {
      name: name,
      label: def.label || name,
      ref: name,
      value: value,
      error: context.state.error ? context.state.error[name] : undefined,
      //Mode
      isEdit: isEdit,
      hasLabel: hasLabel,
      isRequired: def.isRequired,
      //Style
      style: options.style,
      //Methods
      validator: def.validator,
      formatter: def.formatter,
      //Component
      FieldComponent: def.FieldComponent,
      InputLabelComponent: def.InputLabelComponent,
      InputComponent: def.InputComponent,
      TextComponent: def.TextComponent,
      DisplayComponent: def.DisplayComponent
    };
    //Extend the options object in order to be able to specify more options to thie son's component.
    var fieldProps = assign(options, propsContainer);
    // Values list.
    var refContainer = options.refContainer || context.state.reference;
    if(refContainer && refContainer[listName]){
      assign(fieldProps, {values: refContainer[listName]});
    }
    return fieldProps;
  }
};


module.exports = fieldBehaviourMixin;
{'fraction_non_alphanumeric': 0.11577777777777777, 'fraction_numerical': 0.0, 'mean_word_length': 2.924149956408021, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3004469', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1229, 'n_words': 349}