RolesPermission ve UsersPermission düzenlemesi
This commit is contained in:
parent
ac7784c030
commit
ac1ff56288
5 changed files with 104 additions and 75 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
<Notification type="success" duration={2000}>
|
||||
{translate('::ListForms.FormBilgileriKaydedildi')}
|
||||
</Notification>,
|
||||
{ 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(
|
||||
<Notification type="success" duration={2000}>
|
||||
{translate('::ListForms.FormBilgileriKaydedildi')}
|
||||
</Notification>,
|
||||
{ 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(
|
||||
<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)
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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(<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[] {
|
||||
|
|
|
|||
|
|
@ -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(<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[] {
|
||||
|
|
|
|||
Loading…
Reference in a new issue