2026-08-10 09:08:08 +00:00
|
|
|
|
import ScriptBuilderDialog from '@/components/scriptBuilder/ScriptBuilderDialog'
|
|
|
|
|
|
import { useMemo } from 'react'
|
2026-08-14 11:32:31 +00:00
|
|
|
|
import { useLocalization } from '@/utils/hooks/useLocalization'
|
2026-08-10 09:08:08 +00:00
|
|
|
|
import { createDesignerScriptDialect } from './designerScriptDialect'
|
|
|
|
|
|
import type { SqlDataSourceEvent } from './types'
|
|
|
|
|
|
|
|
|
|
|
|
export type DesignerScriptBuilderDialogProps = {
|
|
|
|
|
|
isOpen: boolean
|
|
|
|
|
|
value?: string
|
|
|
|
|
|
/** Düzenlenen event: başlıkta ve event yolu seçicilerinde kullanılır. */
|
|
|
|
|
|
eventName: string
|
|
|
|
|
|
eventInfo?: SqlDataSourceEvent
|
|
|
|
|
|
/** Event'in sahibi komponentin adı, yalnızca başlık için. */
|
|
|
|
|
|
componentLabel?: string
|
|
|
|
|
|
/** Kayıt tariflerinin yazacağı SqlDataSource ref adı. */
|
|
|
|
|
|
sqlRef: string
|
|
|
|
|
|
/** SqlDataSource Select sonucundaki sütun adları. */
|
|
|
|
|
|
recordFields: string[]
|
|
|
|
|
|
/** Sayfadaki tüm ref adları. */
|
|
|
|
|
|
refNames: string[]
|
|
|
|
|
|
onClose: () => void
|
|
|
|
|
|
onApply: (value: string) => void
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Designer event'lerinin script editörü. Ortak Script Builder'ı designer
|
|
|
|
|
|
* lehçesiyle kurar; dialog'un kendisi paylaşılan bileşendir.
|
|
|
|
|
|
*/
|
|
|
|
|
|
function DesignerScriptBuilderDialog({
|
|
|
|
|
|
isOpen,
|
|
|
|
|
|
value,
|
|
|
|
|
|
eventName,
|
|
|
|
|
|
eventInfo,
|
|
|
|
|
|
componentLabel,
|
|
|
|
|
|
sqlRef,
|
|
|
|
|
|
recordFields,
|
|
|
|
|
|
refNames,
|
|
|
|
|
|
onClose,
|
|
|
|
|
|
onApply,
|
|
|
|
|
|
}: DesignerScriptBuilderDialogProps) {
|
2026-08-14 11:32:31 +00:00
|
|
|
|
const { translate } = useLocalization()
|
|
|
|
|
|
|
2026-08-10 09:08:08 +00:00
|
|
|
|
// Çağıran her render'da yeni diziler üretiyor; lehçe içeriklerine göre
|
|
|
|
|
|
// sabitlenmezse editör yazarken sıfırlanırdı.
|
|
|
|
|
|
const recordFieldKey = recordFields.join('|')
|
|
|
|
|
|
const refNameKey = refNames.join('|')
|
|
|
|
|
|
const dialect = useMemo(
|
|
|
|
|
|
() =>
|
|
|
|
|
|
createDesignerScriptDialect({
|
|
|
|
|
|
componentLabel,
|
|
|
|
|
|
eventInfo,
|
|
|
|
|
|
eventName,
|
|
|
|
|
|
recordFields: recordFieldKey ? recordFieldKey.split('|') : [],
|
|
|
|
|
|
refNames: refNameKey ? refNameKey.split('|') : [],
|
|
|
|
|
|
sqlRef,
|
2026-08-14 11:32:31 +00:00
|
|
|
|
translate,
|
2026-08-10 09:08:08 +00:00
|
|
|
|
}),
|
2026-08-14 11:32:31 +00:00
|
|
|
|
[componentLabel, eventInfo, eventName, recordFieldKey, refNameKey, sqlRef, translate],
|
2026-08-10 09:08:08 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<ScriptBuilderDialog
|
|
|
|
|
|
dialect={dialect}
|
|
|
|
|
|
isOpen={isOpen}
|
|
|
|
|
|
value={value}
|
|
|
|
|
|
onApply={onApply}
|
|
|
|
|
|
onClose={onClose}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default DesignerScriptBuilderDialog
|