'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _reactIntl = require('react-intl');

exports.default = pluginContext => {
  var _pluginContext$inputC = pluginContext.inputComponents;
  const CompoundInput = _pluginContext$inputC.CompoundInput,
        DateInput = _pluginContext$inputC.DateInput,
        OptionPickerInput = _pluginContext$inputC.OptionPickerInput,
        TextInput = _pluginContext$inputC.TextInput,
        AutocompleteInput = _pluginContext$inputC.AutocompleteInput,
        IDGeneratorInput = _pluginContext$inputC.IDGeneratorInput,
        TermPickerInput = _pluginContext$inputC.TermPickerInput;
  const config = pluginContext.configHelpers.configKey;
  var _pluginContext$dataTy = pluginContext.dataTypes;
  const DATA_TYPE_DATE = _pluginContext$dataTy.DATA_TYPE_DATE,
        DATA_TYPE_FLOAT = _pluginContext$dataTy.DATA_TYPE_FLOAT;
  const extensions = pluginContext.config.extensions;


  return {
    document: Object.assign({
      [config]: {
        view: {
          type: CompoundInput,
          props: {
            defaultChildSubpath: 'ns2:valuationcontrols_common'
          }
        }
      }
    }, extensions.core.fields, {
      'ns2:valuationcontrols_common': {
        [config]: {
          service: {
            ns: 'http://collectionspace.org/services/valuationcontrol'
          }
        },
        valuationcontrolRefNumber: {
          [config]: {
            cloneable: false,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.valuationcontrols_common.valuationcontrolRefNumber.name',
                'defaultMessage': 'Reference number'
              }
            }),
            required: true,
            searchView: {
              type: TextInput
            },
            view: {
              type: IDGeneratorInput,
              props: {
                idGeneratorName: 'valuationcontrol'
              }
            }
          }
        },
        valueAmountsList: {
          [config]: {
            view: {
              type: CompoundInput
            }
          },
          valueAmounts: {
            [config]: {
              messages: (0, _reactIntl.defineMessages)({
                name: {
                  'id': 'field.valuationcontrols_common.valueAmounts.name',
                  'defaultMessage': 'Amount'
                }
              }),
              repeating: true,
              view: {
                type: CompoundInput,
                props: {
                  tabular: true
                }
              }
            },
            valueCurrency: {
              [config]: {
                messages: (0, _reactIntl.defineMessages)({
                  fullName: {
                    'id': 'field.valuationcontrols_common.valueCurrency.fullName',
                    'defaultMessage': 'Amount currency'
                  },
                  name: {
                    'id': 'field.valuationcontrols_common.valueCurrency.name',
                    'defaultMessage': 'Currency'
                  }
                }),
                view: {
                  type: TermPickerInput,
                  props: {
                    source: 'currency'
                  }
                }
              }
            },
            valueAmount: {
              [config]: {
                dataType: DATA_TYPE_FLOAT,
                messages: (0, _reactIntl.defineMessages)({
                  name: {
                    'id': 'field.valuationcontrols_common.valueAmount.name',
                    'defaultMessage': 'Value'
                  },
                  fullName: {
                    'id': 'field.valuationcontrols_common.valueAmount.fullName',
                    'defaultMessage': 'Amount value'
                  }
                }),
                view: {
                  type: TextInput
                }
              }
            }
          }
        },
        valueDate: {
          [config]: {
            dataType: DATA_TYPE_DATE,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.valuationcontrols_common.valueDate.name',
                'defaultMessage': 'Date'
              }
            }),
            view: {
              type: DateInput
            }
          }
        },
        valueRenewalDate: {
          [config]: {
            dataType: DATA_TYPE_DATE,
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.valuationcontrols_common.valueRenewalDate.name',
                'defaultMessage': 'Renewal date'
              }
            }),
            view: {
              type: DateInput
            }
          }
        },
        valueSource: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.valuationcontrols_common.valueSource.name',
                'defaultMessage': 'Source'
              }
            }),
            view: {
              type: AutocompleteInput,
              props: {
                source: 'person/local,person/shared,organization/local,organization/shared'
              }
            }
          }
        },
        valueType: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.valuationcontrols_common.valueType.name',
                'defaultMessage': 'Type'
              }
            }),
            view: {
              type: OptionPickerInput,
              props: {
                source: 'valueTypes'
              }
            }
          }
        },
        valueNote: {
          [config]: {
            messages: (0, _reactIntl.defineMessages)({
              name: {
                'id': 'field.valuationcontrols_common.valueNote.name',
                'defaultMessage': 'Note'
              }
            }),
            view: {
              type: TextInput,
              props: {
                multiline: true
              }
            }
          }
        }
      }
    })
  };
};