Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions specifyweb/backend/context/app_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
"invertebrate": "invertebrate",
"geology": "geology",
}
DISCIPLINE_NAMES = {
'fish': 'Fish',
'herpetology': 'Herpetology',
'paleobotany': 'Paleobotany',
'invertpaleo': 'Invertebrate Paleontology',
'vertpaleo': 'Vertebrate Paleontology',
'bird': 'Bird',
'mammal': 'Mammal',
'insect': 'Insect',
'botany': 'Botany',
'invertebrate': 'Invertebrate',
'geology': 'Geology',
}

FORM_RESOURCE_EXCLUDED_LST = [
"fish/fishbase.views.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Input, Label } from '../Atoms/Form';
import { icons } from '../Atoms/Icons';
import { Link } from '../Atoms/Link';
import { Dialog } from '../Molecules/Dialog';
import { hasPermission } from '../Permissions/helpers';
import {
allAppResources,
countAppResources,
Expand All @@ -23,7 +24,6 @@ import {
} from './filtersHelpers';
import type { AppResources } from './hooks';
import { appResourceSubTypes, appResourceTypes } from './types';
import { hasPermission } from '../Permissions/helpers';

export function AppResourcesFilters({
initialResources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { loadingBar } from '../Molecules';
import { Dialog } from '../Molecules/Dialog';
import { FilePicker } from '../Molecules/FilePicker';
import { ProtectedTable } from '../Permissions/PermissionDenied';
import { collectionPreferences } from '../Preferences/collectionPreferences';
import { userPreferences } from '../Preferences/userPreferences';
import { AttachmentPluginSkeleton } from '../SkeletonLoaders/AttachmentPlugin';
import { attachmentSettingsPromise, uploadFile } from './attachments';
import { AttachmentViewer } from './Viewer';
import { collectionPreferences } from '../Preferences/collectionPreferences';

export function AttachmentsPlugin(
props: Parameters<typeof ProtectedAttachmentsPlugin>[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { strictGetTable } from '../DataModel/tables';
import type { Attachment, Tables } from '../DataModel/types';
import { Dialog } from '../Molecules/Dialog';
import { hasPermission } from '../Permissions/helpers';
import { collectionPreferences } from '../Preferences/collectionPreferences';
import { ActionState } from './ActionState';
import type { AttachmentUploadSpec, EagerDataSet } from './Import';
import { PerformAttachmentTask } from './PerformAttachmentTask';
Expand All @@ -39,7 +40,6 @@ import {
saveForAttachmentUpload,
validateAttachmentFiles,
} from './utils';
import { collectionPreferences } from '../Preferences/collectionPreferences';

async function prepareForUpload(
dataSet: EagerDataSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ export class BusinessRuleManager<SCHEMA extends AnySchema> {
fieldName: string &
(keyof SCHEMA['fields'] | keyof SCHEMA['toOneIndependent'])
): Promise<RA<BusinessRuleResult<SCHEMA>>> {
// REFACTOR: When checkField is called directly, the promises are not
// added to the public pendingPromise
/*
* REFACTOR: When checkField is called directly, the promises are not
* added to the public pendingPromise
*/

const field = this.resource.specifyTable.getField(fieldName);
if (field === undefined) return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ describe('getDateParser', () => {
new Date()
)
).toMatchInlineSnapshot(`
{
"formatters": [
[Function],
[Function],
],
"max": "9999-12-31",
"minLength": 10,
"parser": [Function],
"required": false,
"title": "Required Format: MM/DD/YYYY.",
"type": "date",
"validators": [
[Function],
],
"value": "2022-08-31",
"whiteSpaceSensitive": false,
}
`));
{
"formatters": [
[Function],
[Function],
],
"max": "9999-12-31",
"minLength": 10,
"parser": [Function],
"required": false,
"title": "Required Format: MM/DD/YYYY.",
"type": "date",
"validators": [
[Function],
],
"value": "2022-08-31",
"whiteSpaceSensitive": false,
}
`));

test('month-year', () =>
expect(getDateParser(undefined, 'month-year', undefined))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import type { GetSet, WritableArray } from '../../utils/types';
import { Link } from '../Atoms/Link';
import { pathIsOverlay } from '../Router/UnloadProtect';
import { scrollIntoView } from '../TreeView/helpers';
import { PreferenceType, usePrefDefinitions } from './index';
import type { PreferenceType } from './index';
import { usePrefDefinitions } from './index';

export function PreferencesAside({
activeCategory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LocalizedString } from 'typesafe-i18n';
import type { LocalizedString } from 'typesafe-i18n';

import { attachmentsText } from '../../localization/attachments';
import { preferencesText } from '../../localization/preferences';
import { queryText } from '../../localization/query';
Expand All @@ -8,13 +9,13 @@ import { treeText } from '../../localization/tree';
import { f } from '../../utils/functools';
import type { RA } from '../../utils/types';
import { ensure } from '../../utils/types';
import { camelToHuman } from '../../utils/utils';
import { genericTables } from '../DataModel/tables';
import { Tables } from '../DataModel/types';
import type { Tables } from '../DataModel/types';
import type { QueryView } from '../QueryBuilder/Header';
import type { StatLayout } from '../Statistics/types';
import type { GenericPreferences } from './types';
import { definePref } from './types';
import { camelToHuman } from '../../utils/utils';
import { QueryView } from '../QueryBuilder/Header';

const tableLabel = (tableName: keyof Tables): LocalizedString =>
genericTables[tableName]?.label ?? camelToHuman(tableName);
Expand Down
74 changes: 35 additions & 39 deletions specifyweb/frontend/js_src/lib/components/Preferences/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import type { LocalizedString } from 'typesafe-i18n';
import { usePromise } from '../../hooks/useAsyncState';
import { useBooleanState } from '../../hooks/useBooleanState';
import { commonText } from '../../localization/common';
import { headerText } from '../../localization/header';
import { preferencesText } from '../../localization/preferences';
import { StringToJsx } from '../../localization/utils';
import { f } from '../../utils/functools';
import type { IR } from '../../utils/types';
import { Container, H2, Key } from '../Atoms';
import { Button } from '../Atoms/Button';
import { className } from '../Atoms/className';
Expand All @@ -21,22 +23,20 @@ import { Submit } from '../Atoms/Submit';
import { LoadingContext, ReadOnlyContext } from '../Core/Contexts';
import { ErrorBoundary } from '../Errors/ErrorBoundary';
import { hasPermission } from '../Permissions/helpers';
import {
ProtectedAction,
ProtectedTool,
} from '../Permissions/PermissionDenied';
import { PreferencesAside } from './Aside';
import type { BasePreferences } from './BasePreferences';
import { collectionPreferenceDefinitions } from './CollectionDefinitions';
import { collectionPreferences } from './collectionPreferences';
import { useDarkMode } from './Hooks';
import { DefaultPreferenceItemRender } from './Renderers';
import type { GenericPreferences, PreferenceItem } from './types';
import { userPreferenceDefinitions } from './UserDefinitions';
import { userPreferences } from './userPreferences';
import { useTopChild } from './useTopChild';
import { IR } from '../../utils/types';
import { headerText } from '../../localization/header';
import { BasePreferences } from './BasePreferences';
import {
ProtectedAction,
ProtectedTool,
} from '../Permissions/PermissionDenied';
import { collectionPreferenceDefinitions } from './CollectionDefinitions';

export type PreferenceType = keyof typeof preferenceInstances;

Expand Down Expand Up @@ -142,9 +142,9 @@ function Preferences({
>
<PreferencesAside
activeCategory={visibleChild}
prefType={prefType}
references={references}
setActiveCategory={setVisibleChild}
prefType={prefType}
/>
<PreferencesContent forwardRefs={forwardRefs} prefType={prefType} />
<span className="flex-1" />
Expand Down Expand Up @@ -323,9 +323,7 @@ export function PreferencesContent({
/>
</p>
{item.description !== undefined && (
<p
className={`flex flex-1 text-gray-500 md:text-right justify-end`}
>
<p className="flex flex-1 text-gray-500 md:text-right justify-end">
{item.description !== undefined && (
<FormatString
text={
Expand Down Expand Up @@ -383,31 +381,29 @@ export function PreferencesContent({
(
[category, { title, description = undefined, subCategories }],
index
) => {
return (
<ErrorBoundary dismissible key={category}>
<Container.Center
className="gap-8 overflow-y-visible"
forwardRef={forwardRefs?.bind(undefined, index)}
id={category}
>
<h3 className="text-2xl">
{typeof title === 'function' ? title() : title}
</h3>
{description !== undefined && (
<p>
{typeof description === 'function'
? description()
: description}
</p>
)}
{subCategories.map(([subcategory, data]) =>
renderSubCategory(category, subcategory, data)
)}
</Container.Center>
</ErrorBoundary>
);
}
) => (
<ErrorBoundary dismissible key={category}>
<Container.Center
className="gap-8 overflow-y-visible"
forwardRef={forwardRefs?.bind(undefined, index)}
id={category}
>
<h3 className="text-2xl">
{typeof title === 'function' ? title() : title}
</h3>
{description !== undefined && (
<p>
{typeof description === 'function'
? description()
: description}
</p>
)}
{subCategories.map(([subcategory, data]) =>
renderSubCategory(category, subcategory, data)
)}
</Container.Center>
</ErrorBoundary>
)
)}
</div>
);
Expand Down Expand Up @@ -484,7 +480,7 @@ function UserPrefItem<T>(props: PreferenceItemProps<T>) {
props.subcategory as any,
props.name as any
);
return <ItemBase {...props} value={value} setValue={setValue} />;
return <ItemBase {...props} setValue={setValue} value={value} />;
}

function CollectionPrefItem<T>(props: PreferenceItemProps<T>) {
Expand All @@ -493,7 +489,7 @@ function CollectionPrefItem<T>(props: PreferenceItemProps<T>) {
props.subcategory as any,
props.name as any
);
return <ItemBase {...props} value={value} setValue={setValue} />;
return <ItemBase {...props} setValue={setValue} value={value} />;
}

function CollectionPreferences(): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import { DeleteButton } from '../Forms/DeleteButton';
import { Dialog } from '../Molecules/Dialog';
import { ResourceLink } from '../Molecules/ResourceLink';
import { hasPermission, hasTablePermission } from '../Permissions/helpers';
import { collectionPreferences } from '../Preferences/collectionPreferences';
import type { Row } from './helpers';
import { checkMoveViolatesEnforced } from './helpers';
import { collectionPreferences } from '../Preferences/collectionPreferences';

const treeActions = [
'add',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ import { loadingBar } from '../Molecules';
import { Dialog } from '../Molecules/Dialog';
import { FilePicker } from '../Molecules/FilePicker';
import { Preview } from '../Molecules/FilePicker';
import { collectionPreferences } from '../Preferences/collectionPreferences';
import { uniquifyDataSetName } from '../WbImport/helpers';
import { ChooseName } from '../WbImport/index';
import {
ATTACHMENTS_COLUMN,
attachmentsToCell,
BASE_TABLE_NAME,
} from '../WorkBench/attachmentHelpers';
import { collectionPreferences } from '../Preferences/collectionPreferences';

export function WbImportAttachmentsView(): JSX.Element {
useMenuItem('workBench');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ theories(
* TODO: The tests are mapping these Taxon headers to Component
* over Determination. The issue is not happening within the
* application
* */
// 'Class',
// 'Superfamily',
// 'Family',
// 'Genus',
// 'Subgenus',
// 'Species',
// 'Subspecies',
// 'Species Author',
// 'Subspecies Author',
*
*/
/*
* 'Class',
* 'Superfamily',
* 'Family',
* 'Genus',
* 'Subgenus',
* 'Species',
* 'Subspecies',
* 'Species Author',
* 'Subspecies Author',
*/
'Who ID First Name',
'Determiner 1 Title',
'Determiner 1 First Name',
Expand Down Expand Up @@ -184,18 +187,20 @@ theories(
Latitude2: [['collectingEvent', 'locality', 'latitude2']],
Longitude1: [['collectingEvent', 'locality', 'longitude1']],
Longitude2: [['collectingEvent', 'locality', 'longitude2']],
// Class: [['determinations', '#1', 'taxon', '$Class', 'name']],
// Family: [['determinations', '#1', 'taxon', '$Family', 'name']],
// Genus: [['determinations', '#1', 'taxon', '$Genus', 'name']],
// Subgenus: [['determinations', '#1', 'taxon', '$Subgenus', 'name']],
// 'Species Author': [
// ['determinations', '#1', 'taxon', '$Species', 'author'],
// ],
// Species: [['determinations', '#1', 'taxon', '$Species', 'name']],
// 'Subspecies Author': [
// ['determinations', '#1', 'taxon', '$Subspecies', 'author'],
// ],
// Subspecies: [['determinations', '#1', 'taxon', '$Subspecies', 'name']],
/*
* Class: [['determinations', '#1', 'taxon', '$Class', 'name']],
* Family: [['determinations', '#1', 'taxon', '$Family', 'name']],
* Genus: [['determinations', '#1', 'taxon', '$Genus', 'name']],
* Subgenus: [['determinations', '#1', 'taxon', '$Subgenus', 'name']],
* 'Species Author': [
* ['determinations', '#1', 'taxon', '$Species', 'author'],
* ],
* Species: [['determinations', '#1', 'taxon', '$Species', 'name']],
* 'Subspecies Author': [
* ['determinations', '#1', 'taxon', '$Subspecies', 'author'],
* ],
* Subspecies: [['determinations', '#1', 'taxon', '$Subspecies', 'name']],
*/
'Prep Type 1': [['preparations', '#1', 'prepType', 'name']],
Country: [
['collectingEvent', 'locality', 'geography', '$Country', 'name'],
Expand Down
Loading