add media_name prop for other routes
				
					
				
			This commit is contained in:
		| @@ -164,7 +164,7 @@ export const LinkedItems = <T extends {id: number; [key: string]: any}>({parentI | ||||
|                     {childResource === 'media' && item.id && ( | ||||
|                       <img | ||||
|                         src={`https://wn.krbl.ru/media/${item.id}/download`} | ||||
|                         alt={String(item.filename)} | ||||
|                         alt={String(item.media_name)} | ||||
|                         style={{ | ||||
|                           width: '100%', | ||||
|                           height: '120px', | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| export type MediaItem = { | ||||
|   id: number | ||||
|   filename: string | ||||
|   media_name: string | ||||
|   media_type: string | ||||
|   media_order?: number | ||||
| } | ||||
| @@ -23,6 +24,6 @@ export const articleFields: Array<FieldType<ArticleItem>> = [ | ||||
| ] | ||||
|  | ||||
| export const mediaFields: Array<FieldType<MediaItem>> = [ | ||||
|   {label: 'Имя', data: 'filename'}, | ||||
|   {label: 'Название', data: 'media_name'}, | ||||
|   {label: 'Тип', data: 'media_type'}, | ||||
| ] | ||||
|   | ||||
| @@ -27,7 +27,7 @@ export const CarrierCreate = () => { | ||||
|     resource: 'media', | ||||
|     onSearch: (value) => [ | ||||
|       { | ||||
|         field: 'filename', | ||||
|         field: 'media_name', | ||||
|         operator: 'contains', | ||||
|         value, | ||||
|       }, | ||||
| @@ -183,13 +183,13 @@ export const CarrierCreate = () => { | ||||
|                 field.onChange(value?.id || '') | ||||
|               }} | ||||
|               getOptionLabel={(item) => { | ||||
|                 return item ? item.filename : '' | ||||
|                 return item ? item.media_name : '' | ||||
|               }} | ||||
|               isOptionEqualToValue={(option, value) => { | ||||
|                 return option.id === value?.id | ||||
|               }} | ||||
|               filterOptions={(options, {inputValue}) => { | ||||
|                 return options.filter((option) => option.filename.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.logo} helperText={(errors as any)?.logo?.message} />} | ||||
|             /> | ||||
|   | ||||
| @@ -26,7 +26,7 @@ export const CarrierEdit = () => { | ||||
|     resource: 'media', | ||||
|     onSearch: (value) => [ | ||||
|       { | ||||
|         field: 'filename', | ||||
|         field: 'media_name', | ||||
|         operator: 'contains', | ||||
|         value, | ||||
|       }, | ||||
| @@ -182,13 +182,13 @@ export const CarrierEdit = () => { | ||||
|                 field.onChange(value?.id || '') | ||||
|               }} | ||||
|               getOptionLabel={(item) => { | ||||
|                 return item ? item.filename : '' | ||||
|                 return item ? item.media_name : '' | ||||
|               }} | ||||
|               isOptionEqualToValue={(option, value) => { | ||||
|                 return option.id === value?.id | ||||
|               }} | ||||
|               filterOptions={(options, {inputValue}) => { | ||||
|                 return options.filter((option) => option.filename.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.logo} helperText={(errors as any)?.logo?.message} />} | ||||
|             /> | ||||
|   | ||||
| @@ -20,7 +20,7 @@ export const CityCreate = () => { | ||||
|     resource: 'media', | ||||
|     onSearch: (value) => [ | ||||
|       { | ||||
|         field: 'filename', | ||||
|         field: 'media_name', | ||||
|         operator: 'contains', | ||||
|         value, | ||||
|       }, | ||||
| @@ -79,13 +79,13 @@ export const CityCreate = () => { | ||||
|                 field.onChange(value?.id || '') | ||||
|               }} | ||||
|               getOptionLabel={(item) => { | ||||
|                 return item ? item.filename : '' | ||||
|                 return item ? item.media_name : '' | ||||
|               }} | ||||
|               isOptionEqualToValue={(option, value) => { | ||||
|                 return option.id === value?.id | ||||
|               }} | ||||
|               filterOptions={(options, {inputValue}) => { | ||||
|                 return options.filter((option) => option.filename.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} />} | ||||
|             /> | ||||
|   | ||||
| @@ -19,7 +19,7 @@ export const CityEdit = () => { | ||||
|     resource: 'media', | ||||
|     onSearch: (value) => [ | ||||
|       { | ||||
|         field: 'filename', | ||||
|         field: 'media_name', | ||||
|         operator: 'contains', | ||||
|         value, | ||||
|       }, | ||||
| @@ -79,13 +79,13 @@ export const CityEdit = () => { | ||||
|                 field.onChange(value?.id || '') | ||||
|               }} | ||||
|               getOptionLabel={(item) => { | ||||
|                 return item ? item.filename : '' | ||||
|                 return item ? item.media_name : '' | ||||
|               }} | ||||
|               isOptionEqualToValue={(option, value) => { | ||||
|                 return option.id === value?.id | ||||
|               }} | ||||
|               filterOptions={(options, {inputValue}) => { | ||||
|                 return options.filter((option) => option.filename.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} />} | ||||
|             /> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user