{"size": 3549, "ext": "js", "max_stars_repo_path": "app/react/Templates/components/PropertyConfigOptions.js", "max_stars_repo_name": "BuildJet/uwazi", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/react/Templates/components/PropertyConfigOptions.js", "max_issues_repo_name": "BuildJet/uwazi", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/react/Templates/components/PropertyConfigOptions.js", "max_forks_repo_name": "BuildJet/uwazi", "max_forks_repo_forks_event_min_datetime": "2022-01-02T14:58:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-02T14:58:09.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 36.2142857143, "max_line_length": 100, "alphanum_fraction": 0.5770639617}
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { FilterSuggestions } from 'app/Templates/components/FilterSuggestions';
import { connect } from 'react-redux';

import PropertyConfigOption from './PropertyConfigOption';
import Tip from '../../Layout/Tip';

class PropertyConfigOptions extends Component {
  render() {
    const { index, filter, type, canBeFilter } = this.props;
    return (
      <div>
        <PropertyConfigOption
          label="Hide label"
          model={`template.data.properties[${index}].noLabel`}
        >
          <Tip>This property will be shown without the label.</Tip>
        </PropertyConfigOption>
        <PropertyConfigOption
          label="Required property"
          model={`template.data.properties[${index}].required`}
        >
          <Tip>You won&#39;t be able to publish a document if this property is empty.</Tip>
        </PropertyConfigOption>
        <PropertyConfigOption
          label="Show in cards"
          model={`template.data.properties[${index}].showInCard`}
        >
          <Tip>This property will appear in the library cards as part of the basic info.</Tip>
        </PropertyConfigOption>

        {canBeFilter && (
          <div className="inline-group">
            <PropertyConfigOption
              label="Use as filter"
              model={`template.data.properties[${index}].filter`}
            >
              <Tip>
                This property will be used for filtering the library results. When properties match
                in equal name and field type with other document types, they will be combined for
                filtering.
              </Tip>
            </PropertyConfigOption>
            {filter && (
              <>
                <PropertyConfigOption
                  label="Default filter"
                  model={`template.data.properties[${index}].defaultfilter`}
                >
                  <Tip>
                    Use this property as a default filter in the library. When there are no document
                    types selected, this property will show as a default filter for your collection.
                  </Tip>
                </PropertyConfigOption>
                {['text', 'date', 'numeric', 'select'].includes(type) && (
                  <PropertyConfigOption
                    label="Priority sorting"
                    model={`template.data.properties[${index}].prioritySorting`}
                  >
                    <Tip>
                      Properties marked as priority sorting will be used as default sorting
                      criteria. If more than one property is marked as priority sorting the system
                      will try to pick-up the best fit. When listing mixed template types, the
                      system will pick-up the best combined priority sorting.
                    </Tip>
                  </PropertyConfigOption>
                )}
              </>
            )}
          </div>
        )}
        <FilterSuggestions index={index} />
      </div>
    );
  }
}

PropertyConfigOptions.defaultProps = {
  canBeFilter: true,
  filter: false,
};

PropertyConfigOptions.propTypes = {
  filter: PropTypes.bool,
  index: PropTypes.number.isRequired,
  type: PropTypes.string.isRequired,
  canBeFilter: PropTypes.bool,
};

export function mapStateToProps({ template }, props) {
  return {
    filter: template.data.properties[props.index].filter,
  };
}

export default connect(mapStateToProps)(PropertyConfigOptions);
