-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): implement order by, limit and offset in query generator #376
- Loading branch information
1 parent
ecce91a
commit 8b13930
Showing
9 changed files
with
895 additions
and
52 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
lapis2-docs/src/components/QueryGenerator/LabelledInput.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,19 @@ | ||
type Props = { | ||
label: string; | ||
value: string | number | undefined; | ||
onChange: (value: string) => void; | ||
}; | ||
|
||
export const LabelledInput = ({ label, value, onChange }: Props) => { | ||
return ( | ||
<div> | ||
<label className='mr-2'>{label}</label> | ||
<input | ||
type='text' | ||
className='input input-bordered w-48' | ||
value={value} | ||
onChange={(e) => onChange(e.target.value)} | ||
/> | ||
</div> | ||
); | ||
}; |
80 changes: 80 additions & 0 deletions
80
lapis2-docs/src/components/QueryGenerator/OrderLimitOffsetSelection.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,80 @@ | ||
import type { Config } from '../../config.ts'; | ||
import type { Dispatch, SetStateAction } from 'react'; | ||
import type { Selection } from './QueryTypeSelection.tsx'; | ||
import { LabelledInput } from './LabelledInput.tsx'; | ||
|
||
export type OrderByLimitOffset = { | ||
orderBy: string[] | undefined; | ||
limit: number | undefined; | ||
offset: number | undefined; | ||
}; | ||
|
||
type Props = { | ||
config: Config; | ||
selection: Selection; | ||
orderByLimitOffset: OrderByLimitOffset; | ||
onOrderByLimitOffsetChange: Dispatch<SetStateAction<OrderByLimitOffset>>; | ||
}; | ||
|
||
export const OrderLimitOffsetSelection = ({ config, orderByLimitOffset, onOrderByLimitOffsetChange }: Props) => { | ||
return ( | ||
<div className='flex flex-col gap-4'> | ||
{JSON.stringify(orderByLimitOffset)} | ||
<div className='flex flex-column justify-start'> | ||
<label className='mr-2'>Order by:</label> | ||
<div> | ||
{orderByLimitOffset.orderBy?.map((value, index) => ( | ||
<div key={index}> | ||
<input | ||
type='text' | ||
className='input input-bordered w-48' | ||
value={value} | ||
onChange={(e) => | ||
onOrderByLimitOffsetChange((prev) => ({ | ||
...prev, | ||
orderBy: prev.orderBy?.map((v, i) => (i === index ? e.target.value : v)), | ||
})) | ||
} | ||
/> | ||
<button | ||
onClick={() => | ||
onOrderByLimitOffsetChange((prev) => ({ | ||
...prev, | ||
orderBy: prev.orderBy?.filter((_, i) => i !== index), | ||
})) | ||
} | ||
> | ||
- | ||
</button> | ||
</div> | ||
))} | ||
<select> | ||
<option>TODO</option> | ||
<option>a</option> | ||
</select> | ||
<button>+</button> | ||
</div> | ||
</div> | ||
<LabelledInput | ||
label='Limit:' | ||
value={orderByLimitOffset.limit} | ||
onChange={(value) => | ||
onOrderByLimitOffsetChange((prev) => ({ | ||
...prev, | ||
limit: value === '' ? undefined : parseInt(value), | ||
})) | ||
} | ||
/> | ||
<LabelledInput | ||
label='Offset:' | ||
value={orderByLimitOffset.offset} | ||
onChange={(value) => | ||
onOrderByLimitOffsetChange((prev) => ({ | ||
...prev, | ||
offset: value === '' ? undefined : parseInt(value), | ||
})) | ||
} | ||
/> | ||
</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
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