add new props for /sight
route
This commit is contained in:
parent
65a8f1e064
commit
af5e8adc3c
@ -12,7 +12,7 @@ interface CustomDataGridProps extends DataGridProps {
|
|||||||
resource?: string // Add this prop
|
resource?: string // Add this prop
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEV_FIELDS = ['id', 'code', 'country_code', 'city_id', 'carrier_id', 'main_color', 'left_color', 'right_color', 'logo', 'slogan', 'filename', 'arms', 'thumbnail', 'route_sys_number', 'governor_appeal', 'scale_min', 'scale_max', 'rotate', 'center_latitude', 'center_longitude'] as const
|
const DEV_FIELDS = ['id', 'code', 'country_code', 'city_id', 'carrier_id', 'main_color', 'left_color', 'right_color', 'logo', 'slogan', 'filename', 'arms', 'thumbnail', 'route_sys_number', 'governor_appeal', 'scale_min', 'scale_max', 'rotate', 'center_latitude', 'center_longitude', 'watermark_lu', 'watermark_rd', 'left_article', 'preview_article'] as const
|
||||||
|
|
||||||
export const CustomDataGrid = ({hasCoordinates = false, columns = [], resource, ...props}: CustomDataGridProps) => {
|
export const CustomDataGrid = ({hasCoordinates = false, columns = [], resource, ...props}: CustomDataGridProps) => {
|
||||||
// const isDev = import.meta.env.DEV
|
// const isDev = import.meta.env.DEV
|
||||||
|
@ -38,6 +38,17 @@ export const SightCreate = () => {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const {autocompleteProps: articleAutocompleteProps} = useAutocomplete({
|
||||||
|
resource: 'article',
|
||||||
|
onSearch: (value) => [
|
||||||
|
{
|
||||||
|
field: 'heading',
|
||||||
|
operator: 'contains',
|
||||||
|
value,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Create isLoading={formLoading} saveButtonProps={saveButtonProps}>
|
<Create isLoading={formLoading} saveButtonProps={saveButtonProps}>
|
||||||
<Box component="form" sx={{display: 'flex', flexDirection: 'column'}} autoComplete="off">
|
<Box component="form" sx={{display: 'flex', flexDirection: 'column'}} autoComplete="off">
|
||||||
@ -129,7 +140,107 @@ export const SightCreate = () => {
|
|||||||
filterOptions={(options, {inputValue}) => {
|
filterOptions={(options, {inputValue}) => {
|
||||||
return options.filter((option) => option.media_name.toLowerCase().includes(inputValue.toLowerCase()))
|
return options.filter((option) => option.media_name.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
}}
|
}}
|
||||||
renderInput={(params) => <TextField {...params} label="Выберите карточку" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} />}
|
renderInput={(params) => <TextField {...params} label="Выберите обложку" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="watermark_lu"
|
||||||
|
defaultValue={null}
|
||||||
|
render={({field}) => (
|
||||||
|
<Autocomplete
|
||||||
|
{...mediaAutocompleteProps}
|
||||||
|
value={mediaAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
|
onChange={(_, value) => {
|
||||||
|
field.onChange(value?.id || '')
|
||||||
|
}}
|
||||||
|
getOptionLabel={(item) => {
|
||||||
|
return item ? item.media_name : ''
|
||||||
|
}}
|
||||||
|
isOptionEqualToValue={(option, value) => {
|
||||||
|
return option.id === value?.id
|
||||||
|
}}
|
||||||
|
filterOptions={(options, {inputValue}) => {
|
||||||
|
return options.filter((option) => option.media_name.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
|
}}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Выберите водный знак (Левый верх)" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="watermark_rd"
|
||||||
|
defaultValue={null}
|
||||||
|
render={({field}) => (
|
||||||
|
<Autocomplete
|
||||||
|
{...mediaAutocompleteProps}
|
||||||
|
value={mediaAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
|
onChange={(_, value) => {
|
||||||
|
field.onChange(value?.id || '')
|
||||||
|
}}
|
||||||
|
getOptionLabel={(item) => {
|
||||||
|
return item ? item.media_name : ''
|
||||||
|
}}
|
||||||
|
isOptionEqualToValue={(option, value) => {
|
||||||
|
return option.id === value?.id
|
||||||
|
}}
|
||||||
|
filterOptions={(options, {inputValue}) => {
|
||||||
|
return options.filter((option) => option.media_name.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
|
}}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Выберите водный знак (Правый низ)" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="left_article"
|
||||||
|
defaultValue={null}
|
||||||
|
render={({field}) => (
|
||||||
|
<Autocomplete
|
||||||
|
{...articleAutocompleteProps}
|
||||||
|
value={articleAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
|
onChange={(_, value) => {
|
||||||
|
field.onChange(value?.id || '')
|
||||||
|
}}
|
||||||
|
getOptionLabel={(item) => {
|
||||||
|
return item ? item.heading : ''
|
||||||
|
}}
|
||||||
|
isOptionEqualToValue={(option, value) => {
|
||||||
|
return option.id === value?.id
|
||||||
|
}}
|
||||||
|
filterOptions={(options, {inputValue}) => {
|
||||||
|
return options.filter((option) => option.heading.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
|
}}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Левая статья" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="preview_article"
|
||||||
|
defaultValue={null}
|
||||||
|
render={({field}) => (
|
||||||
|
<Autocomplete
|
||||||
|
{...articleAutocompleteProps}
|
||||||
|
value={articleAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
|
onChange={(_, value) => {
|
||||||
|
field.onChange(value?.id || '')
|
||||||
|
}}
|
||||||
|
getOptionLabel={(item) => {
|
||||||
|
return item ? item.heading : ''
|
||||||
|
}}
|
||||||
|
isOptionEqualToValue={(option, value) => {
|
||||||
|
return option.id === value?.id
|
||||||
|
}}
|
||||||
|
filterOptions={(options, {inputValue}) => {
|
||||||
|
return options.filter((option) => option.heading.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
|
}}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Cтатья-предпросмотр" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
@ -39,6 +39,17 @@ export const SightEdit = () => {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const {autocompleteProps: articleAutocompleteProps} = useAutocomplete({
|
||||||
|
resource: 'article',
|
||||||
|
onSearch: (value) => [
|
||||||
|
{
|
||||||
|
field: 'heading',
|
||||||
|
operator: 'contains',
|
||||||
|
value,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Edit saveButtonProps={saveButtonProps}>
|
<Edit saveButtonProps={saveButtonProps}>
|
||||||
<Box component="form" sx={{display: 'flex', flexDirection: 'column'}} autoComplete="off">
|
<Box component="form" sx={{display: 'flex', flexDirection: 'column'}} autoComplete="off">
|
||||||
@ -130,7 +141,107 @@ export const SightEdit = () => {
|
|||||||
filterOptions={(options, {inputValue}) => {
|
filterOptions={(options, {inputValue}) => {
|
||||||
return options.filter((option) => option.media_name.toLowerCase().includes(inputValue.toLowerCase()))
|
return options.filter((option) => option.media_name.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
}}
|
}}
|
||||||
renderInput={(params) => <TextField {...params} label="Выберите карточку" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} />}
|
renderInput={(params) => <TextField {...params} label="Выберите обложку" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="watermark_lu"
|
||||||
|
defaultValue={null}
|
||||||
|
render={({field}) => (
|
||||||
|
<Autocomplete
|
||||||
|
{...mediaAutocompleteProps}
|
||||||
|
value={mediaAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
|
onChange={(_, value) => {
|
||||||
|
field.onChange(value?.id || '')
|
||||||
|
}}
|
||||||
|
getOptionLabel={(item) => {
|
||||||
|
return item ? item.media_name : ''
|
||||||
|
}}
|
||||||
|
isOptionEqualToValue={(option, value) => {
|
||||||
|
return option.id === value?.id
|
||||||
|
}}
|
||||||
|
filterOptions={(options, {inputValue}) => {
|
||||||
|
return options.filter((option) => option.media_name.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
|
}}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Выберите водный знак (Левый верх)" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="watermark_rd"
|
||||||
|
defaultValue={null}
|
||||||
|
render={({field}) => (
|
||||||
|
<Autocomplete
|
||||||
|
{...mediaAutocompleteProps}
|
||||||
|
value={mediaAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
|
onChange={(_, value) => {
|
||||||
|
field.onChange(value?.id || '')
|
||||||
|
}}
|
||||||
|
getOptionLabel={(item) => {
|
||||||
|
return item ? item.media_name : ''
|
||||||
|
}}
|
||||||
|
isOptionEqualToValue={(option, value) => {
|
||||||
|
return option.id === value?.id
|
||||||
|
}}
|
||||||
|
filterOptions={(options, {inputValue}) => {
|
||||||
|
return options.filter((option) => option.media_name.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
|
}}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Выберите водный знак (Правый низ)" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="left_article"
|
||||||
|
defaultValue={null}
|
||||||
|
render={({field}) => (
|
||||||
|
<Autocomplete
|
||||||
|
{...articleAutocompleteProps}
|
||||||
|
value={articleAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
|
onChange={(_, value) => {
|
||||||
|
field.onChange(value?.id || '')
|
||||||
|
}}
|
||||||
|
getOptionLabel={(item) => {
|
||||||
|
return item ? item.heading : ''
|
||||||
|
}}
|
||||||
|
isOptionEqualToValue={(option, value) => {
|
||||||
|
return option.id === value?.id
|
||||||
|
}}
|
||||||
|
filterOptions={(options, {inputValue}) => {
|
||||||
|
return options.filter((option) => option.heading.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
|
}}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Левая статья" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="preview_article"
|
||||||
|
defaultValue={null}
|
||||||
|
render={({field}) => (
|
||||||
|
<Autocomplete
|
||||||
|
{...articleAutocompleteProps}
|
||||||
|
value={articleAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
|
onChange={(_, value) => {
|
||||||
|
field.onChange(value?.id || '')
|
||||||
|
}}
|
||||||
|
getOptionLabel={(item) => {
|
||||||
|
return item ? item.heading : ''
|
||||||
|
}}
|
||||||
|
isOptionEqualToValue={(option, value) => {
|
||||||
|
return option.id === value?.id
|
||||||
|
}}
|
||||||
|
filterOptions={(options, {inputValue}) => {
|
||||||
|
return options.filter((option) => option.heading.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
|
}}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Cтатья-предпросмотр" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
@ -59,7 +59,7 @@ export const SightList = () => {
|
|||||||
field: 'city',
|
field: 'city',
|
||||||
headerName: 'Город',
|
headerName: 'Город',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
minWidth: 150,
|
minWidth: 100,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
headerAlign: 'left',
|
headerAlign: 'left',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@ -68,7 +68,31 @@ export const SightList = () => {
|
|||||||
field: 'thumbnail',
|
field: 'thumbnail',
|
||||||
headerName: 'Карточка',
|
headerName: 'Карточка',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
flex: 1,
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'watermark_lu',
|
||||||
|
headerName: 'Вод. знак (lu)',
|
||||||
|
type: 'string',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'watermark_rd',
|
||||||
|
headerName: 'Вод. знак (rd)',
|
||||||
|
type: 'string',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'left_article',
|
||||||
|
headerName: 'Левая статья',
|
||||||
|
type: 'number',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'preview_article',
|
||||||
|
headerName: 'Пред. просмотр статьи',
|
||||||
|
type: 'number',
|
||||||
|
minWidth: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'actions',
|
field: 'actions',
|
||||||
|
Loading…
Reference in New Issue
Block a user