Skip to content

Remove components from v7.11.0 #7029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
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
251 changes: 50 additions & 201 deletions config/common/common.views.xml

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions config/geology/geology.views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@
<cell type="label" labelfor="5"/>
<cell type="field" id="5" uitype="plugin" name="this" initialize="name=PartialDateUI;df=catalogedDate;tp=catalogedDatePrecision" default="today" uifieldformatter="Date"/>
</row>
<!-- Show if you want to use Collection Object Components (https://discourse.specifysoftware.org/t/collection-object-components/2546) -->
<row>
<cell type="subview" viewname="Component" id="6" name="components" colspan="14" defaulttype="table"/>
</row>
<!-- Show if you want to use Collection Object Group (https://discourse.specifysoftware.org/t/collection-object-groups/2226) -->
<!-- <row>
<cell type="subview" viewname="CollectionObjectGroupJoin_Sub" id="co_cog_join" name="cojo" colspan="14"/>
Expand Down Expand Up @@ -454,9 +450,9 @@
</row>
<row>
<cell type="label" labelfor="9"/>
<cell type="field" id="9" name="createdByAgent" uitype="label" readonly="true" uifieldformatter="Agent"/>
<cell type="field" id="9" name="createdByAgent" uitype="label" readonly="true" uifieldformatter="Agent"/>
<cell type="label" labelfor="10"/>
<cell type="field" id="10" name="modifiedByAgent" uitype="label" readonly="true" uifieldformatter="Agent"/>
<cell type="field" id="10" name="modifiedByAgent" uitype="label" readonly="true" uifieldformatter="Agent"/>
</row>
<row>
<cell type="label" labelfor="11"/>
Expand Down Expand Up @@ -521,9 +517,9 @@
</row>
<row>
<cell type="label" labelfor="9"/>
<cell type="field" id="9" name="createdByAgent" uitype="label" readonly="true" uifieldformatter="Agent"/>
<cell type="field" id="9" name="createdByAgent" uitype="label" readonly="true" uifieldformatter="Agent"/>
<cell type="label" labelfor="10"/>
<cell type="field" id="10" name="modifiedByAgent" uitype="label" readonly="true" uifieldformatter="Agent"/>
<cell type="field" id="10" name="modifiedByAgent" uitype="label" readonly="true" uifieldformatter="Agent"/>
</row>
<row>
<cell type="label" labelfor="11"/>
Expand Down
10 changes: 9 additions & 1 deletion specifyweb/businessrules/rules/collectionobject_rules.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
from specifyweb.businessrules.orm_signal_handler import orm_signal_handler

from specifyweb.businessrules.exceptions import BusinessRuleException


@orm_signal_handler('pre_save', 'Collectionobject')
def collectionobject_pre_save(co):
if co.collectionmemberid is None:
co.collectionmemberid = co.collection_id

if co.collectionobjecttype is None:
if co.collectionobjecttype is None:
co.collectionobjecttype = co.collection.collectionobjecttype

if co.componentParent is not None:
raise BusinessRuleException("componentParent can not be set",
{"table": "CollectionObejct",
"fieldName": "componentParent",
"componentParentId": co.componentParent.id})
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { resolveParser } from '../../utils/parser/definitions';
import type { ValueOf } from '../../utils/types';
import type { BusinessRuleResult } from './businessRules';
import {
CO_HAS_PARENT,
COG_PRIMARY_KEY,
COG_TOITSELF,
COJO_PRIMARY_DELETE_KEY,
Expand All @@ -30,7 +29,6 @@ import {
updateLoanPrep,
} from './interactionBusinessRules';
import type { SpecifyResource } from './legacyTypes';
import { idFromUrl } from './resource';
import { setSaveBlockers } from './saveBlockers';
import { schema } from './schema';
import type { LiteralField, Relationship } from './specifyField';
Expand Down Expand Up @@ -279,33 +277,6 @@ export const businessRuleDefs: MappedBusinessRuleDefs = {
saveBlockerKey: COG_TOITSELF,
};
},
childCo: async (
cojo: SpecifyResource<CollectionObjectGroupJoin>
): Promise<BusinessRuleResult> => {
const childCO = cojo.get('childCo');
const childCOId = idFromUrl(childCO!);
const CO: SpecifyResource<CollectionObject> | void =
await new tables.CollectionObject.Resource({ id: childCOId })
.fetch()
.then((co) => co)
.catch((error) => {
console.error('Failed to fetch CollectionObject:', error);
});
let coParent;
if (CO !== undefined) {
coParent = CO.get('componentParent');
}
return coParent === null || coParent === undefined
? {
isValid: true,
saveBlockerKey: CO_HAS_PARENT,
}
: {
isValid: false,
reason: resourcesText.coHasParent(),
saveBlockerKey: CO_HAS_PARENT,
};
},
},
onAdded: (cojo, collection) => {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const PREPARATION_DISPOSED_KEY = 'preparation-isDisposed';
export const PREPARATION_EXCHANGED_OUT_KEY = 'preparation-isExchangedOut';
export const PREPARATION_EXCHANGED_IN_KEY = 'preparation-isExchangedIn';
export const COJO_PRIMARY_DELETE_KEY = 'primary-cojo-delete';
export const CO_HAS_PARENT = ' co-has-parent';

/**
* In tables where a boolean field can designate a "Primary" or important
Expand Down
2 changes: 0 additions & 2 deletions specifyweb/frontend/js_src/lib/components/DataModel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,6 @@ export type CollectionObject = {
readonly collectingEvent: CollectingEvent | null;
readonly collection: Collection;
readonly collectionObjectType: CollectionObjectType;
readonly componentParent: CollectionObject | null;
readonly container: Container | null;
readonly containerOwner: Container | null;
readonly createdByAgent: Agent | null;
Expand All @@ -1462,7 +1461,6 @@ export type CollectionObject = {
readonly collectionObjectAttrs: RA<CollectionObjectAttr>;
readonly collectionObjectCitations: RA<CollectionObjectCitation>;
readonly collectionObjectProperties: RA<CollectionObjectProperty>;
readonly components: RA<CollectionObject>;
readonly conservDescriptions: RA<ConservDescription>;
readonly determinations: RA<Determination>;
readonly dnaSequences: RA<DNASequence>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ const subViewSpec = (
);
return undefined;
}
if (
field?.table.name === 'CollectionObject' &&
['components', 'componentparent'].includes(field.name.toLowerCase())
) {
console.error('Component relatiosnhips are not supported');
return undefined;
}
if (field?.type === 'many-to-many') {
// ResourceApi does not support .rget() on a many-to-many
console.warn('Many-to-many relationships are not supported');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,14 @@ export function useContainerItems(
.filter(
(item) =>
/* Ignore removed fields (i.e, Accession->deaccessions) */
getTable(container.name)!.getField(item.name) !== undefined
getTable(container.name)!.getField(item.name) !== undefined &&
/* Remove components and componentParent relationships in `v7.11.0` */
!(
getTable(container.name)?.name === 'CollectionObject' &&
['components', 'componentparent'].includes(
item.name.toLowerCase()
)
)
)
.map((item) => ({
...item,
Expand Down
Loading