mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
fix(source): fix index plus button (#239)
* 3.0.97 * 3.0.98 * 3.0.99 * fix index plus icon * fix linting
This commit is contained in:
parent
ab304d4251
commit
6327ae7788
@ -9,6 +9,7 @@ export interface StartEndInputProps {
|
|||||||
labelStyle?: string
|
labelStyle?: string
|
||||||
updateStartValue?: (value: string) => void
|
updateStartValue?: (value: string) => void
|
||||||
updateEndValue?: (value: string) => void
|
updateEndValue?: (value: string) => void
|
||||||
|
containerStyle?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,9 +21,10 @@ export const PopupStartEndInput = ({
|
|||||||
labelStyle,
|
labelStyle,
|
||||||
updateStartValue,
|
updateStartValue,
|
||||||
updateEndValue,
|
updateEndValue,
|
||||||
|
containerStyle,
|
||||||
}: StartEndInputProps) => {
|
}: StartEndInputProps) => {
|
||||||
return (
|
return (
|
||||||
<div className='tw:grid tw:grid-cols-2 tw:gap-2'>
|
<div className={`tw:grid tw:grid-cols-2 tw:gap-2 ${containerStyle ?? ''}`}>
|
||||||
<TextInput
|
<TextInput
|
||||||
type='date'
|
type='date'
|
||||||
placeholder='start'
|
placeholder='start'
|
||||||
|
|||||||
@ -21,10 +21,9 @@ export function PlusButton({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{hasUserPermission(collection, 'create', undefined, layer) && (
|
{hasUserPermission(collection, 'create', undefined, layer) && (
|
||||||
<div className='tw:dropdown tw:dropdown-top tw:dropdown-end tw:dropdown-hover tw:z-3000 tw:absolute tw:right-4 tw:bottom-4'>
|
|
||||||
<button
|
<button
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className='tw:z-500 tw:btn tw:btn-circle tw:shadow'
|
className='tw:btn tw:btn-circle tw:shadow tw:z-3000 tw:absolute tw:right-4 tw:bottom-4'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
triggerAction()
|
triggerAction()
|
||||||
}}
|
}}
|
||||||
@ -32,7 +31,6 @@ export function PlusButton({
|
|||||||
>
|
>
|
||||||
<PlusIcon className='tw:w-5 tw:h-5 tw:stroke-[2.5]' />
|
<PlusIcon className='tw:w-5 tw:h-5 tw:stroke-[2.5]' />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { useEffect, useRef, useState } from 'react'
|
|||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
|
|
||||||
import { useAuth } from '#components/Auth/useAuth'
|
import { useAuth } from '#components/Auth/useAuth'
|
||||||
import { TextInput, TextAreaInput } from '#components/Input'
|
import { TextInput } from '#components/Input'
|
||||||
import { useFilterTags } from '#components/Map/hooks/useFilter'
|
import { useFilterTags } from '#components/Map/hooks/useFilter'
|
||||||
import { useAddItem, useItems, useRemoveItem } from '#components/Map/hooks/useItems'
|
import { useAddItem, useItems, useRemoveItem } from '#components/Map/hooks/useItems'
|
||||||
import { useLayers } from '#components/Map/hooks/useLayers'
|
import { useLayers } from '#components/Map/hooks/useLayers'
|
||||||
@ -33,15 +33,13 @@ export const OverlayItemsIndexPage = ({
|
|||||||
url,
|
url,
|
||||||
layerName,
|
layerName,
|
||||||
parameterField,
|
parameterField,
|
||||||
plusButton = true,
|
|
||||||
}: {
|
}: {
|
||||||
layerName: string
|
layerName: string
|
||||||
url: string
|
url: string
|
||||||
parameterField?: string
|
parameterField?: string
|
||||||
plusButton?: boolean
|
|
||||||
}) => {
|
}) => {
|
||||||
const [loading, setLoading] = useState<boolean>(false)
|
const [loading, setLoading] = useState<boolean>(false)
|
||||||
const [addItemPopupType, setAddItemPopupType] = useState<string>('')
|
const [addItemPopupOpen, setAddItemPopupOpen] = useState<boolean>(false)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const parameterFieldDummy = parameterField
|
const parameterFieldDummy = parameterField
|
||||||
|
|
||||||
@ -52,12 +50,10 @@ export const OverlayItemsIndexPage = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (addItemPopupOpen) {
|
||||||
scroll()
|
scroll()
|
||||||
}, [addItemPopupType])
|
}
|
||||||
|
}, [addItemPopupOpen])
|
||||||
useEffect(() => {
|
|
||||||
setAddItemPopupType('')
|
|
||||||
}, [layerName])
|
|
||||||
|
|
||||||
const tags = useTags()
|
const tags = useTags()
|
||||||
const addTag = useAddTag()
|
const addTag = useAddTag()
|
||||||
@ -106,7 +102,7 @@ export const OverlayItemsIndexPage = ({
|
|||||||
}
|
}
|
||||||
addItem({ ...formItem, user_created: user ?? undefined, id: uuid, layer, public_edit: !user })
|
addItem({ ...formItem, user_created: user ?? undefined, id: uuid, layer, public_edit: !user })
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
setAddItemPopupType('')
|
setAddItemPopupOpen(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteItem = async (item: Item) => {
|
const deleteItem = async (item: Item) => {
|
||||||
@ -174,15 +170,18 @@ export const OverlayItemsIndexPage = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{addItemPopupType === 'place' && (
|
{addItemPopupOpen && (
|
||||||
<form ref={tabRef} autoComplete='off' onSubmit={(e) => submitNewItem(e)}>
|
<form ref={tabRef} autoComplete='off' onSubmit={(e) => submitNewItem(e)}>
|
||||||
<div className='tw:cursor-pointer tw:break-inside-avoid card tw:border-[1px] tw:border-base-300 card-body tw:shadow-xl tw:bg-base-100 tw:text-base-content tw:p-6 tw:mb-10'>
|
<div className='tw:cursor-pointer tw:break-inside-avoid card tw:border-[1px] tw:border-base-300 card-body tw:shadow-xl tw:bg-base-100 tw:text-base-content tw:p-6 tw:mb-10'>
|
||||||
<label
|
<label
|
||||||
className='btn btn-sm tw:rounded-2xl btn-circle btn-ghost tw:hover:bg-transparent tw:absolute tw:right-0 tw:top-0 tw:text-gray-600'
|
className='tw:btn tw:btn-sm tw:rounded-2xl tw:btn-circle tw:btn-ghost tw:hover:bg-transparent tw:absolute tw:right-0 tw:top-0 tw:text-gray-600'
|
||||||
onClick={() => setAddItemPopupType('')}
|
onClick={() => setAddItemPopupOpen(false)}
|
||||||
>
|
>
|
||||||
<p className='tw:text-center'>✕</p>
|
<p className='tw:text-center'>✕</p>
|
||||||
</label>
|
</label>
|
||||||
|
<div className='tw:flex tw:justify-center tw:mb-4'>
|
||||||
|
<b className='tw:text-xl tw:text-center tw:font-bold'>{layer?.menuText}</b>
|
||||||
|
</div>
|
||||||
<TextInput
|
<TextInput
|
||||||
type='text'
|
type='text'
|
||||||
placeholder='Name'
|
placeholder='Name'
|
||||||
@ -190,13 +189,9 @@ export const OverlayItemsIndexPage = ({
|
|||||||
defaultValue={''}
|
defaultValue={''}
|
||||||
inputStyle=''
|
inputStyle=''
|
||||||
/>
|
/>
|
||||||
{layer?.itemType.show_start_end_input && <PopupStartEndInput />}
|
{layer?.itemType.show_start_end_input && (
|
||||||
<TextAreaInput
|
<PopupStartEndInput containerStyle='tw:mt-3' showLabels={false} />
|
||||||
placeholder='Text'
|
)}
|
||||||
dataField='text'
|
|
||||||
defaultValue={''}
|
|
||||||
inputStyle='tw:h-40 tw:mt-5'
|
|
||||||
/>
|
|
||||||
<div className='tw:flex tw:justify-center'>
|
<div className='tw:flex tw:justify-center'>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
@ -217,11 +212,11 @@ export const OverlayItemsIndexPage = ({
|
|||||||
</div>
|
</div>
|
||||||
</MapOverlayPage>
|
</MapOverlayPage>
|
||||||
|
|
||||||
{plusButton && (
|
{!layer?.userProfileLayer && (
|
||||||
<PlusButton
|
<PlusButton
|
||||||
layer={layer}
|
layer={layer}
|
||||||
triggerAction={() => {
|
triggerAction={() => {
|
||||||
setAddItemPopupType('place')
|
setAddItemPopupOpen(true)
|
||||||
scroll()
|
scroll()
|
||||||
}}
|
}}
|
||||||
color={'#777'}
|
color={'#777'}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user