-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Bilal ABBAD <bilal@opsmill.com>
- Loading branch information
1 parent
d58aeff
commit ffc67fb
Showing
34 changed files
with
554 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
frontend/app/src/components/form/fields/relationship-many.field.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { LabelFormField } from "@/components/form/fields/common"; | ||
import { DynamicRelationshipFieldProps, FormRelationshipValue } from "@/components/form/type"; | ||
import { FormField, FormInput, FormMessage } from "@/components/ui/form"; | ||
|
||
import { DEFAULT_FORM_FIELD_VALUE } from "@/components/form/constants"; | ||
import { updateRelationshipFieldValue } from "@/components/form/utils/updateFormFieldValue"; | ||
import { RelationshipManyInput } from "@/components/inputs/relationship-many"; | ||
import { Node } from "@/utils/getObjectItemDisplayValue"; | ||
|
||
export interface RelationshipManyInputProps extends Omit<DynamicRelationshipFieldProps, "type"> {} | ||
|
||
export default function RelationshipManyField({ | ||
defaultValue = DEFAULT_FORM_FIELD_VALUE, | ||
description, | ||
label, | ||
name, | ||
rules, | ||
unique, | ||
...props | ||
}: RelationshipManyInputProps) { | ||
return ( | ||
<FormField | ||
key={name} | ||
name={name} | ||
rules={rules} | ||
defaultValue={defaultValue} | ||
render={({ field }) => { | ||
const fieldData: FormRelationshipValue = field.value; | ||
|
||
return ( | ||
<div className="flex flex-col gap-2"> | ||
<LabelFormField | ||
label={label} | ||
unique={unique} | ||
required={!!rules?.required} | ||
description={description} | ||
fieldData={fieldData} | ||
/> | ||
|
||
<FormInput> | ||
<RelationshipManyInput | ||
{...field} | ||
{...props} | ||
value={fieldData.value as Node[] | null} | ||
onChange={(newValue) => { | ||
field.onChange(updateRelationshipFieldValue(newValue, defaultValue)); | ||
}} | ||
/> | ||
</FormInput> | ||
|
||
<FormMessage /> | ||
</div> | ||
); | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.