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
20 changes: 0 additions & 20 deletions specifyweb/backend/context/data/viewset_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,6 @@
<row>
<cell colspan="5" label="TAXON_TREE" type="separator" />
</row>
<row>
<cell label="TT_SHOW_COUNTS_BELOW" labelfor="1" type="label" />
<cell colspan="3" id="1" ignore="true" name="TreeEditor.Rank.Threshold.Taxon" type="field" uitype="combobox" />
</row>
<row>
<cell label="TT_COL_CLR_1" labelfor="TreeColColor1.Taxon" type="label" />
<cell id="TreeColColor1.Taxon" name="Treeeditor.TreeColColor1.Taxon" type="field" uitype="colorchooser" />
Expand All @@ -582,10 +578,6 @@
<row>
<cell colspan="5" label="GEO_TREE" type="separator" />
</row>
<row>
<cell label="GT_SHOW_COUNTS_BELOW" labelfor="2" type="label" />
<cell colspan="3" id="2" ignore="true" name="TreeEditor.Rank.Threshold.Geography" type="field" uitype="combobox" />
</row>
<row>
<cell label="GT_COL_CLR_1" labelfor="TreeColColor1.Geography" type="label" />
<cell id="TreeColColor1.Geography" name="Treeeditor.TreeColColor1.Geography" type="field" uitype="colorchooser" />
Expand All @@ -608,10 +600,6 @@
<row>
<cell colspan="5" label="LITHO_TREE" type="separator" />
</row>
<row>
<cell label="LT_SHOW_COUNTS_BELOW" labelfor="3" type="label" />
<cell colspan="3" id="3" ignore="true" name="TreeEditor.Rank.Threshold.LithoStrat" type="field" uitype="combobox" />
</row>
<row>
<cell label="LT_COL_CLR_1" labelfor="TreeColColor1.LithoStrat" type="label" />
<cell id="TreeColColor1.LithoStrat" name="Treeeditor.TreeColColor1.LithoStrat" type="field" uitype="colorchooser" />
Expand All @@ -631,10 +619,6 @@
<row>
<cell colspan="5" label="GEO_PERIOD_TREE" type="separator" />
</row>
<row>
<cell label="GP_SHOW_COUNTS_BELOW" labelfor="4" type="label" />
<cell colspan="3" id="4" ignore="true" name="TreeEditor.Rank.Threshold.GeologicTimePeriod" type="field" uitype="combobox" />
</row>
<row>
<cell label="GP_COL_CLR_1" labelfor="TreeColColor1.GeologicTimePeriod" type="label" />
<cell id="TreeColColor1.GeologicTimePeriod" name="Treeeditor.TreeColColor1.GeologicTimePeriod" type="field" uitype="colorchooser" />
Expand All @@ -656,10 +640,6 @@
<row>
<cell colspan="5" label="STORAGE_TREE" type="separator" />
</row>
<row>
<cell label="ST_SHOW_COUNTS_BELOW" labelfor="5" type="label" />
<cell colspan="3" id="5" ignore="true" name="TreeEditor.Rank.Threshold.Storage" type="field" uitype="combobox" />
</row>
<row>
<cell label="ST_COL_CLR_1" labelfor="TreeColColor1.Storage" type="label" />
<cell id="TreeColColor1.Storage" name="Treeeditor.TreeColColor1.Storage" type="field" uitype="colorchooser" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { softFail } from '../Errors/Crash';
import { isTreeResource } from '../InitialContext/treeRanks';
import type { BusinessRuleDefs } from './businessRuleDefs';
import { businessRuleDefs } from './businessRuleDefs';
import { backboneFieldSeparator, backendFilter, djangoLookupSeparator } from './helpers';
import {
backboneFieldSeparator,
backendFilter,
djangoLookupSeparator,
} from './helpers';
import type {
AnySchema,
AnyTree,
Expand Down Expand Up @@ -316,10 +320,7 @@ export class BusinessRuleManager<SCHEMA extends AnySchema> {
)
);

