Skip to content

Commit

Permalink
Merge branch 'production' into dev-notifs
Browse files Browse the repository at this point in the history
  • Loading branch information
combs-a authored Jul 15, 2024
2 parents dba67ce + 4c32cd4 commit 2fc2223
Show file tree
Hide file tree
Showing 32 changed files with 765 additions and 144 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [7.9.6.1](https://github.com/specify/specify7/compare/v7.9.6...v7.9.6.1) (9 July 2024)

- Fixes an issue that led to tree definition item separators being trimmed ([#5076](https://github.com/specify/specify7/pull/5076))
- The form system now includes a `whiteSpaceSensitive` attribute, which allows any field to preserve whitespace upon saving

## [7.9.6](https://github.com/specify/specify7/compare/v7.9.5...v7.9.6) (1 July 2024)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function AppResourceEditor({
onAdd={
hasToolPermission('resources', 'create') &&
typeof handleClone === 'function'
? (newResource): void => {
? ([newResource]): void => {
const resource = serializeResource(newResource);
const isClone = typeof resource.spAppResourceDir === 'string';
handleClone(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ theories(getTableOverwrite, [
]);

theories(getGlobalFieldOverwrite, [
{ in: ['Taxon', 'isAccepted'], out: 'readOnly' },
{ in: ['Geography', 'timestampCreated'], out: 'readOnly' },
{ in: ['Taxon', 'isAccepted'], out: { visibility: 'readOnly' } },
{ in: ['Geography', 'timestampCreated'], out: { visibility: 'readOnly' } },
{
in: ['TaxonTreeDefItem', 'fullNameSeparator'],
out: { whiteSpaceSensitive: true },
},
{ in: ['SpecifyUser', 'id'], out: undefined },
]);

theories(getFieldOverwrite, [
{ in: ['Taxon', 'timestampCreated'], out: 'hidden' },
{ in: ['Agent', 'agentType'], out: 'optional' },
{ in: ['Taxon', 'timestampCreated'], out: { visibility: 'hidden' } },
{ in: ['Agent', 'agentType'], out: { visibility: 'optional' } },
{ in: ['Agent', 'lastName'], out: undefined },
{ in: ['Attachment', 'collectingTripAttachments'], out: 'hidden' },
{
in: ['Attachment', 'collectingTripAttachments'],
out: { visibility: 'hidden' },
},
]);
151 changes: 85 additions & 66 deletions specifyweb/frontend/js_src/lib/components/DataModel/schemaOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ export type TableConfigOverwrite =
*/
| 'system';

export type FieldConfigOverwrite =
// Makes a required field optional
| 'optional'
| 'required'
// Removes a field from the mapper (but not from Query Builder)
| 'readOnly'
// Hides a field. If it was required, it is made optional
| 'hidden';
type FieldConfigOverwrite = Partial<{
readonly visibility:
| 'optional' // Makes a required field optional
| 'required'
// Removes a field from the mapper (but not from Query Builder)
| 'readOnly'
// Hides a field. If it was required, it is made optional
| 'hidden';

// Indicates white space should not be ignored in the field
readonly whiteSpaceSensitive: true;
}>;

const tableOverwrites: Partial<RR<keyof Tables, TableConfigOverwrite>> = {
Accession: 'commonBaseTable',
Expand Down Expand Up @@ -100,78 +104,93 @@ const globalFieldOverrides: {
} = {
// Common overwrites apply to fields in all tables
common: {
timestampCreated: 'readOnly',
timestampCreated: { visibility: 'readOnly' },
/**
* This is read only in default forms, but not in schema config.
* That causes problems as field is editable in autogenerated view.
*/
timestampModified: 'readOnly',
timestampModified: { visibility: 'readOnly' },
},
Attachment: {
tableID: 'optional',
tableID: { visibility: 'optional' },
},
CollectionRelationship: {
collectionRelType: 'required',
collectionRelType: { visibility: 'required' },
},
CollectionRelType: {
name: 'required',
name: { visibility: 'required' },
},
DNASequence: {
totalResidues: 'readOnly',
compA: 'readOnly',
compG: 'readOnly',
compC: 'readOnly',
compT: 'readOnly',
ambiguousResidues: 'readOnly',
totalResidues: { visibility: 'readOnly' },
compA: { visibility: 'readOnly' },
compG: { visibility: 'readOnly' },
compC: { visibility: 'readOnly' },
compT: { visibility: 'readOnly' },
ambiguousResidues: { visibility: 'readOnly' },
},
Taxon: {
parent: 'required',
isAccepted: 'readOnly',
acceptedTaxon: 'readOnly',
fullName: 'readOnly',
parent: { visibility: 'required' },
isAccepted: { visibility: 'readOnly' },
acceptedTaxon: { visibility: 'readOnly' },
fullName: { visibility: 'readOnly' },
},
Geography: {
parent: 'required',
isAccepted: 'readOnly',
acceptedGeography: 'readOnly',
fullName: 'readOnly',
parent: { visibility: 'required' },
isAccepted: { visibility: 'readOnly' },
acceptedGeography: { visibility: 'readOnly' },
fullName: { visibility: 'readOnly' },
},
LithoStrat: {
parent: 'required',
isAccepted: 'readOnly',
acceptedLithoStrat: 'readOnly',
fullName: 'readOnly',
parent: { visibility: 'required' },
isAccepted: { visibility: 'readOnly' },
acceptedLithoStrat: { visibility: 'readOnly' },
fullName: { visibility: 'readOnly' },
},
GeologicTimePeriod: {
parent: 'required',
isAccepted: 'readOnly',
acceptedGeologicTimePeriod: 'readOnly',
fullName: 'readOnly',
parent: { visibility: 'required' },
isAccepted: { visibility: 'readOnly' },
acceptedGeologicTimePeriod: { visibility: 'readOnly' },
fullName: { visibility: 'readOnly' },
},
Storage: {
parent: 'required',
isAccepted: 'readOnly',
acceptedStorage: 'readOnly',
fullName: 'readOnly',
parent: { visibility: 'required' },
isAccepted: { visibility: 'readOnly' },
acceptedStorage: { visibility: 'readOnly' },
fullName: { visibility: 'readOnly' },
},
SpecifyUser: {
isAdmin: 'readOnly',
password: 'hidden',
isAdmin: { visibility: 'readOnly' },
password: { visibility: 'hidden' },
},
TaxonTreeDef: {
fullNameDirection: 'readOnly',
fullNameDirection: { visibility: 'readOnly' },
},
TaxonTreeDefItem: {
fullNameSeparator: { whiteSpaceSensitive: true },
},
GeographyTreeDef: {
fullNameDirection: 'readOnly',
fullNameDirection: { visibility: 'readOnly' },
},
GeographyTreeDefItem: {
fullNameSeparator: { whiteSpaceSensitive: true },
},
StorageTreeDef: {
fullNameDirection: 'readOnly',
fullNameDirection: { visibility: 'readOnly' },
},
StorageTreeDefItem: {
fullNameSeparator: { whiteSpaceSensitive: true },
},
GeologicTimePeriodTreeDef: {
fullNameDirection: 'readOnly',
fullNameDirection: { visibility: 'readOnly' },
},
GeologicTimePeriodTreeDefItem: {
fullNameSeparator: { whiteSpaceSensitive: true },
},
LithoStratTreeDef: {
fullNameDirection: 'readOnly',
fullNameDirection: { visibility: 'readOnly' },
},
LithoStratTreeDefItem: {
fullNameSeparator: { whiteSpaceSensitive: true },
},
};

Expand All @@ -183,35 +202,35 @@ const globalFieldOverrides: {
*/
const fieldOverwrites: typeof globalFieldOverrides = {
common: {
timestampCreated: 'hidden',
timestampModified: 'hidden',
createdByAgent: 'hidden',
modifiedByAgent: 'hidden',
collectionMemberId: 'hidden',
rankId: 'hidden',
definition: 'hidden',
definitionItem: 'hidden',
orderNumber: 'hidden',
isPrimary: 'hidden',
isHybrid: 'hidden',
isAccepted: 'hidden',
fullName: 'readOnly',
timestampCreated: { visibility: 'hidden' },
timestampModified: { visibility: 'hidden' },
createdByAgent: { visibility: 'hidden' },
modifiedByAgent: { visibility: 'hidden' },
collectionMemberId: { visibility: 'hidden' },
rankId: { visibility: 'hidden' },
definition: { visibility: 'hidden' },
definitionItem: { visibility: 'hidden' },
orderNumber: { visibility: 'hidden' },
isPrimary: { visibility: 'hidden' },
isHybrid: { visibility: 'hidden' },
isAccepted: { visibility: 'hidden' },
fullName: { visibility: 'readOnly' },
},
Agent: {
agentType: 'optional',
agentType: { visibility: 'optional' },
},
LoanPreparation: {
isResolved: 'optional',
isResolved: { visibility: 'optional' },
},
Locality: {
srcLatLongUnit: 'optional',
srcLatLongUnit: { visibility: 'optional' },
},
PrepType: {
isLoanable: 'readOnly',
isLoanable: { visibility: 'readOnly' },
},
Determination: {
preferredTaxon: 'readOnly',
isCurrent: 'hidden',
preferredTaxon: { visibility: 'readOnly' },
isCurrent: { visibility: 'hidden' },
},
};

Expand All @@ -224,7 +243,7 @@ const endsWithFieldOverwrites: Partial<
RR<keyof Tables | 'common', IR<FieldConfigOverwrite>>
> = {
Attachment: {
Attachments: 'hidden',
Attachments: { visibility: 'hidden' },
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,13 @@ export abstract class FieldBase {
const globalFieldOverride = getGlobalFieldOverwrite(table.name, this.name);

this.isReadOnly =
globalFieldOverride === 'readOnly' || fieldDefinition.readOnly === true;
globalFieldOverride?.visibility === 'readOnly' ||
fieldDefinition.readOnly === true;

this.isRequired =
globalFieldOverride === 'required'
globalFieldOverride?.visibility === 'required'
? true
: globalFieldOverride === 'optional'
: globalFieldOverride?.visibility === 'optional'
? false
: fieldDefinition.required;
this.type = fieldDefinition.type;
Expand All @@ -151,18 +152,21 @@ export abstract class FieldBase {
: camelToHuman(this.name);

this.isHidden =
globalFieldOverride === 'hidden' || (this.localization.ishidden ?? false);
globalFieldOverride?.visibility === 'hidden' ||
(this.localization.ishidden ?? false);

// Apply overrides
const fieldOverwrite = getFieldOverwrite(this.table.name, this.name);

let isRequired = fieldOverwrite !== 'optional' && this.isRequired;
let isRequired =
fieldOverwrite?.visibility !== 'optional' && this.isRequired;
let isHidden = this.isHidden;

const isReadOnly = this.isReadOnly || fieldOverwrite === 'readOnly';
const isReadOnly =
this.isReadOnly || fieldOverwrite?.visibility === 'readOnly';

// Overwritten hidden fields are made not required
if (fieldOverwrite === 'hidden') {
if (fieldOverwrite?.visibility === 'hidden') {
isRequired = false;
isHidden = true;
}
Expand Down Expand Up @@ -250,9 +254,19 @@ export class LiteralField extends FieldBase {

public readonly isRelationship: false = false;

// Indicates white space should not be ignored in the field
public readonly whiteSpaceSensitive: boolean;

public constructor(table: SpecifyTable, fieldDefinition: FieldDefinition) {
super(table, fieldDefinition);
this.type = fieldDefinition.type;

const globalFieldOverride = getGlobalFieldOverwrite(table.name, this.name);
const fieldOverwrite = getFieldOverwrite(table.name, this.name);

this.whiteSpaceSensitive =
(globalFieldOverride?.whiteSpaceSensitive ?? false) ||
(fieldOverwrite?.whiteSpaceSensitive ?? false);
}

// Returns the name of the UIFormatter for the field from the schema config.
Expand Down
Loading

0 comments on commit 2fc2223

Please sign in to comment.