From ac1ff56288c55da237b2d300270cdff0ad8024a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Thu, 19 Mar 2026 00:38:06 +0300 Subject: [PATCH] =?UTF-8?q?RolesPermission=20ve=20UsersPermission=20d?= =?UTF-8?q?=C3=BCzenlemesi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ListForms/ListFormWizardAppService.cs | 7 +- ui/src/store/abpConfig.model.ts | 2 +- ui/src/views/admin/listForm/Wizard.tsx | 95 +++++++++++-------- .../admin/role-management/RolesPermission.tsx | 41 ++++---- .../admin/user-management/UsersPermission.tsx | 34 ++++--- 5 files changed, 104 insertions(+), 75 deletions(-) diff --git a/api/src/Sozsoft.Platform.Application/ListForms/ListFormWizardAppService.cs b/api/src/Sozsoft.Platform.Application/ListForms/ListFormWizardAppService.cs index f6c0be9..8e4412f 100644 --- a/api/src/Sozsoft.Platform.Application/ListForms/ListFormWizardAppService.cs +++ b/api/src/Sozsoft.Platform.Application/ListForms/ListFormWizardAppService.cs @@ -61,9 +61,6 @@ public class ListFormWizardAppService( var descLangKey = WizardConsts.WizardKeyDesc(wizardName); var code = WizardConsts.WizardKey(wizardName); - // Clear Redis Cache - await _languageTextAppService.ClearRedisCacheAsync(); - //Dil - Language Keys await CreateLangKey(nameLangKey, input.LanguageTextMenuEn, input.LanguageTextMenuTr); await CreateLangKey(titleLangKey, input.LanguageTextTitleEn, input.LanguageTextTitleTr); @@ -256,6 +253,10 @@ public class ListFormWizardAppService( await CreateLangKey(captionName, item.EnglishCaption, item.TurkishCaption); } } + + // Clear Redis Cache + await _languageTextAppService.ClearRedisCacheAsync(); + } private async Task CreateLangKey(string key, string textEn, string textTr) diff --git a/ui/src/store/abpConfig.model.ts b/ui/src/store/abpConfig.model.ts index 57d19d0..7fe0502 100644 --- a/ui/src/store/abpConfig.model.ts +++ b/ui/src/store/abpConfig.model.ts @@ -41,7 +41,7 @@ export const abpConfigModel: AbpConfigModel = { const currentCulture = helpers.getState().config?.localization.currentCulture.cultureName const isCultureDifferent = newCulture && currentCulture !== newCulture const isTextsEmpty = !helpers.getState().texts - if (isCultureDifferent || isTextsEmpty) { + if (payload || isCultureDifferent || isTextsEmpty) { await actions.getTexts({ cultureName: newCulture ?? currentCulture ?? appConfig.locale, onlyDynamics: false, diff --git a/ui/src/views/admin/listForm/Wizard.tsx b/ui/src/views/admin/listForm/Wizard.tsx index d4c6921..5dce2b7 100644 --- a/ui/src/views/admin/listForm/Wizard.tsx +++ b/ui/src/views/admin/listForm/Wizard.tsx @@ -313,41 +313,51 @@ const Wizard = () => { } const handleDeploy = async () => { - if (!formikRef.current) throw new Error('Form bulunamadı') - const values = formikRef.current.values - await postListFormWizard({ - ...values, - groups: editingGroups.map((g) => ({ - caption: g.caption, - colCount: g.colCount, - items: g.items.map((item) => { - const col = selectCommandColumns.find((c) => c.columnName === item.dataField) - return { - dataField: item.dataField, - editorType: item.editorType, - editorOptions: item.editorOptions ?? '', - editorScript: item.editorScript ?? '', - colSpan: item.colSpan, - isRequired: item.isRequired, - dbSourceType: col ? sqlDataTypeToDbType(col.dataType) : 12, // 12 = DbType.String - turkishCaption: item.turkishCaption, - englishCaption: item.englishCaption, - } - }), - })), - }) - toast.push( - - {translate('::ListForms.FormBilgileriKaydedildi')} - , - { placement: 'top-end' }, - ) - setTimeout(async () => { - getConfig(true) + try { + if (!formikRef.current) throw new Error('Form bulunamadı') - navigate(ROUTES_ENUM.protected.admin.list.replace(':listFormCode', values.listFormCode)) - }, 6000) + const values = formikRef.current.values + // 🔴 Önce kayıt işlemi TAMAMLANSIN + await postListFormWizard({ + ...values, + groups: editingGroups.map((g) => ({ + caption: g.caption, + colCount: g.colCount, + items: g.items.map((item) => { + const col = selectCommandColumns.find((c) => c.columnName === item.dataField) + + return { + dataField: item.dataField, + editorType: item.editorType, + editorOptions: item.editorOptions ?? '', + editorScript: item.editorScript ?? '', + colSpan: item.colSpan, + isRequired: item.isRequired, + dbSourceType: col ? sqlDataTypeToDbType(col.dataType) : 12, + turkishCaption: item.turkishCaption, + englishCaption: item.englishCaption, + } + }), + })), + }) + + // ✅ sonra config çek + await getConfig(true) + + // ✅ sonra navigate + navigate(ROUTES_ENUM.protected.admin.list.replace(':listFormCode', values.listFormCode), { replace: true }) + + // ✅ en son kullanıcıya mesaj + toast.push( + + {translate('::ListForms.FormBilgileriKaydedildi')} + , + { placement: 'top-end' }, + ) + } catch (err) { + console.error(err) + } } return ( @@ -377,25 +387,30 @@ const Wizard = () => { 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( {translate('::ListForms.FormBilgileriKaydedildi')} , { placement: 'top-end' }, ) - setSubmitting(false) - setTimeout(async () => { - getConfig(true) - - navigate(ROUTES_ENUM.protected.admin.list.replace(':listFormCode', values.listFormCode)) - }, 6000) - } catch (error: any) { toast.push(, { placement: 'top-end', }) + } finally { + setSubmitting(false) } }} > diff --git a/ui/src/views/admin/role-management/RolesPermission.tsx b/ui/src/views/admin/role-management/RolesPermission.tsx index 2206c9a..a632ca2 100644 --- a/ui/src/views/admin/role-management/RolesPermission.tsx +++ b/ui/src/views/admin/role-management/RolesPermission.tsx @@ -58,9 +58,10 @@ function RolesPermission({ .map((group: any) => { const filteredPermissions = group.permissions.filter((perm: any) => { if (!perm.menuGroup) return false - const groups = typeof perm.menuGroup === 'string' - ? perm.menuGroup.split('|').map((g: string) => g.trim()) - : perm.menuGroup + const groups = + typeof perm.menuGroup === 'string' + ? perm.menuGroup.split('|').map((g: string) => g.trim()) + : perm.menuGroup return groups.includes(tenantGroup) }) @@ -97,35 +98,41 @@ function RolesPermission({ } const onDialogOk = async () => { - setIsLoading(true) - setTimeout(async () => { + try { + setIsLoading(true) + if (permissionList?.groups && name) { const listPermissions = await getPermissions(providerName, name) const unChangedPermissions = getPermissionsWithGroupName(listPermissions.data?.groups) const changedPermissions = getPermissionsWithGroupName(permissionList.groups) - const updatePermList: UpdatePermissionDto[] = changedPermissions - .filter((per) => - (unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {}) - .isGranted === per.isGranted - ? false - : true, + const updatePermList = changedPermissions + .filter( + (per) => + (unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {}) + .isGranted !== per.isGranted, ) .map(({ name, isGranted }) => ({ name, isGranted })) - updatePermissions(providerName, name, { permissions: updatePermList }) + // 🔴 KRİTİK NOKTA + await updatePermissions(providerName, name, { + permissions: updatePermList, + }) + + // ✅ artık backend kesin güncel + await getConfig(false) + toast.push(, { placement: 'top-end', }) } onDialogClose() + } catch (err) { + console.error(err) + } finally { setIsLoading(false) - }, 1000) - - setTimeout(async () => { - getConfig(true) - }, 6000) + } } function getPermissionsWithGroupName(groups: PermissionGroupDto[]): PermissionWithGroupName[] { diff --git a/ui/src/views/admin/user-management/UsersPermission.tsx b/ui/src/views/admin/user-management/UsersPermission.tsx index a4932a8..638d85b 100644 --- a/ui/src/views/admin/user-management/UsersPermission.tsx +++ b/ui/src/views/admin/user-management/UsersPermission.tsx @@ -76,35 +76,41 @@ function UsersPermission({ } const onDialogOk = async () => { - setIsLoading(true) - setTimeout(async () => { + try { + setIsLoading(true) + if (permissionList?.groups && id) { const listPermissions = await getPermissions(providerName, id) const unChangedPermissions = getPermissionsWithGroupName(listPermissions.data?.groups) const changedPermissions = getPermissionsWithGroupName(permissionList.groups) - const updatePermList: UpdatePermissionDto[] = changedPermissions - .filter((per) => - (unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {}) - .isGranted === per.isGranted - ? false - : true, + const updatePermList = changedPermissions + .filter( + (per) => + (unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {}) + .isGranted !== per.isGranted, ) .map(({ name, isGranted }) => ({ name, isGranted })) - updatePermissions(providerName, id, { permissions: updatePermList }) + // 🔴 EN KRİTİK SATIR + await updatePermissions(providerName, id, { + permissions: updatePermList, + }) + + // ✅ permission kaydı bittikten sonra config çek + await getConfig(false) + toast.push(, { placement: 'top-end', }) } onDialogClose() + } catch (err) { + console.error(err) + } finally { setIsLoading(false) - }, 1000) - - setTimeout(async () => { - getConfig(true) - }, 6000) + } } function getPermissionsWithGroupName(groups: PermissionGroupDto[]): PermissionWithGroupName[] {