mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	Remove moment from validation schema
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
		
							parent
							
								
									b37da48380
								
							
						
					
					
						commit
						2585780a79
					
				| @ -56,7 +56,9 @@ | ||||
|         "i18n": { | ||||
|           "localized": true | ||||
|         } | ||||
|       } | ||||
|       }, | ||||
|       "repeatable": false, | ||||
|       "required": true | ||||
|     }, | ||||
|     "contactEmail": { | ||||
|       "type": "email", | ||||
|  | ||||
| @ -11,91 +11,41 @@ | ||||
|   "options": { | ||||
|     "draftAndPublish": false | ||||
|   }, | ||||
|   "pluginOptions": { | ||||
|     "i18n": { | ||||
|       "localized": true | ||||
|     } | ||||
|   }, | ||||
|   "pluginOptions": {}, | ||||
|   "attributes": { | ||||
|     "name": { | ||||
|       "type": "string", | ||||
|       "pluginOptions": { | ||||
|         "i18n": { | ||||
|           "localized": true | ||||
|         } | ||||
|       } | ||||
|       "pluginOptions": {} | ||||
|     }, | ||||
|     "temp": { | ||||
|       "type": "component", | ||||
|       "repeatable": true, | ||||
|       "component": "default.temp", | ||||
|       "pluginOptions": { | ||||
|         "i18n": { | ||||
|           "localized": true | ||||
|         } | ||||
|       } | ||||
|     "simple": { | ||||
|       "pluginOptions": {}, | ||||
|       "type": "uid" | ||||
|     }, | ||||
|     "dz": { | ||||
|       "pluginOptions": { | ||||
|         "i18n": { | ||||
|           "localized": true | ||||
|         } | ||||
|     "attached": { | ||||
|       "pluginOptions": {}, | ||||
|       "type": "uid", | ||||
|       "targetField": "name" | ||||
|     }, | ||||
|       "type": "dynamiczone", | ||||
|       "components": [ | ||||
|         "basic.simple", | ||||
|         "blog.test-como", | ||||
|         "default.closingperiod", | ||||
|         "default.dish", | ||||
|         "default.openingtimes", | ||||
|         "default.restaurantservice", | ||||
|         "default.temp", | ||||
|         "default.apple", | ||||
|         "default.car" | ||||
|       ], | ||||
|       "required": true, | ||||
|       "min": 2 | ||||
|     "attached_req": { | ||||
|       "pluginOptions": {}, | ||||
|       "type": "uid", | ||||
|       "targetField": "name", | ||||
|       "required": true | ||||
|     }, | ||||
|     "dz_req": { | ||||
|       "type": "dynamiczone", | ||||
|       "components": [ | ||||
|         "default.apple", | ||||
|         "default.car", | ||||
|         "default.closingperiod", | ||||
|         "default.dish", | ||||
|         "default.openingtimes", | ||||
|         "default.restaurantservice", | ||||
|         "default.temp" | ||||
|       ], | ||||
|       "required": true, | ||||
|       "pluginOptions": { | ||||
|         "i18n": { | ||||
|           "localized": true | ||||
|         } | ||||
|       } | ||||
|     "req": { | ||||
|       "pluginOptions": {}, | ||||
|       "type": "uid", | ||||
|       "required": true | ||||
|     }, | ||||
|     "dz_simple": { | ||||
|       "type": "dynamiczone", | ||||
|       "components": [ | ||||
|         "basic.simple" | ||||
|       ], | ||||
|       "pluginOptions": { | ||||
|         "i18n": { | ||||
|           "localized": true | ||||
|         } | ||||
|       } | ||||
|     "default_val": { | ||||
|       "pluginOptions": {}, | ||||
|       "type": "uid", | ||||
|       "default": "to", | ||||
|       "minLength": 4 | ||||
|     }, | ||||
|     "dz_max": { | ||||
|       "type": "dynamiczone", | ||||
|       "components": [ | ||||
|         "basic.simple" | ||||
|       ], | ||||
|       "max": 2, | ||||
|       "pluginOptions": { | ||||
|         "i18n": { | ||||
|           "localized": true | ||||
|         } | ||||
|       } | ||||
|     "date": { | ||||
|       "type": "date", | ||||
|       "required": true | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -7,7 +7,8 @@ | ||||
|   }, | ||||
|   "attributes": { | ||||
|     "label": { | ||||
|       "type": "string" | ||||
|       "type": "string", | ||||
|       "default": "toto" | ||||
|     }, | ||||
|     "start_date": { | ||||
|       "type": "date", | ||||
| @ -19,11 +20,15 @@ | ||||
|     }, | ||||
|     "media": { | ||||
|       "type": "media", | ||||
|       "multiple": false, | ||||
|       "required": false | ||||
|     }, | ||||
|     "dish": { | ||||
|       "component": "default.dish", | ||||
|       "type": "component" | ||||
|       "type": "component", | ||||
|       "repeatable": true, | ||||
|       "required": true, | ||||
|       "min": 2 | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -36,6 +36,7 @@ const cleanData = (retrievedData, currentSchema, componentsSchema) => { | ||||
|         case 'time': { | ||||
|           cleanedData = value; | ||||
| 
 | ||||
|           // FIXME
 | ||||
|           if (value && value.split(':').length < 3) { | ||||
|             cleanedData = `${value}:00`; | ||||
|           } | ||||
|  | ||||
| @ -9,7 +9,7 @@ import { | ||||
|   isNaN, | ||||
|   toNumber, | ||||
| } from 'lodash'; | ||||
| import moment from 'moment'; | ||||
| 
 | ||||
| import * as yup from 'yup'; | ||||
| import { translatedErrors as errorsTrads } from '@strapi/helper-plugin'; | ||||
| 
 | ||||
| @ -291,10 +291,6 @@ const createYupSchemaAttribute = (type, validations, options) => { | ||||
|                     return !!value; | ||||
|                   } | ||||
| 
 | ||||
|                   if (['date', 'datetime'].includes(type)) { | ||||
|                     return moment(value)._isValid === true; | ||||
|                   } | ||||
| 
 | ||||
|                   if (type === 'boolean') { | ||||
|                     return value !== null; | ||||
|                   } | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| import React, { useEffect, useState, useRef } from 'react'; | ||||
| import React, { useEffect, useState, useRef, memo } from 'react'; | ||||
| import PropTypes from 'prop-types'; | ||||
| import { useCMEditViewDataManager } from '@strapi/helper-plugin'; | ||||
| import { useIntl } from 'react-intl'; | ||||
| @ -13,7 +13,12 @@ import AlertSucessIcon from '@strapi/icons/AlertSucessIcon'; | ||||
| import AlertWarningIcon from '@strapi/icons/AlertWarningIcon'; | ||||
| import LoadingIcon from '@strapi/icons/LoadingIcon'; | ||||
| import useDebounce from './useDebounce'; | ||||
| import { EndActionWrapper, FieldActionWrapper, TextValidation, LoadingWrapper } from './endActionStyle'; | ||||
| import { | ||||
|   EndActionWrapper, | ||||
|   FieldActionWrapper, | ||||
|   TextValidation, | ||||
|   LoadingWrapper, | ||||
| } from './endActionStyle'; | ||||
| 
 | ||||
| // {
 | ||||
| 
 | ||||
| @ -30,7 +35,8 @@ import { EndActionWrapper, FieldActionWrapper, TextValidation, LoadingWrapper } | ||||
| // editable,
 | ||||
| // ...inputProps
 | ||||
| // }
 | ||||
| const InputUID = ({  | ||||
| const InputUID = props => { | ||||
|   const { | ||||
|     attribute, | ||||
|     contentTypeUID, | ||||
|     description, | ||||
| @ -42,7 +48,8 @@ const InputUID = ({ | ||||
|     onChange, | ||||
|     value, | ||||
|     ...rest | ||||
| }) => { | ||||
|   } = props; | ||||
| 
 | ||||
|   const { modifiedData, initialData, layout } = useCMEditViewDataManager(); | ||||
|   const [isLoading, setIsLoading] = useState(false); | ||||
|   const [availability, setAvailability] = useState(null); | ||||
| @ -182,26 +189,32 @@ const InputUID = ({ | ||||
|       disabled={disabled} | ||||
|       endAction={ | ||||
|         <EndActionWrapper> | ||||
|           {availability && availability.isAvailable && !regenerateLabel && | ||||
|             <TextValidation alignItems='center' justifyContent='flex-end'> | ||||
|           {availability && availability.isAvailable && !regenerateLabel && ( | ||||
|             <TextValidation alignItems="center" justifyContent="flex-end"> | ||||
|               <AlertSucessIcon /> | ||||
|               <Text textColor='success600' small>Available</Text> | ||||
|               <Text textColor="success600" small> | ||||
|                 Available | ||||
|               </Text> | ||||
|             </TextValidation> | ||||
|           } | ||||
|           {availability && !availability.isAvailable && !regenerateLabel && | ||||
|             <TextValidation notAvailable alignItems='center' justifyContent='flex-end'> | ||||
|           )} | ||||
|           {availability && !availability.isAvailable && !regenerateLabel && ( | ||||
|             <TextValidation notAvailable alignItems="center" justifyContent="flex-end"> | ||||
|               <AlertWarningIcon /> | ||||
|               <Text textColor='danger600' small>Unavailable</Text> | ||||
|               <Text textColor="danger600" small> | ||||
|                 Unavailable | ||||
|               </Text> | ||||
|             </TextValidation> | ||||
|           } | ||||
|           {regenerateLabel && | ||||
|             <TextValidation alignItems='center' justifyContent='flex-end'> | ||||
|               <Text textColor='primary600' small>{regenerateLabel}</Text> | ||||
|           )} | ||||
|           {regenerateLabel && ( | ||||
|             <TextValidation alignItems="center" justifyContent="flex-end"> | ||||
|               <Text textColor="primary600" small> | ||||
|                 {regenerateLabel} | ||||
|               </Text> | ||||
|             </TextValidation> | ||||
|           } | ||||
|           )} | ||||
|           <FieldActionWrapper | ||||
|             onClick={() => generateUid.current()} | ||||
|             label='regenerate' | ||||
|             label="regenerate" | ||||
|             onMouseEnter={handleGenerateMouseEnter} | ||||
|             onMouseLeave={handleGenerateMouseLeave} | ||||
|           > | ||||
| @ -209,9 +222,9 @@ const InputUID = ({ | ||||
|               <LoadingWrapper> | ||||
|                 <LoadingIcon /> | ||||
|               </LoadingWrapper> | ||||
|             ) :  | ||||
|             ) : ( | ||||
|               <Reload /> | ||||
|             } | ||||
|             )} | ||||
|           </FieldActionWrapper> | ||||
|         </EndActionWrapper> | ||||
|       } | ||||
| @ -323,4 +336,5 @@ const InputUID = ({ | ||||
| //   value: '',
 | ||||
| // };
 | ||||
| 
 | ||||
| // export default memo(InputUID, isEqual);
 | ||||
| export default InputUID; | ||||
|  | ||||
| @ -15,7 +15,6 @@ import InputJSON from '../InputJSON'; | ||||
| import GenericInput from './GenericInput'; | ||||
| import InputUID from '../InputUID'; | ||||
| // import SelectWrapper from '../SelectWrapper';
 | ||||
| // import WysiwygWithErrors from '../WysiwygWithErrors';
 | ||||
| 
 | ||||
| import { | ||||
|   connect, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 soupette
						soupette