From c366b6499ce578c362c075dcd7b9a4d7042e8e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Sat, 31 Jan 2026 00:28:40 +0300 Subject: [PATCH] =?UTF-8?q?Grid=20performans=20=C3=A7al=C4=B1=C5=9Fmas?= =?UTF-8?q?=C4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ListForms/ListFormSelectAppService.cs | 87 +++++++++++++++++++ .../Seeds/ListFormSeeder_Hr.cs | 8 +- .../Seeds/MenusData.json | 2 +- ui/src/views/form/FormButtons.tsx | 43 ++++----- ui/src/views/list/Grid.tsx | 43 ++++----- ui/src/views/list/Tree.tsx | 44 +++++----- 6 files changed, 157 insertions(+), 70 deletions(-) diff --git a/api/src/Erp.Platform.Application/ListForms/ListFormSelectAppService.cs b/api/src/Erp.Platform.Application/ListForms/ListFormSelectAppService.cs index 4ff2ff2a..14abf1ed 100644 --- a/api/src/Erp.Platform.Application/ListForms/ListFormSelectAppService.cs +++ b/api/src/Erp.Platform.Application/ListForms/ListFormSelectAppService.cs @@ -394,5 +394,92 @@ public class ListFormSelectAppService : PlatformAppService, IListFormSelectAppSe return new List(); } + + private static string WrapLookupQueryWithInFilter( + string lookupQuery, + string listFormSelectCommand, + string listFormFieldName) + { + if (string.IsNullOrWhiteSpace(lookupQuery)) + throw new ArgumentException("LookupQuery boş olamaz."); + + if (string.IsNullOrWhiteSpace(listFormSelectCommand)) + throw new ArgumentException("SelectCommand boş olamaz."); + + if (string.IsNullOrWhiteSpace(listFormFieldName)) + throw new ArgumentException("ListFormFieldName boş olamaz."); + + return $@" + SELECT * + FROM ( + {lookupQuery} + ) t + WHERE ""Key"" IN ( + SELECT ""{listFormFieldName}"" + FROM ""{listFormSelectCommand}"" + GROUP BY ""{listFormFieldName}"" + )"; + } + + private static string AddCascadeWhereCondition( + string sql, + string cascadeParentFields, + int paramStartIndex = 0) + { + if (string.IsNullOrWhiteSpace(sql)) + throw new ArgumentException("SQL boş olamaz."); + + if (string.IsNullOrWhiteSpace(cascadeParentFields)) + return sql; + + var fields = cascadeParentFields + .Split(',', StringSplitOptions.RemoveEmptyEntries) + .Select(f => f.Trim()) + .ToArray(); + + if (!fields.Any()) + return sql; + + var conditions = new List(); + for (int i = 0; i < fields.Length; i++) + { + var field = fields[i]; + + // Zaten " ile başlıyorsa dokunma + if (!field.StartsWith("\"")) + field = $"\"{field}\""; + + conditions.Add($"{field} = @param{paramStartIndex + i}"); + } + + string whereClause = string.Join(" AND ", conditions); + var upperSql = sql.ToUpperInvariant(); + + if (upperSql.Contains(" WHERE ")) + { + return InsertBeforeClause(sql, "AND " + whereClause); + } + else + { + return InsertBeforeClause(sql, "WHERE " + whereClause); + } + } + + private static string InsertBeforeClause(string sql, string insertText) + { + var upperSql = sql.ToUpperInvariant(); + string[] clauses = { " GROUP BY ", " ORDER BY ", " HAVING " }; + + foreach (var clause in clauses) + { + int index = upperSql.IndexOf(clause); + if (index > -1) + { + return sql.Insert(index, " " + insertText + " "); + } + } + + return sql + " " + insertText; + } } diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Hr.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Hr.cs index 19fcac97..8598731e 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Hr.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Hr.cs @@ -1826,7 +1826,7 @@ public class ListFormSeeder_Hr : IDataSeedContributor, ITransientDependency new() { ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, + SourceDbType = DbType.String, FieldName = "JobPositionId", CaptionName = "App.Listform.ListformField.JobPositionId", Width = 200, @@ -1948,9 +1948,9 @@ public class ListFormSeeder_Hr : IDataSeedContributor, ITransientDependency DisplayExpr = "name", ValueExpr = "key", LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { - new () { Key= "Hours", Name= "Hours" }, - new () { Key= "Weeks", Name= "Weeks" }, - new () { Key= "Months", Name= "Months" } + new () { Key= "Hourly", Name= "Hourly" }, + new () { Key= "Weekly", Name= "Weekly" }, + new () { Key= "Monthly", Name= "Monthly" } }), }), ValidationRuleJson = DefaultValidationRuleRequiredJson, diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json index 40b19e91..5eeb8fa3 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json +++ b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json @@ -2527,7 +2527,7 @@ "Url": null, "Icon": "FcServices", "RequiredPermissionName": null, - "IsDisabled": false, + "IsDisabled": true, "ShortName": "Mrp" }, { diff --git a/ui/src/views/form/FormButtons.tsx b/ui/src/views/form/FormButtons.tsx index 5b84906f..ae541689 100644 --- a/ui/src/views/form/FormButtons.tsx +++ b/ui/src/views/form/FormButtons.tsx @@ -68,7 +68,7 @@ const FormButtons = (props: { const navigate = useNavigate() const { translate } = useLocalization() - + const layout = layoutTypes.grid const { toolbarData } = useToolbar({ gridDto, @@ -113,18 +113,25 @@ const FormButtons = (props: { } } + const toolbarExcludedNames = ['deleteAllRecords', 'deleteSelectedRecords', 'refreshButton'] + const hasVisibleToolbarButtons = toolbarData?.some( + (item) => item.widget == 'dxButton' && !toolbarExcludedNames.includes(item.name!), + ) + + const commandExcludedNames = ['edit', 'delete'] + const hasVisibleCommandButtons = commandColumnData?.buttons?.some( + (item) => typeof item !== 'string' && !commandExcludedNames.includes(item.name!), + ) + return ( <>
{toolbarData ?.filter( - (item) => - item.widget == 'dxButton' && - item.name != 'deleteAllRecords' && - item.name != 'deleteSelectedRecords', + (item) => item.widget == 'dxButton' && !toolbarExcludedNames.includes(item.name!), ) .map((item, i) => { - const IconComp = navigationIcon[item.options?.icon] // React bileşeni olabilir ya da undefined + const IconComp = navigationIcon[item.options?.icon] const hasValidIcon = IconComp && (typeof IconComp === 'function' || @@ -135,24 +142,21 @@ const FormButtons = (props: { key={'toolbarButton-' + i} variant="default" size="xs" - icon={ - hasValidIcon ? : null // 🔒 güvenli render - } + icon={hasValidIcon ? : null} onClick={item.options?.onClick} > {item.options?.text} ) })} - {!!toolbarData?.filter( - (item) => - item.widget == 'dxButton' && - item.name != 'deleteAllRecords' && - item.name != 'deleteSelectedRecords', - ).length && } + + {hasVisibleToolbarButtons && } + + + {commandColumnData?.buttons - ?.filter((item) => typeof item !== 'string') - .map((item, i) => { + ?.filter((item) => typeof item !== 'string' && !commandExcludedNames.includes(item.name!)) + .map((item: any, i) => { return (