Skip to content

Commit

Permalink
Adds formula background styling to case card value cell.
Browse files Browse the repository at this point in the history
Disables value editing when attribute has a formula
  • Loading branch information
eireland committed Oct 2, 2024
1 parent 8896666 commit 49e3e54
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion v3/src/components/case-card/case-attr-view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.case-card-attr {
height: 25px;

&:nth-child(2) {
.case-card-attr-value {
border-top: solid 1px #b2b2b2;
Expand Down Expand Up @@ -45,6 +45,11 @@
text-align: left;
}

&.formula-attr-value {
background-color: rgba(255, 255, 0, 0.2);
font-style: italic;
}

span {
border-radius: 0;
display: inline-block;
Expand Down
6 changes: 4 additions & 2 deletions v3/src/components/case-card/case-attr-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const CaseAttrView = observer(function CaseAttrView (props: ICaseAttrView
const { caseId, collection, attrId, unit, value, getDividerBounds, onSetContentElt } = props
const cardModel = useCaseCardModel()
const data = cardModel?.data
const attr = collection.getAttribute(attrId)
const isCollectionSummarized = !!cardModel?.summarizedCollections.includes(collection.id)
const displayValue = value ? String(value) : ""
const showUnitWithValue = isFiniteNumber(Number(value)) && unit
Expand Down Expand Up @@ -63,16 +64,17 @@ export const CaseAttrView = observer(function CaseAttrView (props: ICaseAttrView
const renderEditableOrSummaryValue = () => {
if (isCollectionSummarized) {
return (
<div className="case-card-attr-value-text static-summary">
<div className={clsx("case-card-attr-value-text", "static-summary", {"formula-attr-value": attr?.hasFormula})}>
{displayValue}
</div>
)
}

return (
<Editable
className="case-card-attr-value-text"
className={clsx("case-card-attr-value-text", {"formula-attr-value": attr?.hasFormula})}
isPreviewFocusable={true}
isDisabled={attr?.hasFormula}
onCancel={handleCancel}
onChange={handleChangeValue}
onEdit={() => setIsEditing(true)}
Expand Down

0 comments on commit 49e3e54

Please sign in to comment.