const stringValuesAreEqual = (
left: string,
right: string
): boolean =>
const stringValuesAreEqual = (left: string, right: string): boolean =>
rule.isDatabaseConstraint
? left.localeCompare(right, undefined, { sensitivity: 'accent' }) === 0
: left === right;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { ensure, localized } from '../../../utils/types';
import { removeKey } from '../../../utils/utils';
import { strictParseXml } from '../../AppResources/parseXml';
import { tables } from '../../DataModel/tables';
import { getPref } from '../../InitialContext/remotePrefs';
import { formatUrl } from '../../Router/queryString';
import type { SimpleXmlNode } from '../../Syncer/xmlToJson';
import { toSimpleXmlNode, xmlToJson } from '../../Syncer/xmlToJson';
Expand Down Expand Up @@ -471,25 +470,7 @@ describe('parseFormDefinition', () => {

describe('getColumnDefinitions', () => {
requireContext();
test('can customize the column definition source', () =>
expect(
getColumnDefinitions(
toSimpleXmlNode(
xmlToJson(
strictParseXml(
`<viewdef>
<columnDef os="abc">A</columnDef>
<columnDef os="${getPref(
'form.definition.columnSource'
)}">B</columnDef>
</viewdef>`
)
)
)
)
).toBe('B'));

test('fall back to first definition available', () =>
test('uses the first column definition available', () =>
expect(
getColumnDefinitions(
xml(
Expand Down
7 changes: 1 addition & 6 deletions specifyweb/frontend/js_src/lib/components/FormParse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
setLogContext,
} from '../Errors/logContext';
import { cacheableUrl } from '../InitialContext';
import { getPref } from '../InitialContext/remotePrefs';
import { formatUrl } from '../Router/queryString';
import type { SimpleXmlNode } from '../Syncer/xmlToJson';
import { toSimpleXmlNode, xmlToJson } from '../Syncer/xmlToJson';
Expand Down Expand Up @@ -532,11 +531,7 @@ export async function parseFormDefinition(
}

function getColumnDefinitions(viewDefinition: SimpleXmlNode): string {
const definition =
getColumnDefinition(
viewDefinition,
getPref('form.definition.columnSource')
) ?? getColumnDefinition(viewDefinition, undefined);
const definition = getColumnDefinition(viewDefinition, undefined);
// Specify 7 handles forms without column definition fine, so no need to warn for this
return definition ?? getParsedAttribute(viewDefinition, 'colDef') ?? '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,7 @@ exports[`fetches and parses remotePrefs correctly 1`] = `
"SubPaneMgr.MaxPanes": "12",
"SymbiotaTask.BaseUrlPref": "http\\\\://pinkava.asu.edu/symbiota/sandbox/webservices/dwc/dwcaingesthandler.php",
"SymbiotaTask.SHOW_TASK_PREF.fish": "false",
"TaxonTreeEditor.DisplayAuthor": "true",
"Testing2": "",
"TreeEditor.Rank.Threshold.Geography": "100",
"TreeEditor.Rank.Threshold.GeologicTimePeriod": "0",
"TreeEditor.Rank.Threshold.LithoStrat": "200",
"TreeEditor.Rank.Threshold.Storage": "200",
"TreeEditor.Rank.Threshold.Taxon": "100",
"TreeEditor.RestoreTreeExpansionState": "true",
"Treeeditor.SynonymyColor.Geography": "255, 0, 0",
"Treeeditor.SynonymyColor.GeologicTimePeriod": "0, 0, 255",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('Parsing Remote Prefs', () => {
test('parses numeric value', () =>
expect(getPref('attachment.preview_size')).toBe(123));
test('uses default value if pref is not set', () =>
expect(getPref('form.definition.columnSource')).toBe(
remotePrefsDefinitions()['form.definition.columnSource'].defaultValue
expect(getPref('ui.formatting.scrmonthformat')).toBe(
remotePrefsDefinitions()['ui.formatting.scrmonthformat'].defaultValue
));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,97 +126,6 @@ export const remotePrefsDefinitions = f.store(
defaultValue: 'MM/YYYY',
formatters: [formatter.trim, formatter.toUpperCase],
},
'GeologicTimePeriod.treeview_sort_field': {
description: 'Sort order for nodes in the tree viewer',
defaultValue: 'name',
formatters: [formatter.trim],
isLegacy: true,
},
'Taxon.treeview_sort_field': {
description: 'Sort order for nodes in the tree viewer',
defaultValue: 'name',
formatters: [formatter.trim],
isLegacy: true,
},
'Geography.treeview_sort_field': {
description: 'Sort order for nodes in the tree viewer',
defaultValue: 'name',
formatters: [formatter.trim],
isLegacy: true,
},
'LithoStrat.treeview_sort_field': {
description: 'Sort order for nodes in the tree viewer',
defaultValue: 'name',
formatters: [formatter.trim],
isLegacy: true,
},
'Storage.treeview_sort_field': {
description: 'Sort order for nodes in the tree viewer',
defaultValue: 'name',
formatters: [formatter.trim],
isLegacy: true,
},
'TectonicUnit.treeview_sort_field': {
description: 'Sort order for nodes in the tree viewer',
defaultValue: 'name',
formatters: [formatter.trim],
isLegacy: false,
},
'TreeEditor.Rank.Threshold.GeologicTimePeriod': {
description:
'Show Collection Object count only for nodes with RankID >= than this value',
defaultValue: 99_999,
parser: 'java.lang.Long',
isLegacy: true,
},
'TreeEditor.Rank.Threshold.Taxon': {
description:
'Show Collection Object count only for nodes with RankID >= than this value',
defaultValue: 99_999,
parser: 'java.lang.Long',
isLegacy: true,
},
'TreeEditor.Rank.Threshold.Geography': {
description:
'Show Collection Object count only for nodes with RankID >= than this value',
defaultValue: 99_999,
parser: 'java.lang.Long',
isLegacy: true,
},
'TreeEditor.Rank.Threshold.LithoStrat': {
description:
'Show Collection Object count only for nodes with RankID >= than this value',
defaultValue: 99_999,
parser: 'java.lang.Long',
isLegacy: true,
},
'TreeEditor.Rank.Threshold.Storage': {
description:
'Show Collection Object count only for nodes with RankID >= than this value',
defaultValue: 99_999,
parser: 'java.lang.Long',
isLegacy: true,
},
'TreeEditor.Rank.Threshold.TectonicUnit': {
description:
'Show Collection Object count only for nodes with RankID >= than this value',
defaultValue: 99_999,
parser: 'java.lang.Long',
isLegacy: true,
},

/*
* This pref was implemented in Specify 7 in https://github.com/specify/specify7/pull/2818
* and went through many iterations and changes.
* See the Pull Request for the full context and implementation/design decision.
*/
'TaxonTreeEditor.DisplayAuthor': {
description:
'Display Authors of Taxons next to nodes in the Tree Viewer',
defaultValue: false,
parser: 'java.lang.Boolean',
isLegacy: true,
},
'attachment.is_public_default': {
description: 'Whether new Attachments are public by default',
defaultValue: true,
Expand All @@ -242,12 +151,6 @@ export const remotePrefsDefinitions = f.store(
parser: 'java.lang.Boolean',
isLegacy: true,
},
'form.definition.columnSource': {
description: 'The platform to use as a source of columns',
defaultValue: 'lnx',
formatter: [formatter.trim],
isLegacy: false,
},
'sp7.allow_adding_child_to_synonymized_parent.GeologicTimePeriod': {
description:
'Allowed to add children to synopsized Geologic Time Period records',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,15 @@ export const userPreferenceDefinitions = {
renderer: ColorPickerPreferenceItem,
container: 'label',
}),
statsThreshold: definePref<number>({
title: preferencesText.treeStatsThreshold(),
description: preferencesText.treeStatsThresholdDescription(),
requiresReload: false,
visible: false,
defaultValue: 99_999,
type: 'java.lang.Long',
container: 'label',
}),
},
},
taxon: {
Expand Down Expand Up @@ -1502,6 +1511,15 @@ export const userPreferenceDefinitions = {
defaultValue: true,
type: 'java.lang.Boolean',
}),
statsThreshold: definePref<number>({
title: preferencesText.treeStatsThreshold(),
description: preferencesText.treeStatsThresholdDescription(),
requiresReload: false,
visible: false,
defaultValue: 99_999,
type: 'java.lang.Long',
container: 'label',
}),
},
},
storage: {
Expand All @@ -1523,6 +1541,15 @@ export const userPreferenceDefinitions = {
renderer: ColorPickerPreferenceItem,
container: 'label',
}),
statsThreshold: definePref<number>({
title: preferencesText.treeStatsThreshold(),
description: preferencesText.treeStatsThresholdDescription(),
requiresReload: false,
visible: false,
defaultValue: 99_999,
type: 'java.lang.Long',
container: 'label',
}),
},
},
geologicTimePeriod: {
Expand All @@ -1544,6 +1571,15 @@ export const userPreferenceDefinitions = {
renderer: ColorPickerPreferenceItem,
container: 'label',
}),
statsThreshold: definePref<number>({
title: preferencesText.treeStatsThreshold(),
description: preferencesText.treeStatsThresholdDescription(),
requiresReload: false,
visible: false,
defaultValue: 99_999,
type: 'java.lang.Long',
container: 'label',
}),
},
},
lithoStrat: {
Expand All @@ -1565,6 +1601,15 @@ export const userPreferenceDefinitions = {
renderer: ColorPickerPreferenceItem,
container: 'label',
}),
statsThreshold: definePref<number>({
title: preferencesText.treeStatsThreshold(),
description: preferencesText.treeStatsThresholdDescription(),
requiresReload: false,
visible: false,
defaultValue: 99_999,
type: 'java.lang.Long',
container: 'label',
}),
},
},
tectonicUnit: {
Expand All @@ -1586,6 +1631,15 @@ export const userPreferenceDefinitions = {
renderer: ColorPickerPreferenceItem,
container: 'label',
}),
statsThreshold: definePref<number>({
title: preferencesText.treeStatsThreshold(),
description: preferencesText.treeStatsThresholdDescription(),
requiresReload: false,
visible: false,
defaultValue: 99_999,
type: 'java.lang.Long',
container: 'label',
}),
},
},
},
Expand Down
7 changes: 4 additions & 3 deletions specifyweb/frontend/js_src/lib/components/TreeView/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { idFromUrl } from '../DataModel/resource';
import { deserializeResource } from '../DataModel/serializers';
import { softError } from '../Errors/assert';
import { ResourceView } from '../Forms/ResourceView';
import { getPref } from '../InitialContext/remotePrefs';
import { hasTablePermission } from '../Permissions/helpers';
import { useHighContrast } from '../Preferences/Hooks';
import { userPreferences } from '../Preferences/userPreferences';
Expand Down Expand Up @@ -98,8 +97,10 @@ export function Tree<
'synonymColor'
);

const statsThreshold = getPref(
`TreeEditor.Rank.Threshold.${tableName as 'Geography'}`
const [statsThreshold] = userPreferences.use(
'treeEditor',
treeToPref[tableName],
'statsThreshold'
);
const getStats = React.useCallback(
async (nodeId: number | 'null', rankId: number): Promise<Stats> =>
Expand Down
Loading