Wizard üzerindeki problemler giderildi.
This commit is contained in:
parent
975bc8dd6c
commit
ebab6ea114
10 changed files with 121 additions and 63 deletions
|
|
@ -674,7 +674,7 @@
|
|||
"code": "Abp.Account.EnableLocalLogin",
|
||||
"nameKey": "Abp.Account.EnableLocalLogin",
|
||||
"descriptionKey": "Abp.Account.EnableLocalLogin.Description",
|
||||
"defaultValue": "False",
|
||||
"defaultValue": "True",
|
||||
"isVisibleToClients": false,
|
||||
"providers": "G|D",
|
||||
"isInherited": false,
|
||||
|
|
|
|||
|
|
@ -773,10 +773,10 @@ public static class PlatformConsts
|
|||
{
|
||||
public static class ParameterTypes
|
||||
{
|
||||
public const string Static = "S";
|
||||
public const string Query = "Q";
|
||||
public const string Path = "P";
|
||||
public const string Body = "B";
|
||||
public const string Static = "Static";
|
||||
public const string Query = "Query";
|
||||
public const string Path = "Path";
|
||||
public const string Body = "Body";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -324,16 +324,16 @@
|
|||
"Url": "/dil/",
|
||||
"Method": "GET",
|
||||
"DataSourceCode": "Default",
|
||||
"Sql": "SELECT * FROM Plat_H_Language WHERE IsEnabled = @IsEnabled AND CultureName = @CultureName",
|
||||
"Sql": "SELECT * FROM Sas_H_Language WHERE IsEnabled = @IsEnabled AND CultureName = @CultureName",
|
||||
"ParametersJson": [
|
||||
{
|
||||
"Type": "P",
|
||||
"Type": "Path",
|
||||
"Name": "CultureName",
|
||||
"DefaultValue": "ar",
|
||||
"Path": "/dil/:CultureName/"
|
||||
},
|
||||
{
|
||||
"Type": "S",
|
||||
"Type": "Static",
|
||||
"Name": "IsEnabled",
|
||||
"DefaultValue": "true"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { ROUTES_ENUM } from '@/routes/route.constant'
|
|||
import { SelectBoxOption } from '@/types/shared'
|
||||
import { useLocalization } from '@/utils/hooks/useLocalization'
|
||||
import { Form, Formik, FormikProps } from 'formik'
|
||||
import type { KeyboardEvent } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Helmet } from 'react-helmet'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
|
|
@ -516,24 +517,38 @@ const Wizard = () => {
|
|||
.trim()
|
||||
|
||||
const handleWizardNameChange = (name: string) => {
|
||||
const formik = formikRef.current
|
||||
const spacedLabel = toSpacedLabel(name)
|
||||
const previousSpacedLabel = toSpacedLabel(formik?.values.wizardName ?? '')
|
||||
const derived = deriveListFormCode(name)
|
||||
|
||||
formikRef.current?.setFieldValue('wizardName', name)
|
||||
formikRef.current?.setFieldValue('listFormCode', derived)
|
||||
formikRef.current?.setFieldValue('menuCode', derived)
|
||||
formikRef.current?.setFieldValue('languageTextMenuEn', spacedLabel)
|
||||
formikRef.current?.setFieldValue('languageTextMenuTr', spacedLabel)
|
||||
formikRef.current?.setFieldValue('languageTextTitleEn', spacedLabel)
|
||||
formikRef.current?.setFieldValue('languageTextTitleTr', spacedLabel)
|
||||
formikRef.current?.setFieldValue('languageTextDescEn', spacedLabel)
|
||||
formikRef.current?.setFieldValue('languageTextDescTr', spacedLabel)
|
||||
const setAutoText = (field: keyof Pick<
|
||||
ListFormWizardDto,
|
||||
| 'languageTextMenuEn'
|
||||
| 'languageTextMenuTr'
|
||||
| 'languageTextTitleEn'
|
||||
| 'languageTextTitleTr'
|
||||
| 'languageTextDescEn'
|
||||
| 'languageTextDescTr'
|
||||
>) => {
|
||||
const current = formik?.values[field]
|
||||
if (!current || current === previousSpacedLabel) {
|
||||
formik?.setFieldValue(field, spacedLabel)
|
||||
}
|
||||
}
|
||||
|
||||
formik?.setFieldValue('wizardName', name)
|
||||
formik?.setFieldValue('listFormCode', derived)
|
||||
formik?.setFieldValue('menuCode', derived)
|
||||
setAutoText('languageTextMenuEn')
|
||||
setAutoText('languageTextMenuTr')
|
||||
setAutoText('languageTextTitleEn')
|
||||
setAutoText('languageTextTitleTr')
|
||||
setAutoText('languageTextDescEn')
|
||||
setAutoText('languageTextDescTr')
|
||||
}
|
||||
|
||||
const handleMenuParentChange = (code: string) => {
|
||||
formikRef.current?.setFieldValue('menuParentCode', code)
|
||||
if (!code) return
|
||||
const rootCode = findRootCode(rawMenuItems, code)
|
||||
const applyPermissionGroupFromRoot = (rootCode: string) => {
|
||||
const rootItem = rawMenuItems.find((i) => i.code === rootCode)
|
||||
|
||||
// 1. Use group field if set
|
||||
|
|
@ -565,6 +580,28 @@ const Wizard = () => {
|
|||
formikRef.current?.setFieldValue('permissionGroupName', rootCode)
|
||||
}
|
||||
|
||||
const handleMenuParentChange = (code: string) => {
|
||||
formikRef.current?.setFieldValue('menuParentCode', code)
|
||||
if (!code) return
|
||||
applyPermissionGroupFromRoot(findRootCode(rawMenuItems, code))
|
||||
}
|
||||
|
||||
const handleMenuCreated = async (menu: {
|
||||
code: string
|
||||
parentCode?: string
|
||||
menuTextEn: string
|
||||
menuTextTr: string
|
||||
}) => {
|
||||
formikRef.current?.setFieldValue('menuParentCode', menu.code)
|
||||
formikRef.current?.setFieldValue('languageTextMenuParentEn', menu.menuTextEn)
|
||||
formikRef.current?.setFieldValue('languageTextMenuParentTr', menu.menuTextTr)
|
||||
|
||||
const rootCode = menu.parentCode ? findRootCode(rawMenuItems, menu.parentCode) : menu.code
|
||||
applyPermissionGroupFromRoot(rootCode)
|
||||
|
||||
await getMenuList()
|
||||
}
|
||||
|
||||
const handleNext = async () => {
|
||||
if (!formikRef.current) return
|
||||
const errors = await formikRef.current.validateForm()
|
||||
|
|
@ -586,6 +623,19 @@ const Wizard = () => {
|
|||
const handleBack = () => setCurrentStep(0)
|
||||
const { getConfig } = useStoreActions((a) => a.abpConfig)
|
||||
|
||||
const preventEnterSubmit = (event: KeyboardEvent<HTMLFormElement>) => {
|
||||
if (event.key !== 'Enter') return
|
||||
|
||||
const target = event.target as HTMLElement
|
||||
const tagName = target.tagName.toLowerCase()
|
||||
const isTextArea = tagName === 'textarea'
|
||||
const isExplicitSubmit = target.getAttribute('type') === 'submit'
|
||||
|
||||
if (!isTextArea && !isExplicitSubmit) {
|
||||
event.preventDefault()
|
||||
}
|
||||
}
|
||||
|
||||
const handleNext2 = async () => {
|
||||
if (!formikRef.current) return
|
||||
const errors = await formikRef.current.validateForm()
|
||||
|
|
@ -704,40 +754,12 @@ const Wizard = () => {
|
|||
innerRef={formikRef}
|
||||
initialValues={{ ...initialValues }}
|
||||
validationSchema={listFormValidationSchema}
|
||||
onSubmit={async (values, { setSubmitting }) => {
|
||||
setSubmitting(true)
|
||||
|
||||
try {
|
||||
// 🔴 1. Kaydet (bekle)
|
||||
await postListFormWizard({ ...values })
|
||||
|
||||
// 🔴 2. Config güncelle (bekle)
|
||||
await getConfig(true)
|
||||
|
||||
// 🔴 3. Navigate
|
||||
navigate(
|
||||
ROUTES_ENUM.protected.admin.list.replace(':listFormCode', values.listFormCode),
|
||||
{ replace: true },
|
||||
)
|
||||
|
||||
// 🔴 4. Toast (istersen navigate öncesi de olabilir)
|
||||
toast.push(
|
||||
<Notification type="success" duration={2000}>
|
||||
{translate('::ListForms.FormBilgileriKaydedildi')}
|
||||
</Notification>,
|
||||
{ placement: 'top-end' },
|
||||
)
|
||||
} catch (error: any) {
|
||||
toast.push(<Notification title={error.message} type="danger" />, {
|
||||
placement: 'top-end',
|
||||
})
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
onSubmit={(_, { setSubmitting }) => {
|
||||
setSubmitting(false)
|
||||
}}
|
||||
>
|
||||
{({ touched, errors, isSubmitting, values }) => (
|
||||
<Form>
|
||||
<Form onKeyDown={preventEnterSubmit}>
|
||||
<FormContainer size={currentStep >= 2 ? undefined : 'sm'}>
|
||||
{/* ─── Step 1: Basic Info ─────────────────────────────── */}
|
||||
{currentStep === 0 && (
|
||||
|
|
@ -752,6 +774,7 @@ const Wizard = () => {
|
|||
isLoadingMenu={isLoadingMenu}
|
||||
onMenuParentChange={handleMenuParentChange}
|
||||
onClearMenuParent={() => formikRef.current?.setFieldValue('menuParentCode', '')}
|
||||
onMenuCreated={handleMenuCreated}
|
||||
onReloadMenu={getMenuList}
|
||||
permissionGroupList={permissionGroupList}
|
||||
isLoadingPermissionGroup={isLoadingPermissionGroup}
|
||||
|
|
|
|||
|
|
@ -414,6 +414,14 @@ export interface WizardStep1Props {
|
|||
isLoadingMenu: boolean
|
||||
onMenuParentChange: (code: string) => void
|
||||
onClearMenuParent: () => void
|
||||
onMenuCreated: (menu: {
|
||||
code: string
|
||||
parentCode?: string
|
||||
menuTextEn: string
|
||||
menuTextTr: string
|
||||
icon?: string
|
||||
shortName?: string
|
||||
}) => void | Promise<void>
|
||||
onReloadMenu: () => void
|
||||
permissionGroupList: SelectBoxOption[]
|
||||
isLoadingPermissionGroup: boolean
|
||||
|
|
@ -432,6 +440,7 @@ const WizardStep1 = ({
|
|||
isLoadingMenu,
|
||||
onMenuParentChange,
|
||||
onClearMenuParent,
|
||||
onMenuCreated,
|
||||
onReloadMenu,
|
||||
permissionGroupList,
|
||||
isLoadingPermissionGroup,
|
||||
|
|
@ -544,7 +553,7 @@ const WizardStep1 = ({
|
|||
initialParentCode={menuDialogParentCode}
|
||||
initialOrder={menuDialogInitialOrder}
|
||||
rawItems={rawMenuItems}
|
||||
onSaved={onReloadMenu}
|
||||
onSaved={onMenuCreated}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -719,6 +719,7 @@ const WizardStep2 = ({
|
|||
<div className="flex items-center gap-2 ml-3">
|
||||
<Button
|
||||
variant="solid"
|
||||
type="button"
|
||||
onClick={() => onToggleAllColumns(true)}
|
||||
className="text-xs px-2 py-0.5 rounded bg-indigo-500 text-white hover:bg-indigo-600"
|
||||
>
|
||||
|
|
@ -726,6 +727,7 @@ const WizardStep2 = ({
|
|||
</Button>
|
||||
<Button
|
||||
variant="default"
|
||||
type="button"
|
||||
onClick={() => onToggleAllColumns(false)}
|
||||
className="text-xs px-2 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 hover:text-red-500 hover:border-red-400"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -462,10 +462,10 @@ function WizardStep4({
|
|||
<p>Silmek istediğinize emin misiniz?</p>
|
||||
</Dialog.Body>
|
||||
<Dialog.Footer className="flex justify-end gap-2">
|
||||
<Button variant="plain" onClick={() => setDeleteIndex(null)}>
|
||||
<Button type="button" variant="plain" onClick={() => setDeleteIndex(null)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button variant="solid" onClick={removeSubForm}>
|
||||
<Button type="button" variant="solid" onClick={removeSubForm}>
|
||||
Delete
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
|
|
|
|||
|
|
@ -340,10 +340,10 @@ function WizardStep5({ widgets, translate, onChange, onBack, onNext }: Props) {
|
|||
<p>Silmek istediğinize emin misiniz?</p>
|
||||
</Dialog.Body>
|
||||
<Dialog.Footer className="flex justify-end gap-2">
|
||||
<Button variant="plain" onClick={() => setDeleteIndex(null)}>
|
||||
<Button type="button" variant="plain" onClick={() => setDeleteIndex(null)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button variant="solid" onClick={removeWidget}>
|
||||
<Button type="button" variant="solid" onClick={removeWidget}>
|
||||
Delete
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
|
|
|
|||
|
|
@ -1943,7 +1943,14 @@ const SqlTableDesignerDialog = ({
|
|||
initialParentCode={selectedMenuCode}
|
||||
initialOrder={999}
|
||||
rawItems={rawMenuItems}
|
||||
onSaved={() => reloadMenus()}
|
||||
onSaved={(menu) =>
|
||||
reloadMenus((items) => {
|
||||
const savedMenu = items.find((item) => item.code === menu.code)
|
||||
if (savedMenu?.code && savedMenu.shortName) {
|
||||
onMenuCodeSelect(savedMenu.code)
|
||||
}
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,14 @@ export interface MenuAddDialogProps {
|
|||
initialParentCode: string
|
||||
initialOrder: number
|
||||
rawItems: (MenuItem & { id?: string })[]
|
||||
onSaved: () => void
|
||||
onSaved: (menu: {
|
||||
code: string
|
||||
parentCode?: string
|
||||
menuTextEn: string
|
||||
menuTextTr: string
|
||||
icon?: string
|
||||
shortName?: string
|
||||
}) => void | Promise<void>
|
||||
}
|
||||
|
||||
export function MenuAddDialog({
|
||||
|
|
@ -172,7 +179,7 @@ export function MenuAddDialog({
|
|||
if (shortNameRequired && !form.shortName.trim()) return
|
||||
setSaving(true)
|
||||
try {
|
||||
await menuService.createWithLanguageKeyText({
|
||||
const savedMenu = {
|
||||
code: form.code.trim(),
|
||||
displayName: form.code.trim(),
|
||||
parentCode: form.parentCode.trim() || undefined,
|
||||
|
|
@ -182,9 +189,18 @@ export function MenuAddDialog({
|
|||
isDisabled: false,
|
||||
menuTextTr: form.menuTextTr.trim(),
|
||||
menuTextEn: form.menuTextEn.trim(),
|
||||
} as MenuDto)
|
||||
} as MenuDto
|
||||
|
||||
onSaved()
|
||||
await menuService.createWithLanguageKeyText(savedMenu)
|
||||
|
||||
await onSaved({
|
||||
code: savedMenu.code!,
|
||||
parentCode: savedMenu.parentCode,
|
||||
menuTextEn: savedMenu.menuTextEn!,
|
||||
menuTextTr: savedMenu.menuTextTr!,
|
||||
icon: savedMenu.icon,
|
||||
shortName: savedMenu.shortName,
|
||||
})
|
||||
onClose()
|
||||
} catch (e: any) {
|
||||
toast.push(<Notification title={e.message} type="danger" />, { placement: 'top-end' })
|
||||
|
|
@ -342,10 +358,11 @@ export function MenuAddDialog({
|
|||
|
||||
{/* Footer */}
|
||||
<div className="flex justify-end gap-2 pt-1 border-t border-gray-100 dark:border-gray-700">
|
||||
<Button size="sm" variant="plain" onClick={onClose}>
|
||||
<Button type="button" size="sm" variant="plain" onClick={onClose}>
|
||||
{translate('::Cancel') || 'İptal'}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="solid"
|
||||
loading={saving}
|
||||
|
|
|
|||
Loading…
Reference in a new issue