diff --git a/package-lock.json b/package-lock.json index e9e8ed2d..627846a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13850,4 +13850,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/plugins/recordTypes/heldintrust/advancedSearch.js b/src/plugins/recordTypes/heldintrust/advancedSearch.js new file mode 100644 index 00000000..ab640d6c --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/advancedSearch.js @@ -0,0 +1,21 @@ +export default (configContext) => { + const { + OP_CONTAIN, + } = configContext.searchOperators; + + const { + defaultAdvancedSearchBooleanOp, + extensions, + } = configContext.config; + + return { + op: defaultAdvancedSearchBooleanOp, + value: [ + { + op: OP_CONTAIN, + path: 'ns2:heldintrusts_common/heldInTrustNumber', + }, + ...extensions.core.advancedSearch, + ], + }; +}; diff --git a/src/plugins/recordTypes/heldintrust/columns.js b/src/plugins/recordTypes/heldintrust/columns.js new file mode 100644 index 00000000..6d72138f --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/columns.js @@ -0,0 +1,48 @@ +import { defineMessages } from 'react-intl'; + +export default (configContext) => { + const { + formatTimestamp, + formatRefName, + } = configContext.formatHelpers; + + return { + default: { + heldInTrustNumber: { + messages: defineMessages({ + label: { + id: 'column.heldintrust.default.heldInTrustNumber', + defaultMessage: 'Held-in-Trust number', + }, + }), + order: 10, + sortBy: 'heldintrusts_common:heldInTrustNumber', + width: 200, + }, + depositor: { + formatValue: formatRefName, + messages: defineMessages({ + label: { + id: 'column.heldintrust.default.depositor', + defaultMessage: 'Depositor', + }, + }), + order: 20, + sortBy: 'heldintrusts_common:heldInTrustDepositorGroupList/0/depositor', + width: 450, + }, + updatedAt: { + formatValue: formatTimestamp, + messages: defineMessages({ + label: { + id: 'column.heldintrust.default.updatedAt', + defaultMessage: 'Updated', + }, + }), + order: 30, + sortBy: 'collectionspace_core:updatedAt', + width: 150, + }, + }, + }; +}; diff --git a/src/plugins/recordTypes/heldintrust/fields.js b/src/plugins/recordTypes/heldintrust/fields.js new file mode 100644 index 00000000..cc4425a6 --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/fields.js @@ -0,0 +1,854 @@ +import { defineMessages } from 'react-intl'; + +export default (configContext) => { + const { + CompoundInput, + DateInput, + TextInput, + AutocompleteInput, + IDGeneratorInput, + TermPickerInput, + } = configContext.inputComponents; + + const { + configKey: config, + } = configContext.configHelpers; + + const { + DATA_TYPE_DATE, + } = configContext.dataTypes; + + const { + extensions, + } = configContext.config; + + return { + document: { + [config]: { + view: { + type: CompoundInput, + props: { + defaultChildSubpath: 'ns2:heldintrusts_common', + }, + }, + }, + ...extensions.core.fields, + 'ns2:heldintrusts_common': { + [config]: { + service: { + ns: 'http://collectionspace.org/services/heldintrust', + }, + }, + heldInTrustNumber: { + [config]: { + cloneable: false, + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.heldInTrustNumber.name', + defaultMessage: 'Held-in-Trust number', + }, + }), + required: true, + searchView: { + type: TextInput, + }, + view: { + type: IDGeneratorInput, + props: { + source: 'heldintrust', + }, + }, + }, + }, + entryDate: { + [config]: { + dataType: DATA_TYPE_DATE, + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.entryDate.name', + defaultMessage: 'Object entry date', + }, + }), + view: { + type: DateInput, + }, + }, + }, + heldInTrustDepositorGroupList: { + [config]: { + view: { + type: CompoundInput, + }, + }, + heldInTrustDepositorGroup: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.heldInTrustDepositorGroup.name', + defaultMessage: 'Depositor', + }, + }), + repeating: true, + view: { + type: CompoundInput, + props: { + tabular: true, + }, + }, + }, + depositor: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.depositor.fullName', + defaultMessage: 'Depositor name', + }, + name: { + id: 'field.heldintrusts_common.depositor.name', + defaultMessage: 'Name', + }, + }), + view: { + type: AutocompleteInput, + props: { + source: 'person/local,organization/local', + }, + }, + }, + }, + depositorContact: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.depositorContact.fullName', + defaultMessage: 'Depositor contact', + }, + name: { + id: 'field.heldintrusts_common.depositorContact.name', + defaultMessage: 'Contact', + }, + }), + view: { + type: AutocompleteInput, + props: { + source: 'person/local', + }, + }, + }, + }, + depositorContactType: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.depositorContactType.fullName', + defaultMessage: 'Depositor contact type', + }, + name: { + id: 'field.heldintrusts_common.depositorContactType.name', + defaultMessage: 'Contact type', + }, + }), + view: { + type: TermPickerInput, + props: { + source: 'depositorcontacttypes', + }, + }, + }, + }, + depositorNote: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.depositorNote.fullName', + defaultMessage: 'Depositor note', + }, + name: { + id: 'field.heldintrusts_common.depositorNote.name', + defaultMessage: 'Note', + }, + }), + view: { + type: TextInput, + }, + }, + }, + }, + }, + entryMethods: { + [config]: { + view: { + type: CompoundInput, + }, + }, + entryMethod: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.entryMethod.name', + defaultMessage: 'Object entry method', + }, + }), + repeating: true, + view: { + type: TermPickerInput, + props: { + source: 'entrymethod', + }, + }, + }, + }, + }, + agreementGroupList: { + [config]: { + view: { + type: CompoundInput, + }, + }, + agreementGroup: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.agreementGroup.name', + defaultMessage: 'Agreement status', + }, + }), + repeating: true, + view: { + type: CompoundInput, + props: { + tabular: true, + }, + }, + }, + agreementStatus: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.agreementStatus.fullName', + defaultMessage: 'Agreement status', + }, + name: { + id: 'field.heldintrusts_common.agreementStatus.name', + defaultMessage: 'Status', + }, + }), + view: { + type: TermPickerInput, + props: { + source: 'agreementstatuses', + }, + }, + }, + }, + agreementStatusDate: { + [config]: { + dataType: DATA_TYPE_DATE, + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.agreementStatusDate.fullName', + defaultMessage: 'Agreement status date', + }, + name: { + id: 'field.heldintrusts_common.agreementStatusDate.name', + defaultMessage: 'Date', + }, + }), + view: { + type: DateInput, + }, + }, + }, + agreementStatusNote: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.agreementStatusNote.fullName', + defaultMessage: 'Agreement status note', + }, + name: { + id: 'field.heldintrusts_common.agreementStatusNote.name', + defaultMessage: 'Note', + }, + }), + view: { + type: TextInput, + }, + }, + }, + }, + }, + agreementRenewalDates: { + [config]: { + view: { + type: CompoundInput, + }, + }, + agreementRenewalDate: { + [config]: { + dataType: DATA_TYPE_DATE, + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.agreementRenewalDate.name', + defaultMessage: 'Agreement renewal date', + }, + }), + repeating: true, + view: { + type: DateInput, + }, + }, + }, + }, + entryReason: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.entryReason.name', + defaultMessage: 'Object entry reason', + }, + }), + view: { + type: TermPickerInput, + props: { + source: 'heldintrustentryreasons', + }, + }, + }, + }, + returnDate: { + [config]: { + dataType: DATA_TYPE_DATE, + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.returnDate.name', + defaultMessage: 'Object return date', + }, + }), + view: { + type: DateInput, + }, + }, + }, + entryNote: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.entryNote.name', + defaultMessage: 'Entry note', + }, + }), + view: { + type: TextInput, + props: { + multiline: true, + }, + }, + }, + }, + internalApprovalGroupList: { + [config]: { + view: { + type: CompoundInput, + }, + }, + internalApprovalGroup: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.heldInTrustInternalApprovalGroup.name', + defaultMessage: 'Internal approval', + }, + }), + repeating: true, + view: { + type: CompoundInput, + props: { + tabular: true, + }, + }, + }, + internalApprovalGroupName: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.internalApprovalGroupName.fullName', + defaultMessage: 'Internal approval group', + }, + name: { + id: 'field.heldintrusts_common.internalApprovalGroupName.name', + defaultMessage: 'Group', + }, + }), + view: { + type: TermPickerInput, + props: { + source: 'hitapprovalgroups', + }, + }, + }, + }, + internalApprovalIndividual: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.internalApprovalIndividual.fullName', + defaultMessage: 'Internal approval individual', + }, + name: { + id: 'field.heldintrusts_common.internalApprovalIndividual.name', + defaultMessage: 'Individual', + }, + }), + view: { + type: AutocompleteInput, + props: { + source: 'person/local', + }, + }, + }, + }, + internalApprovalStatus: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.internalApprovalStatus.fullName', + defaultMessage: 'Internal approval status', + }, + name: { + id: 'field.heldintrusts_common.internalApprovalStatus.name', + defaultMessage: 'Status', + }, + }), + view: { + type: TermPickerInput, + props: { + source: 'hitapprovaltypes', + }, + }, + }, + }, + internalApprovalDate: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.internalApprovalDate.fullName', + defaultMessage: 'Internal approval date', + }, + name: { + id: 'field.heldintrusts_common.internalApprovalDate.name', + defaultMessage: 'Date', + }, + }), + view: { + type: DateInput, + }, + }, + }, + internalApprovalNote: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.internalApprovalNote.fullName', + defaultMessage: 'Internal approval note', + }, + name: { + id: 'field.heldintrusts_common.internalApprovalNote.name', + defaultMessage: 'Note', + }, + }), + view: { + type: TextInput, + }, + }, + }, + }, + }, + externalApprovalGroupList: { + [config]: { + view: { + type: CompoundInput, + }, + }, + externalApprovalGroup: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.heldInTrustExternalApprovalGroup.name', + defaultMessage: 'External approval', + }, + }), + repeating: true, + view: { + type: CompoundInput, + props: { + tabular: true, + }, + }, + }, + externalApprovalGroupName: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.externalApprovalGroupName.fullName', + defaultMessage: 'External approval group', + }, + name: { + id: 'field.heldintrusts_common.externalApprovalGroupName.name', + defaultMessage: 'Group', + }, + }), + view: { + type: TermPickerInput, + props: { + source: 'hitapprovalgroups', + }, + }, + }, + }, + externalApprovalIndividual: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.externalApprovalIndividual.fullName', + defaultMessage: 'External approval individual', + }, + name: { + id: 'field.heldintrusts_common.externalApprovalIndividual.name', + defaultMessage: 'Individual', + }, + }), + view: { + type: AutocompleteInput, + props: { + source: 'person/local', + }, + }, + }, + }, + externalApprovalStatus: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.externalApprovalStatus.fullName', + defaultMessage: 'External approval status', + }, + name: { + id: 'field.heldintrusts_common.externalApprovalStatus.name', + defaultMessage: 'Status', + }, + }), + view: { + type: TermPickerInput, + props: { + source: 'hitapprovaltypes', + }, + }, + }, + }, + externalApprovalDate: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.externalApprovalDate.fullName', + defaultMessage: 'External approval date', + }, + name: { + id: 'field.heldintrusts_common.externalApprovalDate.name', + defaultMessage: 'Date', + }, + }), + view: { + type: DateInput, + }, + }, + }, + externalApprovalNote: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.externalApprovalNote.fullName', + defaultMessage: 'External approval note', + }, + name: { + id: 'field.heldintrusts_common.externalApprovalNote.name', + defaultMessage: 'Note', + }, + }), + view: { + type: TextInput, + }, + }, + }, + }, + }, + handlingPreferences: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.handlingPreferences.name', + defaultMessage: 'Handling preferences', + }, + }), + view: { + type: TextInput, + props: { + multiline: true, + }, + }, + }, + }, + handlingLimitationsGroupList: { + [config]: { + view: { + type: CompoundInput, + }, + }, + handlingLimitationsGroup: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.handlingLimitationsGroup.name', + defaultMessage: 'Handling limitations', + }, + }), + repeating: true, + view: { + type: CompoundInput, + }, + }, + handlingLimitationsType: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.handlingLimitationsType.fullName', + defaultMessage: 'Handling limitations type', + }, + name: { + id: 'field.heldintrusts_common.handlingLimitationsType.name', + defaultMessage: 'Type', + }, + }), + view: { + type: TermPickerInput, + props: { + source: 'handlinglimitationstypes', + }, + }, + }, + }, + handlingLimitationsRequestor: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.handlingLimitationsRequestor.fullName', + defaultMessage: 'Handling limitations requestor', + }, + name: { + id: 'field.heldintrusts_common.handlingLimitationsRequestor.name', + defaultMessage: 'Requestor', + }, + }), + view: { + type: AutocompleteInput, + props: { + source: 'person/local,organization/local', + }, + }, + }, + }, + handlingLimitationsLevel: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.handlingLimitationsLevel.fullName', + defaultMessage: 'Handling limitations level', + }, + name: { + id: 'field.heldintrusts_common.handlingLimitationsLevel.name', + defaultMessage: 'Level', + }, + }), + view: { + type: TermPickerInput, + props: { + source: 'handlinglimitationslevels', + }, + }, + }, + }, + handlingLimitationsOnBehalfOf: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.handlingLimitationsOnBehalfOf.fullName', + defaultMessage: 'Handling limitations on behalf of', + }, + name: { + id: 'field.heldintrusts_common.handlingLimitationsOnBehalfOf.name', + defaultMessage: 'On behalf of', + }, + }), + view: { + type: AutocompleteInput, + props: { + source: 'person/local,organization/local', + }, + }, + }, + }, + handlingLimitationsDetail: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.handlingLimitationsDetail.fullName', + defaultMessage: 'Handling limitations detail', + }, + name: { + id: 'field.heldintrusts_common.handlingLimitationsDetail.name', + defaultMessage: 'Detail', + }, + }), + view: { + type: TextInput, + }, + }, + }, + handlingLimitationsDate: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.handlingLimitationsDate.fullName', + defaultMessage: 'Handling limitations date', + }, + name: { + id: 'field.heldintrusts_common.handlingLimitationsDate.name', + defaultMessage: 'Date', + }, + }), + view: { + type: DateInput, + }, + }, + }, + }, + }, + correspondenceGroupList: { + [config]: { + view: { + type: CompoundInput, + }, + }, + correspondenceGroup: { + [config]: { + messages: defineMessages({ + name: { + id: 'field.heldintrusts_common.correspondenceGroup.name', + defaultMessage: 'Correspondence', + }, + }), + repeating: true, + view: { + type: CompoundInput, + props: { + tabular: true, + }, + }, + }, + correspondenceDate: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.correspondenceDate.fullName', + defaultMessage: 'Correspondence date', + }, + name: { + id: 'field.heldintrusts_common.correspondenceDate.name', + defaultMessage: 'Date', + }, + }), + view: { + type: DateInput, + }, + }, + }, + correspondenceSender: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.correspondenceSender.fullName', + defaultMessage: 'Correspondence sender', + }, + name: { + id: 'field.heldintrusts_common.correspondenceSender.name', + defaultMessage: 'Sender', + }, + }), + view: { + type: AutocompleteInput, + props: { + source: 'person/local,organization/local', + }, + }, + }, + }, + correspondenceRecipient: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.correspondenceRecipient.fullName', + defaultMessage: 'Correspondence recipient', + }, + name: { + id: 'field.heldintrusts_common.correspondenceRecipient.name', + defaultMessage: 'Recipient', + }, + }), + view: { + type: AutocompleteInput, + props: { + source: 'person/local,organization/local', + }, + }, + }, + }, + correspondenceSummary: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.correspondenceSummary.fullName', + defaultMessage: 'Correspondence summary', + }, + name: { + id: 'field.heldintrusts_common.correspondenceSummary.name', + defaultMessage: 'Summary', + }, + }), + view: { + type: TextInput, + }, + }, + }, + correspondenceReference: { + [config]: { + messages: defineMessages({ + fullName: { + id: 'field.heldintrusts_common.correspondenceReference.fullName', + defaultMessage: 'Correspondence reference', + }, + name: { + id: 'field.heldintrusts_common.correspondenceReference.name', + defaultMessage: 'Reference', + }, + }), + view: { + type: TextInput, + }, + }, + }, + }, + }, + }, + }, + }; +}; diff --git a/src/plugins/recordTypes/heldintrust/forms/default.jsx b/src/plugins/recordTypes/heldintrust/forms/default.jsx new file mode 100644 index 00000000..170b1c6a --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/forms/default.jsx @@ -0,0 +1,136 @@ +import { defineMessages } from 'react-intl'; + +const template = (configContext) => { + const { + React, + } = configContext.lib; + + const { + Row, + Col, + Cols, + Panel, + } = configContext.layoutComponents; + + const { + Field, + } = configContext.recordComponents; + + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default (configContext) => ({ + messages: defineMessages({ + name: { + id: 'form.heldintrust.default.name', + defaultMessage: 'Standard Template', + }, + }), + sortOrder: 0, + template: template(configContext), +}); diff --git a/src/plugins/recordTypes/heldintrust/forms/index.js b/src/plugins/recordTypes/heldintrust/forms/index.js new file mode 100644 index 00000000..b04a0c7d --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/forms/index.js @@ -0,0 +1,5 @@ +import defaultForm from './default'; + +export default (configContext) => ({ + default: defaultForm(configContext), +}); diff --git a/src/plugins/recordTypes/heldintrust/idGenerators.js b/src/plugins/recordTypes/heldintrust/idGenerators.js new file mode 100644 index 00000000..8717a44e --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/idGenerators.js @@ -0,0 +1,13 @@ +import { defineMessages } from 'react-intl'; + +export default { + heldintrust: { + csid: '038b61f2-2975-4b33-ac93-ce8d8b6042f0', + messages: defineMessages({ + type: { + id: 'idGenerator.heldintrust.type', + defaultMessage: 'Held-in-Trust', + }, + }), + }, +}; diff --git a/src/plugins/recordTypes/heldintrust/index.js b/src/plugins/recordTypes/heldintrust/index.js new file mode 100644 index 00000000..1b6a392f --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/index.js @@ -0,0 +1,23 @@ +import advancedSearch from './advancedSearch'; +import columns from './columns'; +import fields from './fields'; +import forms from './forms'; +import messages from './messages'; +import serviceConfig from './serviceConfig'; +import title from './title'; +import idGenerators from './idGenerators'; + +export default () => (configContext) => ({ + idGenerators, + recordTypes: { + heldintrust: { + messages, + serviceConfig, + advancedSearch: advancedSearch(configContext), + columns: columns(configContext), + fields: fields(configContext), + forms: forms(configContext), + title: title(configContext), + }, + }, +}); diff --git a/src/plugins/recordTypes/heldintrust/messages.js b/src/plugins/recordTypes/heldintrust/messages.js new file mode 100644 index 00000000..04d8784d --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/messages.js @@ -0,0 +1,30 @@ +import { defineMessages } from 'react-intl'; + +export default { + record: defineMessages({ + name: { + id: 'record.heldintrust.name', + description: 'The name of the record type.', + defaultMessage: 'Held-in-Trust', + }, + collectionName: { + id: 'record.heldintrust.collectionName', + description: 'The name of a collection of records of the type.', + defaultMessage: 'Held-in-Trust', + }, + }), + panel: defineMessages({ + heldintrust: { + id: 'panel.heldintrust.info', + defaultMessage: 'Held-in-Trust Information', + }, + cultureCareAndHandling: { + id: 'panel.heldintrust.cultureCareAndHandling', + defaultMessage: 'Culture Care and Handling', + }, + correspondence: { + id: 'panel.heldintrust.correspondence', + defaultMessage: 'Correspondence', + }, + }), +}; diff --git a/src/plugins/recordTypes/heldintrust/serviceConfig.js b/src/plugins/recordTypes/heldintrust/serviceConfig.js new file mode 100644 index 00000000..a202db39 --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/serviceConfig.js @@ -0,0 +1,8 @@ +export default { + serviceName: 'Heldintrusts', + servicePath: 'heldintrusts', + serviceType: 'procedure', + + objectName: 'Heldintrust', + documentName: 'heldintrusts', +}; diff --git a/src/plugins/recordTypes/heldintrust/title.js b/src/plugins/recordTypes/heldintrust/title.js new file mode 100644 index 00000000..ba43ddc7 --- /dev/null +++ b/src/plugins/recordTypes/heldintrust/title.js @@ -0,0 +1,25 @@ +export default (configContext) => (data) => { + const { + getPart, + deepGet, + } = configContext.recordDataHelpers; + + const { + getDisplayName, + } = configContext.refNameHelpers; + + if (!data) { + return ''; + } + + const common = getPart(data, 'heldintrusts_common'); + + if (!common) { + return ''; + } + + const hitNumber = common.get('heldInTrustNumber'); + const depositor = getDisplayName(deepGet(common, ['heldInTrustDepositorGroupList', 'heldInTrustDepositorGroup', 0, 'depositor'])); + + return [hitNumber, depositor].filter((part) => !!part).join(' – '); +}; diff --git a/src/plugins/recordTypes/index.js b/src/plugins/recordTypes/index.js index 2e3c35bf..d2f62dac 100644 --- a/src/plugins/recordTypes/index.js +++ b/src/plugins/recordTypes/index.js @@ -17,6 +17,7 @@ import contact from './contact'; import exhibition from './exhibition'; import exxport from './export'; import group from './group'; +import heldintrust from './heldintrust'; import idgenerator from './idgenerator'; import insurance from './insurance'; import intake from './intake'; @@ -62,6 +63,7 @@ export default [ exhibition, exxport, group, + heldintrust, idgenerator, insurance, intake, diff --git a/test/specs/plugins/recordTypes/heldintrust/advancedSearch.spec.js b/test/specs/plugins/recordTypes/heldintrust/advancedSearch.spec.js new file mode 100644 index 00000000..cffd711e --- /dev/null +++ b/test/specs/plugins/recordTypes/heldintrust/advancedSearch.spec.js @@ -0,0 +1,23 @@ +import createConfigContext from '../../../../../src/helpers/createConfigContext'; +import advancedSearch from '../../../../../src/plugins/recordTypes/heldintrust/advancedSearch'; + +chai.should(); + +describe('heldintrust record advanced search', () => { + const configContext = createConfigContext(); + + it('should contain a top level property `op`', () => { + advancedSearch(configContext).should.have.property('op'); + }); + + it('should contain a top level property `value` that is an array', () => { + advancedSearch(configContext).should.have.property('value').that.is.an('array'); + }); + + it('should include a search operation for `heldInTrustNumber`', () => { + advancedSearch(configContext).value.should.include({ + op: configContext.searchOperators.OP_CONTAIN, + path: 'ns2:heldintrusts_common/heldInTrustNumber', + }); + }); +}); diff --git a/test/specs/plugins/recordTypes/heldintrust/columns.spec.js b/test/specs/plugins/recordTypes/heldintrust/columns.spec.js new file mode 100644 index 00000000..8d3503b6 --- /dev/null +++ b/test/specs/plugins/recordTypes/heldintrust/columns.spec.js @@ -0,0 +1,22 @@ +import createColumns from '../../../../../src/plugins/recordTypes/heldintrust/columns'; +import createConfigContext from '../../../../../src/helpers/createConfigContext'; + +chai.should(); + +describe('heldintrust record columns', () => { + const configContext = createConfigContext(); + const columns = createColumns(configContext); + + it('should have the correct shape', () => { + columns.should.have.property('default').that.is.an('object'); + }); + + it('should have depositor source column that is formatted as a refname display name', () => { + const { depositor } = columns.default; + + depositor.should.have.property('formatValue').that.is.a('function'); + + depositor.formatValue('urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(johndoe)\'John Doe\'').should + .equal('John Doe'); + }); +}); diff --git a/test/specs/plugins/recordTypes/heldintrust/forms/default.spec.js b/test/specs/plugins/recordTypes/heldintrust/forms/default.spec.js new file mode 100644 index 00000000..ef941cf3 --- /dev/null +++ b/test/specs/plugins/recordTypes/heldintrust/forms/default.spec.js @@ -0,0 +1,14 @@ +import Field from '../../../../../../src/components/record/Field'; +import form from '../../../../../../src/plugins/recordTypes/heldintrust/forms/default'; +import createConfigContext from '../../../../../../src/helpers/createConfigContext'; + +chai.should(); + +describe('heldintrust record default form', () => { + it('should be a Field', () => { + const configContext = createConfigContext(); + const { template } = form(configContext); + + template.type.should.equal(Field); + }); +}); diff --git a/test/specs/plugins/recordTypes/heldintrust/index.spec.js b/test/specs/plugins/recordTypes/heldintrust/index.spec.js new file mode 100644 index 00000000..5e32610c --- /dev/null +++ b/test/specs/plugins/recordTypes/heldintrust/index.spec.js @@ -0,0 +1,30 @@ +import heldintrustRecordTypePluginFactor from '../../../../../src/plugins/recordTypes/heldintrust'; +import createConfigContext from '../../../../../src/helpers/createConfigContext'; + +chai.should(); + +describe('heldintrust record plugin', () => { + const config = {}; + const heldInTrustRecordType = heldintrustRecordTypePluginFactor(config); + const configContext = createConfigContext(); + + it('should have the correct shape', () => { + const pluginConfigContribution = heldInTrustRecordType(configContext); + + const { + recordTypes, + } = pluginConfigContribution; + + recordTypes.should.have.property('heldintrust'); + + const heldInTrustRecordTypes = recordTypes.heldintrust; + + heldInTrustRecordTypes.should.have.property('messages').that.is.an('object'); + heldInTrustRecordTypes.should.have.property('serviceConfig').that.is.an('object'); + heldInTrustRecordTypes.should.have.property('title').that.is.a('function'); + heldInTrustRecordTypes.should.have.property('forms').that.is.an('object'); + heldInTrustRecordTypes.should.have.property('fields').that.is.a('object'); + heldInTrustRecordTypes.should.have.property('columns').that.is.an('object'); + heldInTrustRecordTypes.should.have.property('advancedSearch').that.is.an('object'); + }); +}); diff --git a/test/specs/plugins/recordTypes/heldintrust/messages.spec.js b/test/specs/plugins/recordTypes/heldintrust/messages.spec.js new file mode 100644 index 00000000..7ce7c0a6 --- /dev/null +++ b/test/specs/plugins/recordTypes/heldintrust/messages.spec.js @@ -0,0 +1,17 @@ +import messages from '../../../../../src/plugins/recordTypes/heldintrust/messages'; + +chai.should(); + +describe('heldintrust record messages', () => { + it('should contain properties with id and defaultMessage properties', () => { + messages.should.be.an('object'); + + Object.keys(messages).forEach((message) => { + const heldInTrustMessage = messages[message]; + + Object.keys(heldInTrustMessage).forEach((name) => { + heldInTrustMessage[name].should.contain.all.keys(['id', 'defaultMessage']); + }); + }); + }); +}); diff --git a/test/specs/plugins/recordTypes/heldintrust/serviceConfig.spec.js b/test/specs/plugins/recordTypes/heldintrust/serviceConfig.spec.js new file mode 100644 index 00000000..7dfeaab1 --- /dev/null +++ b/test/specs/plugins/recordTypes/heldintrust/serviceConfig.spec.js @@ -0,0 +1,13 @@ +import serviceConfig from '../../../../../src/plugins/recordTypes/heldintrust/serviceConfig'; + +chai.should(); + +describe('heldintrust record serviceConfig', () => { + it('should have servicePath property', () => { + serviceConfig.should.have.property('servicePath').that.is.a('string'); + serviceConfig.should.have.property('serviceName').that.is.a('string'); + serviceConfig.should.have.property('serviceType').that.is.a('string'); + serviceConfig.should.have.property('objectName').that.is.a('string'); + serviceConfig.should.have.property('documentName').that.is.a('string'); + }); +}); diff --git a/test/specs/plugins/recordTypes/heldintrust/title.spec.js b/test/specs/plugins/recordTypes/heldintrust/title.spec.js new file mode 100644 index 00000000..c36ed0d8 --- /dev/null +++ b/test/specs/plugins/recordTypes/heldintrust/title.spec.js @@ -0,0 +1,78 @@ +import Immutable from 'immutable'; +import createTitleGetter from '../../../../../src/plugins/recordTypes/heldintrust/title'; +import createConfigContext from '../../../../../src/helpers/createConfigContext'; + +chai.should(); + +describe('heldintrust record title', () => { + const configContext = createConfigContext(); + const title = createTitleGetter(configContext); + + it('should concat the Held-in-Trust number and the depositor', () => { + const data = Immutable.fromJS({ + document: { + 'ns2:heldintrusts_common': { + heldInTrustNumber: 'HIT2023.1', + heldInTrustDepositorGroupList: { + heldInTrustDepositorGroup: { + depositor: 'urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Depositor)\'Depositor\'', + }, + }, + }, + }, + }); + + title(data).should.equal('HIT2023.1 – Depositor'); + }); + + it('should return the Held-in-Trust number when the depositor is empty', () => { + const data = Immutable.fromJS({ + document: { + 'ns2:heldintrusts_common': { + heldInTrustNumber: 'HIT2023.1', + heldInTrustDepositorGroupList: { + heldInTrustDepositorGroup: { + depositor: '', + }, + }, + }, + }, + }); + + title(data).should.equal('HIT2023.1'); + }); + + it('should return the depositor when the Held-in-Trust number is empty', () => { + const data = Immutable.fromJS({ + document: { + 'ns2:heldintrusts_common': { + heldInTrustNumber: '', + heldInTrustDepositorGroupList: { + heldInTrustDepositorGroup: { + depositor: 'urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Depositor)\'Depositor\'', + }, + }, + }, + }, + }); + + title(data).should.equal('Depositor'); + }); + + it('should return empty string if no data is passed', () => { + title(null).should.equal(''); + title(undefined).should.equal(''); + }); + + it('should return empty string if the common part is not present', () => { + const data = Immutable.fromJS({ + data: { + 'ns2:heldintrusts_extension': { + heldInTrustNumber: 'Something', + }, + }, + }); + + title(data).should.equal(''); + }); +});