mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
feat(app): popup customizing (#333)
* small form edits * fix linting * custom button label * more popup customizing * reset dev port
This commit is contained in:
parent
a599eddca6
commit
cb6737d370
@ -19,6 +19,7 @@ import {
|
|||||||
PopupStartEndInput,
|
PopupStartEndInput,
|
||||||
PopupTextAreaInput,
|
PopupTextAreaInput,
|
||||||
PopupTextInput,
|
PopupTextInput,
|
||||||
|
HeaderView,
|
||||||
} from 'utopia-ui'
|
} from 'utopia-ui'
|
||||||
|
|
||||||
import { itemsApi } from '../api/itemsApi'
|
import { itemsApi } from '../api/itemsApi'
|
||||||
@ -105,7 +106,7 @@ function MapContainer({ layers, map }: { layers: LayerProps[]; map: any }) {
|
|||||||
layer.markerDefaultColor2 ? layer.markerDefaultColor2 : 'RGBA(35, 31, 32, 0.2)'
|
layer.markerDefaultColor2 ? layer.markerDefaultColor2 : 'RGBA(35, 31, 32, 0.2)'
|
||||||
}
|
}
|
||||||
itemType={layer.itemType}
|
itemType={layer.itemType}
|
||||||
customEditLink='/edit-item'
|
customEditLink={layer.itemType.small_form_edit ? undefined : '/edit-item'}
|
||||||
customEditParameter='id'
|
customEditParameter='id'
|
||||||
public_edit_items={layer.public_edit_items}
|
public_edit_items={layer.public_edit_items}
|
||||||
listed={layer.listed}
|
listed={layer.listed}
|
||||||
@ -114,11 +115,16 @@ function MapContainer({ layers, map }: { layers: LayerProps[]; map: any }) {
|
|||||||
<PopupView>
|
<PopupView>
|
||||||
{layer.itemType.show_start_end && <StartEndView></StartEndView>}
|
{layer.itemType.show_start_end && <StartEndView></StartEndView>}
|
||||||
{layer.itemType.show_profile_button && (
|
{layer.itemType.show_profile_button && (
|
||||||
<PopupButton url={'/item'} parameterField={'id'} text={'Profile'} />
|
<PopupButton
|
||||||
|
url={'/item'}
|
||||||
|
parameterField={'id'}
|
||||||
|
text={layer.itemType.botton_label ?? 'Profile'}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{layer.itemType.show_text && <TextView truncate></TextView>}
|
{layer.itemType.show_text && <TextView truncate></TextView>}
|
||||||
</PopupView>
|
</PopupView>
|
||||||
<PopupForm>
|
<PopupForm>
|
||||||
|
{layer.itemType.show_header_view_in_form && <HeaderView hideMenu />}
|
||||||
{layer.itemType.show_name_input && (
|
{layer.itemType.show_name_input && (
|
||||||
<PopupTextInput dataField='name' placeholder='Name'></PopupTextInput>
|
<PopupTextInput dataField='name' placeholder='Name'></PopupTextInput>
|
||||||
)}
|
)}
|
||||||
@ -129,7 +135,7 @@ function MapContainer({ layers, map }: { layers: LayerProps[]; map: any }) {
|
|||||||
<div className='tw:mt-4'>
|
<div className='tw:mt-4'>
|
||||||
<PopupTextAreaInput
|
<PopupTextAreaInput
|
||||||
dataField='text'
|
dataField='text'
|
||||||
placeholder={'Text ...'}
|
placeholder={layer.itemType.text_input_label ?? 'Text ...'}
|
||||||
style='tw:h-40'
|
style='tw:h-40'
|
||||||
></PopupTextAreaInput>
|
></PopupTextAreaInput>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import {
|
|||||||
PopupCheckboxInput as PlainPopupCheckboxInput,
|
PopupCheckboxInput as PlainPopupCheckboxInput,
|
||||||
PopupTextAreaInput as PlainPopupTextAreaInput,
|
PopupTextAreaInput as PlainPopupTextAreaInput,
|
||||||
PopupStartEndInput as PlainPopupStartEndInput,
|
PopupStartEndInput as PlainPopupStartEndInput,
|
||||||
|
HeaderView as PlainHeaderView,
|
||||||
} from '#components/Map/Subcomponents/ItemPopupComponents'
|
} from '#components/Map/Subcomponents/ItemPopupComponents'
|
||||||
|
|
||||||
import { templateify } from './templateify'
|
import { templateify } from './templateify'
|
||||||
@ -20,3 +21,4 @@ export const PopupButton = templateify(PlainPopupButton)
|
|||||||
export const PopupCheckboxInput = templateify(PlainPopupCheckboxInput)
|
export const PopupCheckboxInput = templateify(PlainPopupCheckboxInput)
|
||||||
export const PopupTextAreaInput = templateify(PlainPopupTextAreaInput)
|
export const PopupTextAreaInput = templateify(PlainPopupTextAreaInput)
|
||||||
export const PopupStartEndInput = templateify(PlainPopupStartEndInput)
|
export const PopupStartEndInput = templateify(PlainPopupStartEndInput)
|
||||||
|
export const HeaderView = templateify(PlainHeaderView)
|
||||||
|
|||||||
@ -254,7 +254,7 @@ export function ItemFormPopup(props: Props) {
|
|||||||
onSubmit={(e) => handleSubmit(e)}
|
onSubmit={(e) => handleSubmit(e)}
|
||||||
>
|
>
|
||||||
{popupForm.item ? (
|
{popupForm.item ? (
|
||||||
<div className='tw:h-3'></div>
|
<div className=''></div>
|
||||||
) : (
|
) : (
|
||||||
<div className='tw:flex tw:justify-center'>
|
<div className='tw:flex tw:justify-center'>
|
||||||
<b className='tw:text-xl tw:text-center tw:font-bold'>{menuText}</b>
|
<b className='tw:text-xl tw:text-center tw:font-bold'>{menuText}</b>
|
||||||
|
|||||||
@ -37,7 +37,7 @@ export function HeaderView({
|
|||||||
hideSubname = false,
|
hideSubname = false,
|
||||||
showAddress = false,
|
showAddress = false,
|
||||||
}: {
|
}: {
|
||||||
item: Item
|
item?: Item
|
||||||
api?: ItemsApi<any>
|
api?: ItemsApi<any>
|
||||||
editCallback?: any
|
editCallback?: any
|
||||||
deleteCallback?: any
|
deleteCallback?: any
|
||||||
@ -58,10 +58,10 @@ export function HeaderView({
|
|||||||
const [imageLoaded, setImageLoaded] = useState(false)
|
const [imageLoaded, setImageLoaded] = useState(false)
|
||||||
|
|
||||||
const avatar =
|
const avatar =
|
||||||
(item.image && appState.assetsApi.url + item.image + '?width=160&heigth=160') ||
|
(item?.image && appState.assetsApi.url + item.image + '?width=160&heigth=160') ||
|
||||||
item.image_external
|
item?.image_external
|
||||||
const title = item.name
|
const title = item?.name
|
||||||
const subtitle = item.subname
|
const subtitle = item?.subname
|
||||||
|
|
||||||
const [address] = useState<string>('')
|
const [address] = useState<string>('')
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ export function HeaderView({
|
|||||||
setModalOpen(true)
|
setModalOpen(true)
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
}
|
}
|
||||||
|
if (!item) return null
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className='tw:flex tw:flex-row'>
|
<div className='tw:flex tw:flex-row'>
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export const PopupTextAreaInput = ({
|
|||||||
dataField={dataField}
|
dataField={dataField}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
inputStyle={style}
|
inputStyle={style}
|
||||||
|
required={false}
|
||||||
></TextAreaInput>
|
></TextAreaInput>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,3 +5,4 @@ export { PopupCheckboxInput } from './PopupCheckboxInput'
|
|||||||
export { TextView } from './TextView'
|
export { TextView } from './TextView'
|
||||||
export { StartEndView } from './StartEndView'
|
export { StartEndView } from './StartEndView'
|
||||||
export { PopupButton } from './PopupButton'
|
export { PopupButton } from './PopupButton'
|
||||||
|
export { HeaderView } from './HeaderView'
|
||||||
|
|||||||
4
lib/src/types/ItemType.d.ts
vendored
4
lib/src/types/ItemType.d.ts
vendored
@ -16,4 +16,8 @@ export interface ItemType {
|
|||||||
relations: boolean
|
relations: boolean
|
||||||
template: string
|
template: string
|
||||||
questlog: boolean
|
questlog: boolean
|
||||||
|
small_form_edit?: boolean
|
||||||
|
botton_label?: string
|
||||||
|
text_input_label?: string
|
||||||
|
show_header_view_in_form?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user