Skip to content

Commit

Permalink
Merge pull request #2092 from AbdulWahab3181/add-index-to-node-type-c…
Browse files Browse the repository at this point in the history
…reation

Add Index to node type creation in Ontology
  • Loading branch information
Rassl authored Aug 28, 2024
2 parents 2127b09 + 43d1e94 commit f521bcc
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Button } from '@mui/material'
import { Button, Grid } from '@mui/material'
import { useEffect, useMemo, useState } from 'react'
import { FieldValues, FormProvider, useForm } from 'react-hook-form'
import { ClipLoader } from 'react-spinners'
Expand Down Expand Up @@ -32,6 +32,7 @@ export type FormData = {
attributes?: {
[k: string]: string | boolean
}
selectedIndex?: string
}

type Props = {
Expand Down Expand Up @@ -70,7 +71,7 @@ const handleSubmitForm = async (
mediaOptions: { videoAudio: boolean; image: boolean; sourceLink: boolean },
): Promise<string | undefined> => {
try {
const { attributes, ...withoutAttributes } = data
const { attributes, selectedIndex, ...withoutAttributes } = data

const updatedAttributes = {
...convertAttributes(attributes),
Expand All @@ -79,12 +80,14 @@ const handleSubmitForm = async (

const requestData: {
attributes: { [key: string]: string }
index?: string
media_url?: string
image_url?: string
source_link?: string
} = {
...withoutAttributes,
attributes: updatedAttributes,
index: selectedIndex,
}

if (mediaOptions.videoAudio) {
Expand Down Expand Up @@ -476,6 +479,19 @@ export const Editor = ({
parent={selectedSchema ? selectedSchema.type : parent}
/>
<MediaOptions setMediaOptions={setMediaOptions} />
<Flex>
<LineBar />
<Flex mb={12} mt={12}>
<Text>Indexes</Text>
</Flex>
<Grid item mb={2} width="70%">
<AutoComplete
onSelect={(val) => setValue(`selectedIndex`, val?.value)}
options={attributes.map((attr) => ({ label: attr.key, value: attr.key }))}
/>
</Grid>
<LineBar />
</Flex>
<Flex direction="row" justify="space-between" mt={20}>
{selectedSchema && (
<Flex direction="column">
Expand Down Expand Up @@ -557,3 +573,10 @@ const StyledError = styled(Flex)`
margin-top: 12px;
padding-top: 20px;
`

const LineBar = styled.div`
border: 1px solid ${colors.BG2};
width: calc(100% + 32px);
opacity: 0.5;
margin-left: -16px;
`

0 comments on commit f521bcc

Please sign in to comment.