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