feat: working PoC for reusing relationship filters in validate
This commit is contained in:
@@ -38,7 +38,6 @@ export type Props = {
|
||||
initialData?: Data
|
||||
waitForAutocomplete?: boolean
|
||||
log?: boolean
|
||||
validationOperation?: 'create' | 'update'
|
||||
}
|
||||
|
||||
export type SubmitOptions = {
|
||||
|
||||
@@ -78,7 +78,7 @@ const Relationship: React.FC<Props> = (props) => {
|
||||
const [lastFullyLoadedRelation, setLastFullyLoadedRelation] = useState(-1);
|
||||
const [lastLoadedPage, setLastLoadedPage] = useState(1);
|
||||
const [errorLoading, setErrorLoading] = useState('');
|
||||
const [optionFilters, setOptionFilters] = useState<{[relation: string]: Where}>({});
|
||||
const [optionFilters, setOptionFilters] = useState<{[relation: string]: Where}>();
|
||||
const [hasLoadedValueOptions, setHasLoadedValueOptions] = useState(false);
|
||||
const [search, setSearch] = useState('');
|
||||
|
||||
@@ -311,11 +311,13 @@ const Relationship: React.FC<Props> = (props) => {
|
||||
}, [relationTo, filterOptions, optionFilters, id, getData, getSiblingData, path, user]);
|
||||
|
||||
useEffect(() => {
|
||||
setHasLoadedValueOptions(false);
|
||||
getResults({
|
||||
value: initialValue,
|
||||
});
|
||||
}, [initialValue, getResults]);
|
||||
if (optionFilters) {
|
||||
setHasLoadedValueOptions(false);
|
||||
getResults({
|
||||
value: initialValue,
|
||||
});
|
||||
}
|
||||
}, [initialValue, getResults, optionFilters]);
|
||||
|
||||
const classes = [
|
||||
'field-type',
|
||||
|
||||
@@ -53,7 +53,6 @@ const AddUploadModal: React.FC<Props> = (props) => {
|
||||
action={`${serverURL}${api}/${collection.slug}`}
|
||||
onSuccess={onSuccess}
|
||||
disableSuccessStatus
|
||||
validationOperation="create"
|
||||
>
|
||||
<header className={`${baseClass}__header`}>
|
||||
<div>
|
||||
|
||||
@@ -65,7 +65,6 @@ const CreateFirstUser: React.FC<Props> = (props) => {
|
||||
method="post"
|
||||
redirect={admin}
|
||||
action={`${serverURL}${api}/${userSlug}/first-register`}
|
||||
validationOperation="create"
|
||||
>
|
||||
<NegativeFieldGutterProvider allow>
|
||||
<RenderFields
|
||||
|
||||
@@ -85,7 +85,6 @@ const DefaultEditView: React.FC<Props> = (props) => {
|
||||
onSuccess={onSave}
|
||||
disabled={!hasSavePermission}
|
||||
initialState={initialState}
|
||||
validationOperation={isEditing ? 'update' : 'create'}
|
||||
>
|
||||
<div className={`${baseClass}__main`}>
|
||||
<Meta
|
||||
|
||||
Reference in New Issue
Block a user