From aea724a8874575b57fee338c5461399227b139c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Fri, 19 Jun 2026 12:18:43 +0300 Subject: [PATCH] =?UTF-8?q?Chart=20komponenti=20Fields=20d=C3=BCzenlemesi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/views/list/Chart.tsx | 62 ++++++++++++++----------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/ui/src/views/list/Chart.tsx b/ui/src/views/list/Chart.tsx index ceecce1..4881bd1 100644 --- a/ui/src/views/list/Chart.tsx +++ b/ui/src/views/list/Chart.tsx @@ -9,7 +9,6 @@ import { Helmet } from 'react-helmet' import { useParams, useSearchParams } from 'react-router-dom' import { GridDto } from '@/proxy/form/models' import { usePermission } from '@/utils/hooks/usePermission' -import { toast, Notification } from '@/components/ui' import { ROUTES_ENUM } from '@/routes/route.constant' import { usePWA } from '@/utils/hooks/usePWA' import { FaSearch } from 'react-icons/fa' @@ -18,8 +17,6 @@ import { ChartSeriesDto } from '@/proxy/admin/charts/models' import { SelectBoxOption } from '@/types/shared' import { useStoreState } from '@/store/store' import ChartDrawer from './ChartDrawer' -import { getListFormFields } from '@/services/admin/list-form-field.service' -import { groupBy } from 'lodash' import { ListFormJsonRowDto } from '@/proxy/admin/list-form/models' import { ListFormEditTabs } from '@/proxy/admin/list-form/options' import { @@ -54,13 +51,34 @@ const Chart = (props: ChartProps) => { const [searchParams] = useSearchParams() const [chartOptions, setChartOptions] = useState() const { createSelectDataSource } = useListFormCustomDataSource({} as any) - const config = useStoreState((state) => state.abpConfig.config) const params = useParams() const _listFormCode = props?.listFormCode ?? params?.listFormCode ?? '' const [openDrawer, setOpenDrawer] = useState(false) - const [fieldList, setFieldList] = useState([]) + + const fieldList = useMemo(() => { + if (!gridDto?.columnFormats) { + return [] + } + + const fields = new Map() + + gridDto.columnFormats.forEach((column) => { + const fieldName = column.fieldName + + if (!fieldName || fields.has(fieldName)) { + return + } + + fields.set(fieldName, { + value: fieldName, + label: column.captionName ? translate('::' + column.captionName) : fieldName, + }) + }) + + return Array.from(fields.values()) + }, [gridDto?.columnFormats, translate]) // Ana state - Chart bu state'e göre render edilir const [currentSeries, setCurrentSeries] = useState([]) @@ -230,40 +248,6 @@ const Chart = (props: ChartProps) => { [gridDto, urlSearchParams, searchText], ) - const getFields = useCallback(async () => { - if (!props.listFormCode) return - try { - const resp = await getListFormFields({ - listFormCode: props.listFormCode, - sorting: 'ListOrderNo', - maxResultCount: 1000, - }) - if (resp.data?.items) { - const fieldNames = groupBy(resp?.data?.items, 'fieldName') - setFieldList( - Object.keys(fieldNames).map((fieldName) => { - const firstItem = fieldNames[fieldName][0] - const label = firstItem.captionName - ? translate('::' + firstItem.captionName) - : fieldName - return { value: fieldName, label } - }), - ) - } - } catch (error: any) { - toast.push( - - Alanlar getirilemedi {error.toString()} - , - { placement: 'top-end' }, - ) - } - }, [props.listFormCode, translate]) - - useEffect(() => { - if (props.listFormCode) getFields() - }, [props.listFormCode, config]) - const handlePreviewChange = useCallback((series: ChartSeriesDto[]) => { // Preview değişikliklerini anında chart'a yansıt setCurrentSeries(series)