Skip to content

Commit

Permalink
Add product placeholder field
Browse files Browse the repository at this point in the history
  • Loading branch information
zkhin committed Mar 17, 2022
1 parent 0d5c912 commit f927258
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/scenes/Products/Detail/ProductDetail.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ fragment ProductDetail on Product {
describeCompletion {
value
}
placeholderDescription {
value
}
engagement {
...EngagementBreadcrumb
partnershipsProducingMediums {
Expand Down
11 changes: 9 additions & 2 deletions src/scenes/Products/Detail/ProductDetailHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Tooltip,
Typography,
} from '@material-ui/core';
import { Edit } from '@material-ui/icons';
import { CropFreeOutlined, Edit } from '@material-ui/icons';
import { Skeleton } from '@material-ui/lab';
import React from 'react';
import { Helmet } from 'react-helmet-async';
Expand All @@ -17,10 +17,13 @@ import { Redacted } from '../../../components/Redacted';
import { Link } from '../../../components/Routing';
import { ProductDetailFragment as Product } from './ProductDetail.generated';

const useStyles = makeStyles(() => ({
const useStyles = makeStyles((theme) => ({
nameRedacted: {
width: '50%',
},
placeholderIcon: {
marginLeft: theme.spacing(1),
},
}));

export const ProductDetailHeader = ({ product }: { product?: Product }) => {
Expand All @@ -29,6 +32,7 @@ export const ProductDetailHeader = ({ product }: { product?: Product }) => {
const language = product?.engagement.language.value;
const langName = language?.name.value ?? language?.displayName.value;
const project = product?.engagement.project;
const placeholderDescription = product?.placeholderDescription.value;

return (
<>
Expand All @@ -54,6 +58,9 @@ export const ProductDetailHeader = ({ product }: { product?: Product }) => {
width="100%"
/>
)}
{placeholderDescription && (
<CropFreeOutlined className={classes.placeholderIcon} />
)}
</Typography>
</Grid>
<Grid item>
Expand Down
1 change: 1 addition & 0 deletions src/scenes/Products/Edit/EditProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export const EditProduct = () => {
}
: undefined,
title: '',
placeholderDescription: product.placeholderDescription.value,
...(product.__typename === 'DirectScriptureProduct'
? {
productType: product.__typename,
Expand Down
23 changes: 23 additions & 0 deletions src/scenes/Products/ProductForm/PlaceholderDescriptionSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { TextField } from '../../../components/form';
import { DefaultAccordion } from './DefaultAccordion';
import { SectionProps } from './ProductFormFields';

export const PlaceholderDescriptionSection = ({
accordionState,
}: SectionProps) => {
return (
<DefaultAccordion
name="placeholderDescription"
{...accordionState}
title="Placeholder Description"
renderCollapsed={() => <></>}
>
<TextField
name="placeholderDescription"
label="Placeholder"
placeholder="Enter placeholder description"
/>
</DefaultAccordion>
);
};
5 changes: 5 additions & 0 deletions src/scenes/Products/ProductForm/ProductForm.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ fragment ProductForm on Product {
canEdit
value
}
placeholderDescription {
canRead
canEdit
value
}
... on DirectScriptureProduct {
unspecifiedScripture {
canRead
Expand Down
2 changes: 2 additions & 0 deletions src/scenes/Products/ProductForm/ProductFormFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MethodologySection } from './MethodologySection';
import { OtherProductSection } from './OtherProductSection';
import { PartnershipProducingMediumsSection } from './PartnershipProducingMediumsSection';
import { EditPartnershipsProducingMediumsInfoFragment } from './PartnershipsProducingMediums.generated';
import { PlaceholderDescriptionSection } from './PlaceholderDescriptionSection';
import { ProductFormValues } from './ProductForm';
import {
ProductForm_DerivativeScriptureProduct_Fragment as DerivativeScriptureProduct,
Expand Down Expand Up @@ -46,6 +47,7 @@ export type SectionProps = FormProps<ProductFormValues> & {
const sections: ReadonlyArray<ComponentType<SectionProps>> = [
GoalsSection,
ProductSection,
PlaceholderDescriptionSection,
OtherProductSection,
ScriptureReferencesSection,
MediumsSection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ fragment ProductInfoForProgressReport on Product {
}
}
}
placeholderDescription {
value
}
}

0 comments on commit f927258

Please sign in to comment.