RolesPermission ve UsersPermission düzenlemesi

This commit is contained in:
Sedat Öztürk 2026-03-19 00:38:06 +03:00
parent ac7784c030
commit ac1ff56288
5 changed files with 104 additions and 75 deletions

View file

@ -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<LanguageKey> CreateLangKey(string key, string textEn, string textTr)

View file

@ -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,

View file

@ -313,8 +313,12 @@ const Wizard = () => {
}
const handleDeploy = async () => {
try {
if (!formikRef.current) throw new Error('Form bulunamadı')
const values = formikRef.current.values
// 🔴 Önce kayıt işlemi TAMAMLANSIN
await postListFormWizard({
...values,
groups: editingGroups.map((g) => ({
@ -322,6 +326,7 @@ const Wizard = () => {
colCount: g.colCount,
items: g.items.map((item) => {
const col = selectCommandColumns.find((c) => c.columnName === item.dataField)
return {
dataField: item.dataField,
editorType: item.editorType,
@ -329,25 +334,30 @@ const Wizard = () => {
editorScript: item.editorScript ?? '',
colSpan: item.colSpan,
isRequired: item.isRequired,
dbSourceType: col ? sqlDataTypeToDbType(col.dataType) : 12, // 12 = DbType.String
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(
<Notification type="success" duration={2000}>
{translate('::ListForms.FormBilgileriKaydedildi')}
</Notification>,
{ placement: 'top-end' },
)
setTimeout(async () => {
getConfig(true)
navigate(ROUTES_ENUM.protected.admin.list.replace(':listFormCode', values.listFormCode))
}, 6000)
} 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(
<Notification type="success" duration={2000}>
{translate('::ListForms.FormBilgileriKaydedildi')}
</Notification>,
{ 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(<Notification title={error.message} type="danger" />, {
placement: 'top-end',
})
} finally {
setSubmitting(false)
}
}}
>

View file

@ -58,7 +58,8 @@ function RolesPermission({
.map((group: any) => {
const filteredPermissions = group.permissions.filter((perm: any) => {
if (!perm.menuGroup) return false
const groups = typeof perm.menuGroup === 'string'
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 () => {
try {
setIsLoading(true)
setTimeout(async () => {
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) =>
const updatePermList = changedPermissions
.filter(
(per) =>
(unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {})
.isGranted === per.isGranted
? false
: true,
.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(<Notification title={'Permission updated'} type="success" />, {
placement: 'top-end',
})
}
onDialogClose()
} catch (err) {
console.error(err)
} finally {
setIsLoading(false)
}, 1000)
setTimeout(async () => {
getConfig(true)
}, 6000)
}
}
function getPermissionsWithGroupName(groups: PermissionGroupDto[]): PermissionWithGroupName[] {

View file

@ -76,35 +76,41 @@ function UsersPermission({
}
const onDialogOk = async () => {
try {
setIsLoading(true)
setTimeout(async () => {
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) =>
const updatePermList = changedPermissions
.filter(
(per) =>
(unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {})
.isGranted === per.isGranted
? false
: true,
.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(<Notification title={'Permission updated'} type="success" />, {
placement: 'top-end',
})
}
onDialogClose()
} catch (err) {
console.error(err)
} finally {
setIsLoading(false)
}, 1000)
setTimeout(async () => {
getConfig(true)
}, 6000)
}
}
function getPermissionsWithGroupName(groups: PermissionGroupDto[]): PermissionWithGroupName[] {