Genel Grid düzenlemesi
This commit is contained in:
parent
c11781e2b9
commit
b394c8d837
6 changed files with 36 additions and 21 deletions
|
|
@ -82,7 +82,7 @@ define(['./workbox-a959eb95'], (function (workbox) { 'use strict';
|
|||
"revision": "3ca0b8505b4bec776b69afdba2768812"
|
||||
}, {
|
||||
"url": "/index.html",
|
||||
"revision": "0.sjlnuata16g"
|
||||
"revision": "0.el21c3n5m38"
|
||||
}], {});
|
||||
workbox.cleanupOutdatedCaches();
|
||||
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("/index.html"), {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import CustomStore from 'devextreme/data/custom_store'
|
|||
import { useState } from 'react'
|
||||
import { FaPlus, FaTrash, FaEdit, FaFileAlt, FaSave } from 'react-icons/fa'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { GridColumnData } from '../list/GridColumnData'
|
||||
import { GridColumnData, GridExtraFilterState } from '../list/GridColumnData'
|
||||
import { useToolbar } from '../list/useToolbar'
|
||||
import { PermissionResults, RowMode } from './types'
|
||||
import { GridDto } from '@/proxy/form/models'
|
||||
|
|
@ -49,6 +49,7 @@ const FormButtons = (props: {
|
|||
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [deleteRowId, setDeleteRowId] = useState<string>()
|
||||
const [extraFilters, setExtraFilters] = useState<GridExtraFilterState[]>([])
|
||||
|
||||
const navigate = useNavigate()
|
||||
const { translate } = useLocalization()
|
||||
|
|
@ -59,6 +60,8 @@ const FormButtons = (props: {
|
|||
getSelectedRowsData,
|
||||
refreshData,
|
||||
getFilter,
|
||||
extraFilters,
|
||||
setExtraFilters,
|
||||
})
|
||||
|
||||
const handleDelete = async (e: any) => {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ const FormEdit = (
|
|||
></Helmet>
|
||||
)}
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h3>{translate('::App.Languages.Language')}</h3>
|
||||
<h3>{translate('::' + gridDto?.gridOptions.title)}</h3>
|
||||
{permissionResults && (
|
||||
<FormButtons
|
||||
mode={mode}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const FormView = (
|
|||
></Helmet>
|
||||
)}
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h3>{translate('::App.Languages.Language')}</h3>
|
||||
<h3>{translate('::' + gridDto?.gridOptions.title)}</h3>
|
||||
{permissionResults && (
|
||||
<FormButtons
|
||||
mode={mode}
|
||||
|
|
|
|||
|
|
@ -397,41 +397,53 @@ const Grid = (props: GridProps) => {
|
|||
}, [gridDto])
|
||||
|
||||
useEffect(() => {
|
||||
if (!gridDto) {
|
||||
return
|
||||
}
|
||||
if (!gridDto) return
|
||||
|
||||
// Set columns
|
||||
const cols = getBandedColumns()
|
||||
setColumnData(cols)
|
||||
|
||||
// Filters'i AND ile birleştir
|
||||
let filterArray: any[] = []
|
||||
// 1. extraFilters'tan gelenleri ekle
|
||||
const filterArray: any[] = []
|
||||
extraFilters.forEach((f) => {
|
||||
if (f.value) {
|
||||
if (filterArray.length > 0) {
|
||||
filterArray.push('and')
|
||||
}
|
||||
if (filterArray.length > 0) filterArray.push('and')
|
||||
filterArray.push([f.fieldName, f.operator, f.value])
|
||||
}
|
||||
})
|
||||
|
||||
const params = new URLSearchParams()
|
||||
if (filterArray.length > 0) {
|
||||
params.set('filter', JSON.stringify(filterArray))
|
||||
// 2. searchParams içindeki kolonları filtreye çevir
|
||||
const params = new URLSearchParams(searchParams)
|
||||
if (cols?.length) {
|
||||
cols.forEach((col) => {
|
||||
if (!col.dataField) return
|
||||
const sValue = params.get(col.dataField)
|
||||
if (sValue) {
|
||||
if (filterArray.length > 0) filterArray.push('and')
|
||||
filterArray.push([col.dataField, '=', sValue])
|
||||
// orijinal paramı kaldır
|
||||
params.delete(col.dataField)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set data source
|
||||
const dataSource: CustomStore<any, any> = createSelectDataSource(
|
||||
// 3. oluşan filtreleri `filter` paramına yaz
|
||||
if (filterArray.length > 0) {
|
||||
params.set('filter', JSON.stringify(filterArray))
|
||||
} else {
|
||||
params.delete('filter')
|
||||
}
|
||||
|
||||
// 4. datasource oluştur
|
||||
const dataSource = createSelectDataSource(
|
||||
gridDto.gridOptions,
|
||||
listFormCode,
|
||||
searchParams,
|
||||
params,
|
||||
cols,
|
||||
setWidgetGroups,
|
||||
)
|
||||
|
||||
setGridDataSource(dataSource)
|
||||
}, [gridDto, searchParams])
|
||||
}, [gridDto, searchParams, extraFilters])
|
||||
|
||||
useEffect(() => {
|
||||
refListFormCode.current = listFormCode
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export function GridExtraFilterToolbar({
|
|||
) : (
|
||||
<input
|
||||
type="text"
|
||||
className="border rounded px-1 py-0.5"
|
||||
className="border rounded px-1 py-1"
|
||||
value={inputValues[fs.fieldName] ?? current?.value ?? ''}
|
||||
placeholder={fs.caption}
|
||||
onChange={(e) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue