Grid, Card ve Pivot son güncelleme
This commit is contained in:
parent
bd287d752e
commit
ea5dbe91f5
10 changed files with 86 additions and 54 deletions
|
|
@ -86,7 +86,7 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
||||||
`h-${CONTROL_SIZES.xs}`,
|
`h-${CONTROL_SIZES.xs}`,
|
||||||
icon && !children
|
icon && !children
|
||||||
? `w-${CONTROL_SIZES.xs} ${sizeIconClass} text-base`
|
? `w-${CONTROL_SIZES.xs} ${sizeIconClass} text-base`
|
||||||
: 'px-3 py-1 text-xs'
|
: 'px-2 py-1 text-xs'
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
@import './assets/styles/app.css';
|
@import './assets/styles/app.css';
|
||||||
|
|
||||||
|
.dx-field-item {
|
||||||
|
padding-top: 5px !important;
|
||||||
|
}
|
||||||
|
|
||||||
.dx-toolbar .dx-toolbar-item.no-default {
|
.dx-toolbar .dx-toolbar-item.no-default {
|
||||||
all: unset; /* tüm default style'ları sıfırla */
|
all: unset; /* tüm default style'ları sıfırla */
|
||||||
display: block; /* tekrar görünür yap */
|
display: block; /* tekrar görünür yap */
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,11 @@ export function useCurrentMenuIcon(className = 'w-6 h-6'): JSX.Element {
|
||||||
if (!menu.path) return false
|
if (!menu.path) return false
|
||||||
|
|
||||||
// normalize: /list/ -> /form/
|
// normalize: /list/ -> /form/
|
||||||
const formPath = menu.path.replace('/list/', '/form/')
|
const menuPath = menu.path.toLowerCase()
|
||||||
|
const listFormPath = menuPath.replace('/list/', '/form/')
|
||||||
|
const formPath = listFormPath.replace('/list-', '/form-')
|
||||||
|
|
||||||
return location.pathname.startsWith(menu.path) || location.pathname.startsWith(formPath)
|
return location.pathname.startsWith(menuPath) || location.pathname.startsWith(listFormPath) || location.pathname.startsWith(formPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
const IconComponent = currentMenu?.icon ? navigationIcon[currentMenu.icon] || FaUser : FaUser
|
const IconComponent = currentMenu?.icon ? navigationIcon[currentMenu.icon] || FaUser : FaUser
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,8 @@ const FormButtons = (props: {
|
||||||
if (props.onActionNew) {
|
if (props.onActionNew) {
|
||||||
props.onActionNew()
|
props.onActionNew()
|
||||||
} else {
|
} else {
|
||||||
navigate(ROUTES_ENUM.protected.admin.formNew.replace(':formCode', listFormCode))
|
navigate(-1)
|
||||||
|
//navigate(ROUTES_ENUM.protected.admin.formNew.replace(':formCode', listFormCode))
|
||||||
}
|
}
|
||||||
toast.push(
|
toast.push(
|
||||||
<Notification type="success" duration={2000}>
|
<Notification type="success" duration={2000}>
|
||||||
|
|
@ -171,8 +172,10 @@ const FormButtons = (props: {
|
||||||
|
|
||||||
{!isSubForm && (
|
{!isSubForm && (
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
size="xs"
|
size="xs"
|
||||||
|
variant="default"
|
||||||
|
className="dx-button dx-button-mode-contained dx-button-normal"
|
||||||
|
icon={<FaBackward />}
|
||||||
color="gray-500"
|
color="gray-500"
|
||||||
title={translate('::Cancel')}
|
title={translate('::Cancel')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
@ -183,13 +186,14 @@ const FormButtons = (props: {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FaBackward />
|
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{mode != 'new' && (
|
{mode != 'new' && (
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
size="xs"
|
size="xs"
|
||||||
|
variant="default"
|
||||||
|
className="dx-button dx-button-mode-contained dx-button-normal"
|
||||||
|
icon={<FaTrash />}
|
||||||
color="red-500"
|
color="red-500"
|
||||||
title={translate('::Delete')}
|
title={translate('::Delete')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
@ -197,13 +201,14 @@ const FormButtons = (props: {
|
||||||
}}
|
}}
|
||||||
{...(permissions.d ? {} : { disabled: true })}
|
{...(permissions.d ? {} : { disabled: true })}
|
||||||
>
|
>
|
||||||
<FaTrash />
|
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{mode != 'new' && (
|
{mode != 'new' && (
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
size="xs"
|
size="xs"
|
||||||
|
variant="default"
|
||||||
|
className="dx-button dx-button-mode-contained dx-button-normal"
|
||||||
|
icon={<FaPlus />}
|
||||||
title={translate('::AddNew')}
|
title={translate('::AddNew')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (onActionNew) {
|
if (onActionNew) {
|
||||||
|
|
@ -213,14 +218,14 @@ const FormButtons = (props: {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
{...(permissions.c ? {} : { disabled: true })}
|
{...(permissions.c ? {} : { disabled: true })}
|
||||||
>
|
></Button>
|
||||||
<FaPlus />
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
{mode == 'view' && (
|
{mode == 'view' && (
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
size="xs"
|
size="xs"
|
||||||
|
variant="default"
|
||||||
|
className="dx-button dx-button-mode-contained dx-button-normal"
|
||||||
|
icon={<FaEdit />}
|
||||||
title={translate('::Edit')}
|
title={translate('::Edit')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (onActionEdit) {
|
if (onActionEdit) {
|
||||||
|
|
@ -234,14 +239,14 @@ const FormButtons = (props: {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
{...(permissions.u ? {} : { disabled: true })}
|
{...(permissions.u ? {} : { disabled: true })}
|
||||||
>
|
></Button>
|
||||||
<FaEdit />
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
{(mode == 'edit' || (onActionView && mode == 'new')) && (
|
{(mode == 'edit' || (onActionView && mode == 'new')) && (
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
size="xs"
|
size="xs"
|
||||||
|
variant="default"
|
||||||
|
className="dx-button dx-button-mode-contained dx-button-normal"
|
||||||
|
icon={<FaFileAlt />}
|
||||||
title={translate('::Detail')}
|
title={translate('::Detail')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (onActionView) {
|
if (onActionView) {
|
||||||
|
|
@ -255,26 +260,26 @@ const FormButtons = (props: {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
{...(permissions.r ? {} : { disabled: true })}
|
{...(permissions.r ? {} : { disabled: true })}
|
||||||
>
|
></Button>
|
||||||
<FaFileAlt />
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
{(mode == 'edit' || mode == 'new') && (
|
{(mode == 'edit' || mode == 'new') && (
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
size="xs"
|
size="xs"
|
||||||
|
variant="default"
|
||||||
|
className="dx-button dx-button-mode-contained dx-button-normal"
|
||||||
|
icon={<FaSave />}
|
||||||
title={translate('::Save')}
|
title={translate('::Save')}
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
{...(permissions.c || permissions.u ? {} : { disabled: true })}
|
{...(permissions.c || permissions.u ? {} : { disabled: true })}
|
||||||
>
|
></Button>
|
||||||
<FaSave />
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
{checkPermission(gridDto?.gridOptions.permissionDto.c) && !isSubForm && (
|
{checkPermission(gridDto?.gridOptions.permissionDto.c) && !isSubForm && (
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
color="green-500"
|
|
||||||
size="xs"
|
size="xs"
|
||||||
|
variant="default"
|
||||||
|
className="dx-button dx-button-mode-contained dx-button-normal"
|
||||||
|
icon={<FaInfo />}
|
||||||
|
color="green-500"
|
||||||
title={translate('::ListForms.ListForm.Manage')}
|
title={translate('::ListForms.ListForm.Manage')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.open(
|
window.open(
|
||||||
|
|
@ -285,9 +290,7 @@ const FormButtons = (props: {
|
||||||
isPwaMode ? '_self' : '_blank',
|
isPwaMode ? '_self' : '_blank',
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
>
|
></Button>
|
||||||
<FaInfo />
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Dialog
|
<Dialog
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ const FormDevExpress = (props: {
|
||||||
const { listFormCode, isSubForm, mode, refForm, formData, formItems, setFormData } = props
|
const { listFormCode, isSubForm, mode, refForm, formData, formItems, setFormData } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className={`${DX_CLASSNAMES} py-2 px-2`}>
|
<form className={`${DX_CLASSNAMES} ${!isSubForm ? 'px-2' : ''} pb-2`}>
|
||||||
<FormDx
|
<FormDx
|
||||||
ref={refForm}
|
ref={refForm}
|
||||||
formData={formData}
|
formData={formData}
|
||||||
|
|
@ -43,6 +43,7 @@ const FormDevExpress = (props: {
|
||||||
{formItems.map((formGroupItem, i) => {
|
{formItems.map((formGroupItem, i) => {
|
||||||
return (
|
return (
|
||||||
<GroupItemDx
|
<GroupItemDx
|
||||||
|
|
||||||
key={'formGroupItem-' + i}
|
key={'formGroupItem-' + i}
|
||||||
colCount={formGroupItem.colCount}
|
colCount={formGroupItem.colCount}
|
||||||
colSpan={formGroupItem.colSpan}
|
colSpan={formGroupItem.colSpan}
|
||||||
|
|
@ -96,6 +97,7 @@ const FormDevExpress = (props: {
|
||||||
</SimpleItemDx>
|
</SimpleItemDx>
|
||||||
) : (
|
) : (
|
||||||
<SimpleItemDx
|
<SimpleItemDx
|
||||||
|
cssClass='font-semibold'
|
||||||
key={'formItem-' + i}
|
key={'formItem-' + i}
|
||||||
{...formItem}
|
{...formItem}
|
||||||
editorOptions={{
|
editorOptions={{
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ const FormView = (
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="px-2">
|
<div className={`${isSubForm ? 'px-2' : ''}`}>
|
||||||
<FormDevExpress
|
<FormDevExpress
|
||||||
mode={mode}
|
mode={mode}
|
||||||
refForm={refForm}
|
refForm={refForm}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import { GridDto, SubFormDto, SubFormTabTypeEnum } from '@/proxy/form/models'
|
||||||
import FormEdit from './FormEdit'
|
import FormEdit from './FormEdit'
|
||||||
import FormNew from './FormNew'
|
import FormNew from './FormNew'
|
||||||
import FormView from './FormView'
|
import FormView from './FormView'
|
||||||
|
import { getList } from '@/services/form.service'
|
||||||
|
|
||||||
const SubForms = (props: {
|
const SubForms = (props: {
|
||||||
gridDto: GridDto
|
gridDto: GridDto
|
||||||
|
|
@ -78,7 +79,7 @@ const SubForms = (props: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className='mt-2'
|
className="mt-2"
|
||||||
>
|
>
|
||||||
<TabList>
|
<TabList>
|
||||||
{subForms.map((subForm, i) => {
|
{subForms.map((subForm, i) => {
|
||||||
|
|
|
||||||
|
|
@ -20,20 +20,7 @@ import { Container, Loading } from '@/components/shared'
|
||||||
import WidgetGroup from '@/components/common/WidgetGroup'
|
import WidgetGroup from '@/components/common/WidgetGroup'
|
||||||
import { GridExtraFilterState } from './Utils'
|
import { GridExtraFilterState } from './Utils'
|
||||||
import { useStoreActions, useStoreState } from '@/store/store'
|
import { useStoreActions, useStoreState } from '@/store/store'
|
||||||
|
import { FaTrashCan } from 'react-icons/fa6'
|
||||||
interface CardProps {
|
|
||||||
listFormCode: string
|
|
||||||
searchParams?: URLSearchParams
|
|
||||||
isSubForm?: boolean
|
|
||||||
level?: number
|
|
||||||
refreshData?: () => Promise<void>
|
|
||||||
gridDto?: GridDto
|
|
||||||
}
|
|
||||||
|
|
||||||
type Option = {
|
|
||||||
value: number
|
|
||||||
label: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const CardItem = ({
|
const CardItem = ({
|
||||||
isSubForm,
|
isSubForm,
|
||||||
|
|
@ -189,6 +176,20 @@ const CardItem = ({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CardProps {
|
||||||
|
listFormCode: string
|
||||||
|
searchParams?: URLSearchParams
|
||||||
|
isSubForm?: boolean
|
||||||
|
level?: number
|
||||||
|
refreshData?: () => Promise<void>
|
||||||
|
gridDto?: GridDto
|
||||||
|
}
|
||||||
|
|
||||||
|
type Option = {
|
||||||
|
value: number
|
||||||
|
label: string
|
||||||
|
}
|
||||||
|
|
||||||
const Card = (props: CardProps) => {
|
const Card = (props: CardProps) => {
|
||||||
const { listFormCode, searchParams, gridDto } = props
|
const { listFormCode, searchParams, gridDto } = props
|
||||||
const { createSelectDataSource } = useListFormCustomDataSource({})
|
const { createSelectDataSource } = useListFormCustomDataSource({})
|
||||||
|
|
@ -287,6 +288,7 @@ const Card = (props: CardProps) => {
|
||||||
const dataSource = createSelectDataSource(gridDto.gridOptions, listFormCode, urlSearchParams)
|
const dataSource = createSelectDataSource(gridDto.gridOptions, listFormCode, urlSearchParams)
|
||||||
setGridDataSource(dataSource)
|
setGridDataSource(dataSource)
|
||||||
|
|
||||||
|
//listFormStates
|
||||||
const listFormStates = states.find((a) => a.listFormCode === listFormCode)
|
const listFormStates = states.find((a) => a.listFormCode === listFormCode)
|
||||||
if (listFormStates) {
|
if (listFormStates) {
|
||||||
setLayoutCount(listFormStates.cardLayoutColumn || 4)
|
setLayoutCount(listFormStates.cardLayoutColumn || 4)
|
||||||
|
|
@ -340,7 +342,7 @@ const Card = (props: CardProps) => {
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||||
|
|
||||||
if (data.length < 3) {
|
if (data.length < 6) {
|
||||||
setLayoutCount(data.length)
|
setLayoutCount(data.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -379,9 +381,9 @@ const Card = (props: CardProps) => {
|
||||||
onFilter(newValue)
|
onFilter(newValue)
|
||||||
setPrevValue(newValue)
|
setPrevValue(newValue)
|
||||||
}}
|
}}
|
||||||
className="p-1 pl-6 pr-2 border border-1 outline-none text-xs text-gray-700
|
className="p-1 pl-6 pr-2 border border-1 outline-none text-xs text-gray-700 dark:text-gray-200 placeholder-gray-400 rounded"
|
||||||
dark:text-gray-200 placeholder-gray-400 rounded"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
size="xs"
|
size="xs"
|
||||||
variant={layoutCount === 1 ? 'solid' : 'default'}
|
variant={layoutCount === 1 ? 'solid' : 'default'}
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ import { useToolbar } from './useToolbar'
|
||||||
import { ImportDashboard } from '@/components/importManager/ImportDashboard'
|
import { ImportDashboard } from '@/components/importManager/ImportDashboard'
|
||||||
import WidgetGroup from '@/components/ui/Widget/WidgetGroup'
|
import WidgetGroup from '@/components/ui/Widget/WidgetGroup'
|
||||||
import { GridExtraFilterToolbar } from './GridExtraFilterToolbar'
|
import { GridExtraFilterToolbar } from './GridExtraFilterToolbar'
|
||||||
|
import { getList } from '@/services/form.service'
|
||||||
|
|
||||||
interface GridProps {
|
interface GridProps {
|
||||||
listFormCode: string
|
listFormCode: string
|
||||||
|
|
@ -79,7 +80,7 @@ interface GridProps {
|
||||||
const statedGridPanelColor = 'rgba(50, 200, 200, 0.5)' // kullanici tanimli gridState ile islem gormus gridin paneline ait renk
|
const statedGridPanelColor = 'rgba(50, 200, 200, 0.5)' // kullanici tanimli gridState ile islem gormus gridin paneline ait renk
|
||||||
|
|
||||||
const Grid = (props: GridProps) => {
|
const Grid = (props: GridProps) => {
|
||||||
const { listFormCode, searchParams, isSubForm, level, gridDto } = props
|
const { listFormCode, searchParams, isSubForm, level, gridDto: extGridDto } = props
|
||||||
const { translate } = useLocalization()
|
const { translate } = useLocalization()
|
||||||
const { smaller } = useResponsive()
|
const { smaller } = useResponsive()
|
||||||
|
|
||||||
|
|
@ -91,6 +92,7 @@ const Grid = (props: GridProps) => {
|
||||||
const [formData, setFormData] = useState<any>()
|
const [formData, setFormData] = useState<any>()
|
||||||
const [mode, setMode] = useState<RowMode>('view')
|
const [mode, setMode] = useState<RowMode>('view')
|
||||||
const [extraFilters, setExtraFilters] = useState<GridExtraFilterState[]>([])
|
const [extraFilters, setExtraFilters] = useState<GridExtraFilterState[]>([])
|
||||||
|
const [gridDto, setGridDto] = useState<GridDto>()
|
||||||
|
|
||||||
const preloadExportLibs = () => {
|
const preloadExportLibs = () => {
|
||||||
import('exceljs')
|
import('exceljs')
|
||||||
|
|
@ -103,7 +105,19 @@ const Grid = (props: GridProps) => {
|
||||||
const defaultSearchParams = useRef<string | null>(null)
|
const defaultSearchParams = useRef<string | null>(null)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// sadece 1 kere açılışta al
|
const initializeGrid = async () => {
|
||||||
|
const response = await getList({ listFormCode })
|
||||||
|
setGridDto(response.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extGridDto === undefined) {
|
||||||
|
initializeGrid()
|
||||||
|
} else {
|
||||||
|
setGridDto(extGridDto)
|
||||||
|
}
|
||||||
|
}, [listFormCode, extGridDto])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
if (!defaultSearchParams.current) {
|
if (!defaultSearchParams.current) {
|
||||||
defaultSearchParams.current = searchParams?.get('filter') ?? null
|
defaultSearchParams.current = searchParams?.get('filter') ?? null
|
||||||
}
|
}
|
||||||
|
|
@ -399,9 +413,8 @@ const Grid = (props: GridProps) => {
|
||||||
gridRef.current.instance.state(null)
|
gridRef.current.instance.state(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refListFormCode.current && refListFormCode.current !== listFormCode) {
|
if (refListFormCode.current !== listFormCode) {
|
||||||
setExtraFilters([])
|
setExtraFilters([])
|
||||||
defaultSearchParams.current = null
|
|
||||||
}
|
}
|
||||||
}, [listFormCode])
|
}, [listFormCode])
|
||||||
|
|
||||||
|
|
@ -493,6 +506,7 @@ const Grid = (props: GridProps) => {
|
||||||
searchParams?.delete('filter')
|
searchParams?.delete('filter')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gridRef.current?.instance.refresh()
|
gridRef.current?.instance.refresh()
|
||||||
}, [extraFilters])
|
}, [extraFilters])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,10 @@ const List = () => {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!gridDto) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<div
|
<div
|
||||||
|
|
@ -63,7 +67,7 @@ const List = () => {
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{MenuIcon}
|
{MenuIcon}
|
||||||
<h4 className="text-slate-700 text-sm font-medium leading-none">
|
<h4 className="text-slate-700 text-sm font-medium leading-none">
|
||||||
{translate('::' + gridDto?.gridOptions?.title)}
|
{translate('::' + gridDto?.gridOptions?.title) || ''}
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue