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

Add product placeholder field #1093

Closed
wants to merge 1 commit 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
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
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
}
}