Skip to content
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

COG business rules: isPrimary and isSubstrate #5275

Draft
wants to merge 19 commits into
base: production
Choose a base branch
from
Draft

Conversation

sharadsw
Copy link
Contributor

@sharadsw sharadsw commented Sep 13, 2024

Fixes #5246

Business Logic:

  • In each COG, isPrimary and isSubstrate can only be set to True for a single CO.
  • COJOs that link to a child COG instead of a child CO cannot check either the isPrimary or isSubstrate fields.
    • (Will need to be done with conditional forms)
  • When checked, IsPrimary is set to True for one CO in a COG. All other COJO records will have IsPrimary set to False.
  • When no CO has IsPrimary set to True, it is NULL for all COJO records in the COG.
    • Default behavior?
  • The first COJO CO will automatically have isPrimary set to True when the COG type is 'consolidated'

NOTE:
This PR adds the possibility to do an empty value check in conditional rendering using the keyword _EMPTY. This was already possible if we use an incomplete condition like <rows condition="childcog="> but it's an unintentional feature and may not seem very clear to users. Empty value checks can now be done with a condition like this:

<rows condition="childcog=_EMPTY">
...
</rows>

The condition will hold true whenever a relation is null or a field has a blank value.

Checklist

  • Self-review the PR after opening it to make sure the changes look good
    and self-explanatory (or properly documented)
  • Add automated tests
  • Add relevant issue to release milestone

Testing instructions

These viewdefs can be used for testing

COG viewdef

<viewdef name="CollectionObjectGroup" class="edu.ku.brc.specify.datamodel.CollectionObjectGroup" type="form" gettable="edu.ku.brc.af.ui.forms.DataGetterForObj" settable="edu.ku.brc.af.ui.forms.DataSetterForObj">
	<desc>The CollectionObjectGroup Table</desc>
	<enableRules/>
	<columnDef>p,2px,p,2px,p,2px,p,2px,p,2px,p,p:g</columnDef>
	<rowDef auto="true" cell="p" sep="2px"/>
	<rows>
		<row>
			<cell type="label" labelfor="1" label="Name"/>
			<cell type="field" id="1" name="name" uitype="text" isrequired="true"/>
			<cell type="label" labelfor="2" label="CogType"/>
			<cell type="field" id="2" name="cogtype" uitype="combobox" isrequired="true"/>
		</row>
		<row>
			<cell type="subview" viewname="CollectionObjectGroupJoin" defaulttype="Table" id="8" name="parentcojos"/>
		</row>
	</rows>
</viewdef>

COJO viewdef

<viewdef name="CollectionObjectGroupJoin" class="edu.ku.brc.specify.datamodel.CollectionObjectGroupJoin" type="form" gettable="edu.ku.brc.af.ui.forms.DataGetterForObj" settable="edu.ku.brc.af.ui.forms.DataSetterForObj">
	<desc>The CollectionObjectGroupJoin Table</desc>
	<enableRules/>
	<columnDef>p,2px,p,2px,p,2px,p,2px,p,2px,p,p:g</columnDef>
	<rowDef auto="true" cell="p" sep="2px"/>
	<rows>
		<row>
			<cell type="label" label="Child CO"/>
			<cell type="subview" id="CO" viewname="CollectionObject" name="childCo" initialize="icon=CollectionObject;btn=true;align=left;verticalAlign=center" defaulttype="icon"/>
			<cell type="label" label="Child COG"/>
			<cell type="subview" id="CGO" viewname="CollectionObjectGroup" name="childCog" initialize="icon=CollectionObjectGroup;btn=true;align=left;verticalAlign=center" defaulttype="icon"/>
			<cell type="panel" coldef="100px,2px,76px" colspan="3">
				<rows>
					<row>
						<cell type="label" labelfor="1" label="CO"/>
						<cell type="label" labelfor="2" label="isPrimary"/>
						<cell type="field" id="2" name="isPrimary" uitype="checkbox"/>
						<cell type="label" labelfor="3" label="isSubstrate"/>
						<cell type="field" id="3" name="isSubstrate" uitype="checkbox"/>
					</row>
				</rows>
				<rows condition="childco=_EMPTY">
					<row>
						<cell type="label" labelfor="5" label="COG"/>
						<cell type="label" labelfor="6" label="isPrimary"/>
						<cell type="field" id="6" name="isPrimary" uitype="checkbox" readonly="true"/>
						<cell type="label" labelfor="7" label="isSubstrate"/>
						<cell type="field" id="7" name="isSubstrate" uitype="checkbox" readonly="true"/>
					</row>
				</rows>
			</cell>
		</row>
	</rows>
</viewdef>
  • Go to Data Entry > CollectionObjectGroup (navigate through the URL if hidden)
  • Add COG children (parentCojos)
  • Verify only 1 CO child can be set as isPrimary or isSubstrate
  • Verify isPrimary and isSubstrate are read-only for children that link to COGs
  • Verify isPrimary for the first CO child is checked when cogtype changes to Consolidated

@sharadsw sharadsw added this to the 7.9.8 milestone Sep 13, 2024
@@ -468,6 +468,8 @@ export type FormCondition =
| State<'Always'>
| undefined;

export const EMPTY_VALUE_CONDITION = '_EMPTY';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you clarify why this is needed, and why having an empty string "" isn't sufficient?

Copy link
Contributor Author

@sharadsw sharadsw Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so users have a clearer way of doing an empty value check. A condition like <rows condition="childcog="> will work for an empty value check but it reads like an incomplete condition and on first glance doesn't seem like it would/should be doing anything at all. The _EMPTY keyword should just make things clearer for users

@sharadsw
Copy link
Contributor Author

sharadsw commented Oct 2, 2024

The field that will contain the children of a COG is cojo and not parentCojos. I have changed the business rules accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋Back Log
Development

Successfully merging this pull request may close these issues.

Add business logic for isPrimary and isSubstrate in COGs
4 participants