@@ -12,6 +12,7 @@ import {
1212 TextField ,
1313 TextInput ,
1414 useRecordContext ,
15+ useDefaultTitle ,
1516} from 'react-admin' ;
1617import PhotoCameraIcon from '@mui/icons-material/PhotoCamera' ;
1718import AspectRatioIcon from '@mui/icons-material/AspectRatio' ;
@@ -32,87 +33,100 @@ const RichTextInput = React.lazy(() =>
3233) ;
3334
3435const ProductTitle = ( ) => {
36+ const title = useDefaultTitle ( ) ;
37+
3538 const record = useRecordContext < Product > ( ) ;
36- return record ? < span > Poster "{ record . reference } "</ span > : null ;
39+ return record ? (
40+ < >
41+ < title > { `${ title } - Poster "${ record . reference } ` } </ title >
42+ < span > Poster "{ record . reference } "</ span >
43+ </ >
44+ ) : null ;
3745} ;
3846
39- const ProductEdit = ( ) => (
40- < Edit title = { < ProductTitle /> } >
41- < TabbedForm >
42- < TabbedForm . Tab
43- label = "resources.products.tabs.image"
44- sx = { { maxWidth : '40em' , minHeight : 48 } }
45- iconPosition = "start"
46- icon = { < PhotoCameraIcon /> }
47- >
48- < Poster />
49- < TextInput source = "image" validate = { req } />
50- < TextInput source = "thumbnail" validate = { req } />
51- </ TabbedForm . Tab >
52- < TabbedForm . Tab
53- label = "resources.products.tabs.details"
54- path = "details"
55- sx = { { maxWidth : '40em' , minHeight : 48 } }
56- iconPosition = "start"
57- icon = { < AspectRatioIcon /> }
58- >
59- < ProductEditDetails />
60- </ TabbedForm . Tab >
61- < TabbedForm . Tab
62- label = "resources.products.tabs.description"
63- path = "description"
64- sx = { { maxWidth : '40em' , minHeight : 48 } }
65- iconPosition = "start"
66- icon = { < EditNoteIcon /> }
67- >
68- < RichTextInput source = "description" label = "" validate = { req } />
69- </ TabbedForm . Tab >
70- < TabbedForm . Tab
71- label = "resources.products.tabs.reviews"
72- count = {
73- < ReferenceManyCount
74- reference = "reviews"
75- target = "product_id"
76- sx = { { lineHeight : 'inherit' } }
47+ const ProductEdit = ( ) => {
48+ return (
49+ < Edit title = { < ProductTitle /> } >
50+ < TabbedForm >
51+ < TabbedForm . Tab
52+ label = "resources.products.tabs.image"
53+ sx = { { maxWidth : '40em' , minHeight : 48 } }
54+ iconPosition = "start"
55+ icon = { < PhotoCameraIcon /> }
56+ >
57+ < Poster />
58+ < TextInput source = "image" validate = { req } />
59+ < TextInput source = "thumbnail" validate = { req } />
60+ </ TabbedForm . Tab >
61+ < TabbedForm . Tab
62+ label = "resources.products.tabs.details"
63+ path = "details"
64+ sx = { { maxWidth : '40em' , minHeight : 48 } }
65+ iconPosition = "start"
66+ icon = { < AspectRatioIcon /> }
67+ >
68+ < ProductEditDetails />
69+ </ TabbedForm . Tab >
70+ < TabbedForm . Tab
71+ label = "resources.products.tabs.description"
72+ path = "description"
73+ sx = { { maxWidth : '40em' , minHeight : 48 } }
74+ iconPosition = "start"
75+ icon = { < EditNoteIcon /> }
76+ >
77+ < RichTextInput
78+ source = "description"
79+ label = ""
80+ validate = { req }
7781 />
78- }
79- path = "reviews"
80- sx = { { minHeight : 48 } }
81- iconPosition = "start"
82- icon = { < ReviewIcon /> }
83- >
84- < ReferenceManyField
85- reference = "reviews"
86- target = "product_id"
87- pagination = { < Pagination /> }
82+ </ TabbedForm . Tab >
83+ < TabbedForm . Tab
84+ label = "resources.products.tabs.reviews"
85+ count = {
86+ < ReferenceManyCount
87+ reference = "reviews"
88+ target = "product_id"
89+ sx = { { lineHeight : 'inherit' } }
90+ />
91+ }
92+ path = "reviews"
93+ sx = { { minHeight : 48 } }
94+ iconPosition = "start"
95+ icon = { < ReviewIcon /> }
8896 >
89- < Datagrid
90- sx = { {
91- width : '100%' ,
92- '& .column-comment' : {
93- maxWidth : '20em' ,
94- overflow : 'hidden' ,
95- textOverflow : 'ellipsis' ,
96- whiteSpace : 'nowrap' ,
97- } ,
98- } }
97+ < ReferenceManyField
98+ reference = "reviews"
99+ target = "product_id"
100+ pagination = { < Pagination /> }
99101 >
100- < DateField source = "date" />
101- < CustomerReferenceField source = "customer_id" />
102- < StarRatingField
103- label = "resources.reviews.fields.rating"
104- source = "rating"
105- />
106- < TextField source = "comment" />
107- < TextField source = "status" />
108- < EditButton />
109- </ Datagrid >
110- < CreateRelatedReviewButton />
111- </ ReferenceManyField >
112- </ TabbedForm . Tab >
113- </ TabbedForm >
114- </ Edit >
115- ) ;
102+ < Datagrid
103+ sx = { {
104+ width : '100%' ,
105+ '& .column-comment' : {
106+ maxWidth : '20em' ,
107+ overflow : 'hidden' ,
108+ textOverflow : 'ellipsis' ,
109+ whiteSpace : 'nowrap' ,
110+ } ,
111+ } }
112+ >
113+ < DateField source = "date" />
114+ < CustomerReferenceField source = "customer_id" />
115+ < StarRatingField
116+ label = "resources.reviews.fields.rating"
117+ source = "rating"
118+ />
119+ < TextField source = "comment" />
120+ < TextField source = "status" />
121+ < EditButton />
122+ </ Datagrid >
123+ < CreateRelatedReviewButton />
124+ </ ReferenceManyField >
125+ </ TabbedForm . Tab >
126+ </ TabbedForm >
127+ </ Edit >
128+ ) ;
129+ } ;
116130
117131const req = [ required ( ) ] ;
118132
0 commit comments