SubForm kısmını isRefresh yeteneği getirildi.
This commit is contained in:
parent
8c0863b11c
commit
abb85cf097
11 changed files with 36 additions and 318 deletions
|
|
@ -5,6 +5,7 @@ public class SubFormDto
|
|||
public string TabTitle { get; set; }
|
||||
public string TabType { get; set; }
|
||||
public string Code { get; set; }
|
||||
public bool IsRefresh { get; set; }
|
||||
public SubFormRelationDto[] Relation { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6007,6 +6007,12 @@
|
|||
"en": "List Form Code",
|
||||
"tr": "List Form Code"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.ListFormEdit.SubFormsIsRefresh",
|
||||
"en": "Is Refresh",
|
||||
"tr": "Yenilensin mi?"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.ListFormEdit.SubFormsRelation",
|
||||
|
|
@ -12658,13 +12664,6 @@
|
|||
"routeType": "protected",
|
||||
"authority": []
|
||||
},
|
||||
{
|
||||
"key": "admin.pivot",
|
||||
"path": "/admin/pivot/:listFormCode",
|
||||
"componentPath": "@/views/list/ListPivot",
|
||||
"routeType": "protected",
|
||||
"authority": []
|
||||
},
|
||||
{
|
||||
"key": "admin.developerkit",
|
||||
"path": "/admin/developerkit",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ public class SubForm : ValueObject
|
|||
public string TabTitle { get; set; }
|
||||
public string TabType { get; set; }
|
||||
public string Code { get; set; }
|
||||
public bool IsRefresh { get; set; }
|
||||
public SubFormRelation[] Relation { get; set; }
|
||||
|
||||
protected override IEnumerable<object> GetAtomicValues()
|
||||
|
|
@ -15,6 +16,7 @@ public class SubForm : ValueObject
|
|||
yield return TabTitle;
|
||||
yield return TabType;
|
||||
yield return Code;
|
||||
yield return IsRefresh;
|
||||
yield return Relation;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ export interface ListFormJsonRowDto {
|
|||
itemSubForm?: SubFormDto
|
||||
itemWidget?: WidgetEditDto
|
||||
itemExtraFilter?: ExtraFilterEditDto
|
||||
|
||||
itemChartAnnotation?: ChartAnnotationDto
|
||||
itemChartPanes?: ChartPanesDto
|
||||
itemChartSeries?: ChartSeriesDto
|
||||
|
|
|
|||
|
|
@ -673,6 +673,7 @@ export interface SubFormDto {
|
|||
tabTitle: string
|
||||
tabType: SubFormTabTypeEnum
|
||||
code: string
|
||||
isRefresh: boolean
|
||||
relation: SubFormRelationDto[]
|
||||
|
||||
tabMode: RowMode
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ function FormTabSubForm() {
|
|||
<Th>{translate('::ListForms.ListFormEdit.SubFormsTabTitle')}</Th>
|
||||
<Th>{translate('::ListForms.ListFormEdit.SubFormsTabType')}</Th>
|
||||
<Th>{translate('::ListForms.ListFormEdit.SubFormsCode')}</Th>
|
||||
<Th>{translate('::ListForms.ListFormEdit.SubFormsIsRefresh')}</Th>
|
||||
<Th>{translate('::ListForms.ListFormEdit.SubFormsRelation')}</Th>
|
||||
</Tr>
|
||||
</THead>
|
||||
|
|
@ -105,6 +106,7 @@ function FormTabSubForm() {
|
|||
<Td>{row.tabTitle}</Td>
|
||||
<Td>{row.tabType}</Td>
|
||||
<Td>{row.code}</Td>
|
||||
<Td>{row.isRefresh ? 'Evet' : 'Hayır'}</Td>
|
||||
<Td>
|
||||
<ul className="list-disc">
|
||||
{row.relation?.map((i) => (
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
Dialog,
|
||||
FormContainer,
|
||||
FormItem,
|
||||
|
|
@ -15,7 +16,7 @@ import { useLocalization } from '@/utils/hooks/useLocalization'
|
|||
import { Field, FieldArray, FieldProps, Form, Formik } from 'formik'
|
||||
import { Dispatch, SetStateAction } from 'react'
|
||||
import { FaCalendarPlus, FaCalendarMinus } from 'react-icons/fa'
|
||||
import { object, string } from 'yup'
|
||||
import { boolean, object, string } from 'yup'
|
||||
import { tabTypeOptions } from '../options'
|
||||
import { JsonRowDialogData } from './types'
|
||||
import {
|
||||
|
|
@ -30,6 +31,7 @@ const schema = object().shape({
|
|||
tabTitle: string().required('Tab Title Required'),
|
||||
tabType: string().required('Tab Type Required'),
|
||||
code: string().required('Code Required'),
|
||||
isRefresh: boolean(),
|
||||
})
|
||||
|
||||
function JsonRowOpDialogSubForm({
|
||||
|
|
@ -82,6 +84,7 @@ function JsonRowOpDialogSubForm({
|
|||
tabTitle: '',
|
||||
tabType: 'List',
|
||||
code: '',
|
||||
isRefresh: false,
|
||||
relation: [],
|
||||
}
|
||||
}
|
||||
|
|
@ -174,6 +177,17 @@ function JsonRowOpDialogSubForm({
|
|||
/>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="isRefresh"
|
||||
invalid={errors.isRefresh && touched.isRefresh}
|
||||
errorMessage={errors.isRefresh}
|
||||
>
|
||||
<Field
|
||||
name="isRefresh"
|
||||
component={Checkbox}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
<FormItem label="Relations">
|
||||
<FieldArray
|
||||
name="relation"
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ import { GridDto, SubFormDto, SubFormTabTypeEnum } from '@/proxy/form/models'
|
|||
import FormEdit from './FormEdit'
|
||||
import FormNew from './FormNew'
|
||||
import FormView from './FormView'
|
||||
import { getList } from '@/services/form.service'
|
||||
|
||||
const SubForms = (props: {
|
||||
gridDto: GridDto
|
||||
formData: any
|
||||
level: number
|
||||
refreshData?: () => Promise<void>
|
||||
refreshGridDto?: () => Promise<void>
|
||||
}) => {
|
||||
const { gridDto, formData, level, refreshData } = props
|
||||
const { gridDto, formData, level, refreshData, refreshGridDto } = props
|
||||
const { hash } = useLocation()
|
||||
const [currentTab, setCurrentTab] = useState<string>()
|
||||
const [subForms, setSubForms] = useState<SubFormDto[]>()
|
||||
|
|
@ -103,7 +103,7 @@ const SubForms = (props: {
|
|||
searchParams={subForm.searchParams}
|
||||
isSubForm={true}
|
||||
level={level + 1}
|
||||
refreshData={refreshData}
|
||||
refreshData={subForm.isRefresh ? refreshData : undefined}
|
||||
/>
|
||||
)}
|
||||
{subForm.tabType == SubFormTabTypeEnum.Form &&
|
||||
|
|
@ -181,10 +181,13 @@ const SubForms = (props: {
|
|||
))}
|
||||
{subForm.tabType == SubFormTabTypeEnum.Chart && (
|
||||
<Chart
|
||||
id={gridDto?.gridOptions.id!}
|
||||
listFormCode={subForm.code}
|
||||
isSubForm={true}
|
||||
level={level + 1}
|
||||
refreshData={refreshData}
|
||||
refreshData={subForm.isRefresh ? refreshData : undefined}
|
||||
gridDto={gridDto}
|
||||
refreshGridDto={refreshGridDto}
|
||||
/>
|
||||
)}
|
||||
</TabContent>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ interface ChartProps extends CommonProps, Meta {
|
|||
level?: number
|
||||
refreshData?: () => Promise<void>
|
||||
gridDto?: GridDto
|
||||
refreshGridDto: () => Promise<void>
|
||||
refreshGridDto?: () => Promise<void>
|
||||
}
|
||||
|
||||
const Chart = (props: ChartProps) => {
|
||||
|
|
@ -291,7 +291,7 @@ const Chart = (props: ChartProps) => {
|
|||
className="text-sm"
|
||||
onClick={async () => {
|
||||
initialized.current = false
|
||||
await refreshGridDto()
|
||||
await refreshGridDto?.()
|
||||
}}
|
||||
title="Refresh Data"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,278 +0,0 @@
|
|||
import { Button, FormContainer, Input, Notification, Select, Dialog, toast } from '@/components/ui'
|
||||
import { Field, FieldArray, Form, Formik, FieldProps } from 'formik'
|
||||
import { FaMinus, FaPlus } from 'react-icons/fa'
|
||||
import { SelectBoxOption } from '@/shared/types'
|
||||
import {
|
||||
chartSeriesTypeOptions,
|
||||
columnSummaryTypeListOptions,
|
||||
} from '../admin/listForm/edit/options'
|
||||
import { ChartSeriesDto } from '@/proxy/admin/charts/models'
|
||||
import { useLocalization } from '@/utils/hooks/useLocalization'
|
||||
import { useStoreState } from '@/store/store'
|
||||
import { object, array, string } from 'yup'
|
||||
|
||||
interface ChartSeriesDialog1 {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
initialSeries: ChartSeriesDto[]
|
||||
fieldList: SelectBoxOption[]
|
||||
onSave: (series: ChartSeriesDto[]) => void
|
||||
}
|
||||
|
||||
const schema = object().shape({
|
||||
series: array().of(
|
||||
object().shape({
|
||||
name: string().required('Name Required'),
|
||||
argumentField: string().required('Argument Field Required'),
|
||||
valueField: string().required('Value Field Required'),
|
||||
summaryType: string().required('Summary Type Required'),
|
||||
}),
|
||||
),
|
||||
})
|
||||
|
||||
const ChartSeriesDialog1 = ({
|
||||
open,
|
||||
onClose,
|
||||
initialSeries,
|
||||
fieldList,
|
||||
onSave,
|
||||
}: ChartSeriesDialog1) => {
|
||||
const { translate } = useLocalization()
|
||||
|
||||
// State UserId güncellemesi için
|
||||
const { userName } = useStoreState((s) => s.auth.user)
|
||||
|
||||
const newSeriesValue = () => {
|
||||
return {
|
||||
index: -1,
|
||||
type: 'line',
|
||||
name: '',
|
||||
argumentField: '',
|
||||
valueField: '',
|
||||
summaryType: 'sum',
|
||||
axis: '',
|
||||
barOverlapGroup: '',
|
||||
barPadding: 0,
|
||||
barWidth: 0,
|
||||
color: '',
|
||||
cornerRadius: 0,
|
||||
dashStyle: 'solid',
|
||||
ignoreEmptyPoints: false,
|
||||
pane: '',
|
||||
rangeValue1Field: '',
|
||||
rangeValue2Field: '',
|
||||
selectionMode: 'none',
|
||||
showInLegend: true,
|
||||
visible: true,
|
||||
width: 2,
|
||||
label: {
|
||||
visible: true,
|
||||
backgroundColor: '#f05b41',
|
||||
customizeText: '',
|
||||
format: 'decimal',
|
||||
font: {
|
||||
color: '#FFFFFF',
|
||||
family: '"Segoe UI", "Helvetica Neue", "Trebuchet MS", Verdana, sans-serif',
|
||||
size: 12,
|
||||
weight: 400,
|
||||
},
|
||||
},
|
||||
userId: userName ?? '',
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog isOpen={open} onClose={onClose} width={1200}>
|
||||
<div className="flex flex-col bg-white p-4 h-[600px]">
|
||||
<Formik
|
||||
enableReinitialize
|
||||
initialValues={{
|
||||
series: initialSeries && initialSeries.length > 0 ? initialSeries : [newSeriesValue()],
|
||||
}}
|
||||
validationSchema={schema}
|
||||
onSubmit={(values, { setSubmitting }) => {
|
||||
try {
|
||||
onSave(values.series)
|
||||
toast.push(<Notification type="success">{'Chart güncellendi'}</Notification>, {
|
||||
placement: 'top-end',
|
||||
})
|
||||
onClose()
|
||||
} catch (error: any) {
|
||||
toast.push(
|
||||
<Notification type="danger">
|
||||
Hata
|
||||
<code>{error}</code>
|
||||
</Notification>,
|
||||
{ placement: 'top-end' },
|
||||
)
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{({ setFieldValue, values, isSubmitting }) => (
|
||||
<Form className="flex flex-col h-full">
|
||||
<FormContainer size="sm" className="flex flex-col h-full">
|
||||
{/* Header */}
|
||||
<div className="mb-2 pb-2 border-b flex items-center justify-between">
|
||||
<Button
|
||||
variant="default"
|
||||
shape="circle"
|
||||
type="button"
|
||||
size="xs"
|
||||
onClick={() => setFieldValue('series', [...values.series, newSeriesValue()])}
|
||||
>
|
||||
<div className="flex items-center gap-1">
|
||||
<FaPlus /> Seri Ekle
|
||||
</div>
|
||||
</Button>
|
||||
</div>
|
||||
{/* Kaydırılabilir içerik */}
|
||||
<div className="flex-1 overflow-y-auto p-1">
|
||||
<FieldArray name="series">
|
||||
{({ remove }) => (
|
||||
<div>
|
||||
<div className="grid grid-cols-12 gap-2 font-semibold text-xs py-2">
|
||||
<div className="text-center col-span-1">#</div>
|
||||
<div className="text-center col-span-2">Type</div>
|
||||
<div className="text-center col-span-2">Name</div>
|
||||
<div className="text-center col-span-2">Argument Field</div>
|
||||
<div className="text-center col-span-2">Value Field</div>
|
||||
<div className="text-center col-span-2">Summary Type</div>
|
||||
<div className="text-center col-span-1">#</div>
|
||||
</div>
|
||||
{values.series.map((_, index) => (
|
||||
<div key={index} className="border-b py-1">
|
||||
<div className="grid grid-cols-12 gap-1 items-center">
|
||||
<div className="text-center text-xs col-span-1">
|
||||
{values.series[index].index}
|
||||
</div>
|
||||
|
||||
<div className="text-xs col-span-2">
|
||||
<Field name={`series[${index}].type`}>
|
||||
{({ field, form }: FieldProps<SelectBoxOption>) => (
|
||||
<Select
|
||||
field={field}
|
||||
form={form}
|
||||
options={chartSeriesTypeOptions}
|
||||
isClearable
|
||||
value={chartSeriesTypeOptions.find(
|
||||
(option) => option.value === field.value,
|
||||
)}
|
||||
onChange={(option) =>
|
||||
form.setFieldValue(field.name, option?.value)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="text-xs col-span-2">
|
||||
<Field
|
||||
size="sm"
|
||||
name={`series[${index}].name`}
|
||||
type="text"
|
||||
component={Input}
|
||||
className="text-xs px-1 py-0 grid-cols-2"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="text-xs col-span-2">
|
||||
<Field type="text" name={`series[${index}].argumentField`}>
|
||||
{({ field, form }: FieldProps<SelectBoxOption>) => (
|
||||
<Select
|
||||
field={field}
|
||||
form={form}
|
||||
isClearable={true}
|
||||
options={fieldList}
|
||||
value={fieldList?.find(
|
||||
(option) => option.value === field.value,
|
||||
)}
|
||||
onChange={(option) =>
|
||||
form.setFieldValue(field.name, option?.value)
|
||||
}
|
||||
menuPlacement="auto"
|
||||
maxMenuHeight={150}
|
||||
/>
|
||||
)}
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="text-xs col-span-2">
|
||||
<Field type="text" name={`series[${index}].valueField`}>
|
||||
{({ field, form }: FieldProps<SelectBoxOption>) => (
|
||||
<Select
|
||||
field={field}
|
||||
form={form}
|
||||
isClearable={true}
|
||||
options={fieldList}
|
||||
value={fieldList?.find(
|
||||
(option) => option.value === field.value,
|
||||
)}
|
||||
onChange={(option) =>
|
||||
form.setFieldValue(field.name, option?.value)
|
||||
}
|
||||
menuPlacement="auto"
|
||||
maxMenuHeight={150}
|
||||
/>
|
||||
)}
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="text-xs col-span-2">
|
||||
<Field type="text" name={`series[${index}].summaryType`}>
|
||||
{({ field, form }: FieldProps<SelectBoxOption>) => (
|
||||
<Select
|
||||
field={field}
|
||||
form={form}
|
||||
isClearable={true}
|
||||
options={columnSummaryTypeListOptions}
|
||||
value={columnSummaryTypeListOptions.find(
|
||||
(option) => option.value === field.value,
|
||||
)}
|
||||
onChange={(option) =>
|
||||
form.setFieldValue(field.name, option?.value)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-center gap-1 col-span-1">
|
||||
<Button
|
||||
shape="circle"
|
||||
type="button"
|
||||
size="xs"
|
||||
icon={<FaMinus />}
|
||||
className="bg-slate-100 hover:bg-red-100"
|
||||
onClick={() => remove(index)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</FieldArray>
|
||||
</div>
|
||||
{/* Footer */}
|
||||
<div className="flex gap-2 mt-auto pt-2 border-t text-right justify-end">
|
||||
<Button
|
||||
variant="solid"
|
||||
loading={isSubmitting}
|
||||
type="submit"
|
||||
className="ml-auto px-4 py-1 text-sm rounded"
|
||||
>
|
||||
{isSubmitting ? translate('::SavingWithThreeDot') : translate('::Save')}
|
||||
</Button>
|
||||
</div>
|
||||
</FormContainer>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
export default ChartSeriesDialog1
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import { CommonProps } from '@/@types/common'
|
||||
import { Meta } from '@/@types/routes'
|
||||
import Container from '@/components/shared/Container'
|
||||
import { useParams, useSearchParams } from 'react-router-dom'
|
||||
import Pivot from './Pivot'
|
||||
|
||||
export interface FormProps extends CommonProps, Meta {
|
||||
listFormCode?: string
|
||||
}
|
||||
|
||||
const ListPivot = (props?: FormProps) => {
|
||||
const params = useParams()
|
||||
const _listFormCode = props?.listFormCode ?? params?.listFormCode ?? ''
|
||||
const [searchParams] = useSearchParams()
|
||||
|
||||
return _listFormCode ? (
|
||||
<Container>
|
||||
<Pivot listFormCode={_listFormCode} searchParams={searchParams} isSubForm={false}></Pivot>
|
||||
</Container>
|
||||
) : (
|
||||
<></>
|
||||
)
|
||||
}
|
||||
|
||||
export default ListPivot
|
||||
Loading…
Reference in a new issue