From 7a0aa881d59dc43836f807f36872ec50347cf6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Sun, 2 Nov 2025 15:13:06 +0300 Subject: [PATCH] FormSeeder ve Utils eklendi --- .../Seeds/FormSeeder.cs | 1339 +++-------------- .../Seeds/ListSeeder.cs | 113 +- .../Kurs.Platform.DbMigrator/Seeds/Utils.cs | 128 ++ .../Enums/LookUpQueryValues.cs | 2 +- 4 files changed, 349 insertions(+), 1233 deletions(-) create mode 100644 api/src/Kurs.Platform.DbMigrator/Seeds/Utils.cs diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/FormSeeder.cs b/api/src/Kurs.Platform.DbMigrator/Seeds/FormSeeder.cs index f59c6a06..3673a6a1 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/FormSeeder.cs +++ b/api/src/Kurs.Platform.DbMigrator/Seeds/FormSeeder.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Data; using System.Text.Json; using System.Threading.Tasks; -using DocumentFormat.OpenXml.Spreadsheet; using Kurs.Languages.Languages; using Kurs.Platform.Entities; using Kurs.Platform.Enums; @@ -15,11 +14,9 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories; using Volo.Abp.Identity; using Volo.Abp.TenantManagement; -using static Kurs.Platform.PlatformConsts; -using AbpIdentity = Kurs.Platform.Data.Seeds.SeedConsts.AbpIdentity; using AppCodes = Kurs.Platform.Data.Seeds.SeedConsts.AppCodes; -using Kurs.Languages.Entities; -using Kurs.Settings.Entities; +using static Kurs.Platform.PlatformConsts; +using static Kurs.Platform.PlatformSeeder.Utils; namespace Kurs.Platform.Data.Seeds; @@ -58,17 +55,17 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency ShowActivity = true, LayoutJson = JsonSerializer.Serialize(new LayoutDto() { Grid = true, Card = true, Pivot = true, Chart = true, DefaultLayout = "grid", CardLayoutColumn = 4 }), SubFormsJson = JsonSerializer.Serialize(new List() { - new { - TabTitle = "Language Texts", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.LanguageText, - Relation = new List() { - new { - ParentFieldName = "CultureName", - ChildFieldName = "CultureName" + new { + TabTitle = "Language Texts", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.LanguageText, + Relation = new List() { + new { + ParentFieldName = "CultureName", + ChildFieldName = "CultureName" + } } } - } }), CultureName = LanguageCodes.En, ListFormCode = ListFormCodes.Forms.FormLanguage, @@ -83,18 +80,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Language)), KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = "\"IsDeleted\" = 'false'", + DefaultFilter = DefaultFilterJson, SortMode = GridOptions.SortModeSingle, - PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - D = AppCodes.Languages.Language + ".Delete", - E = AppCodes.Languages.Language + ".Export", - I = AppCodes.Languages.Language + ".Import", - A = AppCodes.Languages.Language + ".Activity" - }), + PermissionJson = DefaultPermissionJson(AppCodes.Languages.Language), DeleteCommand = $"UPDATE \"{TableNameResolver.GetFullTableName(nameof(TableNameEnum.Language))}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -108,13 +96,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey } }), - EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto - { - AllowDeleting = true, - AllowAdding = true, - AllowUpdating = true, - ConfirmDelete = true, - }), + EditingOptionJson = DefaultEditingOptionJson, EditingFormJson = JsonSerializer.Serialize(new List() { new() { Order = 1, @@ -155,6 +137,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency }) } ); + await _listFormFieldRepository.InsertManyAsync([ new() { ListFormCode = formLanguage.ListFormCode, @@ -167,19 +150,8 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, SortIndex = 0, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - I = true, - Deny = false - }), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), }, new() { ListFormCode = formLanguage.ListFormCode, @@ -194,22 +166,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SortIndex = 1, SortDirection = GridColumnOptions.SortOrderAsc, AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - I = true, - Deny = false - }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), }, new() { @@ -223,22 +182,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - I = true, - Deny = false - }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), }, new() { @@ -252,22 +198,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - I = true, - Deny = false - }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), }, new() { @@ -280,19 +213,8 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Visible = true, IsActive = true, IsDeleted = false, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - I = true, - Deny = false - }), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), }, new() { @@ -305,22 +227,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Visible = true, IsActive = true, IsDeleted = false, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - I = true, - Deny = false - }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), }, ]); } @@ -373,18 +282,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.SkillType)), KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = "\"IsDeleted\" = 'false'", + DefaultFilter = DefaultFilterJson, SortMode = GridOptions.SortModeSingle, - PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto - { - C = AppCodes.Definitions.SkillType + ".Create", - R = AppCodes.Definitions.SkillType, - U = AppCodes.Definitions.SkillType + ".Update", - D = AppCodes.Definitions.SkillType + ".Delete", - E = AppCodes.Definitions.SkillType + ".Export", - I = AppCodes.Definitions.SkillType + ".Import", - A = AppCodes.Definitions.SkillType + ".Activity" - }), + PermissionJson = DefaultPermissionJson(AppCodes.Definitions.SkillType), DeleteCommand = $"UPDATE \"{TableNameResolver.GetFullTableName(nameof(TableNameEnum.SkillType))}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -398,13 +298,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey } }), - EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto - { - AllowDeleting = true, - AllowAdding = true, - AllowUpdating = true, - ConfirmDelete = true, - }), + EditingOptionJson = DefaultEditingOptionJson, EditingFormJson = JsonSerializer.Serialize(new List() { new() { Order = 1, @@ -413,8 +307,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency ItemType = "group", Items = [ new() { Order = 1, DataField = "Name", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - ] - } + ]} }), InsertFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -442,6 +335,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency }) } ); + await _listFormFieldRepository.InsertManyAsync([ new() { ListFormCode = formSkillType.ListFormCode, @@ -454,19 +348,8 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, SortIndex = 0, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Definitions.SkillType + ".Create", - R = AppCodes.Definitions.SkillType, - U = AppCodes.Definitions.SkillType + ".Update", - E = true, - I = true, - Deny = false - }), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.SkillType), }, new() { ListFormCode = formSkillType.ListFormCode, @@ -481,22 +364,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SortIndex = 1, SortDirection = GridColumnOptions.SortOrderAsc, AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Definitions.SkillType + ".Create", - R = AppCodes.Definitions.SkillType, - U = AppCodes.Definitions.SkillType + ".Update", - E = true, - I = true, - Deny = false - }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.SkillType), }, ]); } @@ -538,18 +408,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.UomCategory)), KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = "\"IsDeleted\" = 'false'", + DefaultFilter = DefaultFilterJson, SortMode = GridOptions.SortModeSingle, - PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto - { - C = AppCodes.Definitions.UomCategory + ".Create", - R = AppCodes.Definitions.UomCategory, - U = AppCodes.Definitions.UomCategory + ".Update", - D = AppCodes.Definitions.UomCategory + ".Delete", - E = AppCodes.Definitions.UomCategory + ".Export", - I = AppCodes.Definitions.UomCategory + ".Import", - A = AppCodes.Definitions.UomCategory + ".Activity" - }), + PermissionJson = DefaultPermissionJson(AppCodes.Definitions.UomCategory), DeleteCommand = $"UPDATE \"{TableNameResolver.GetFullTableName(nameof(TableNameEnum.UomCategory))}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -563,13 +424,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey } }), - EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto - { - AllowDeleting = true, - AllowAdding = true, - AllowUpdating = true, - ConfirmDelete = true, - }), + EditingOptionJson = DefaultEditingOptionJson, EditingFormJson = JsonSerializer.Serialize(new List() { new() { Order = 1, @@ -578,8 +433,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency ItemType = "group", Items = [ new() { Order = 1, DataField = "Name", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - ] - } + ]} }), InsertFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -607,8 +461,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency }) } ); + await _listFormFieldRepository.InsertManyAsync([ - new() { + new() { ListFormCode = formUomCategory.ListFormCode, CultureName = LanguageCodes.En, SourceDbType = DbType.Guid, @@ -619,19 +474,8 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, SortIndex = 0, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Definitions.UomCategory + ".Create", - R = AppCodes.Definitions.UomCategory, - U = AppCodes.Definitions.UomCategory + ".Update", - E = true, - I = true, - Deny = false - }), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.UomCategory), }, new() { ListFormCode = formUomCategory.ListFormCode, @@ -646,22 +490,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SortIndex = 1, SortDirection = GridColumnOptions.SortOrderAsc, AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Definitions.UomCategory + ".Create", - R = AppCodes.Definitions.UomCategory, - U = AppCodes.Definitions.UomCategory + ".Update", - E = true, - I = true, - Deny = false - }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.UomCategory), }, ]); } @@ -707,18 +538,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Bank)), KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = "\"IsDeleted\" = 'false'", + DefaultFilter = DefaultFilterJson, SortMode = GridOptions.SortModeSingle, - PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - D = AppCodes.Accounting.Bank + ".Delete", - E = AppCodes.Accounting.Bank + ".Export", - I = AppCodes.Accounting.Bank + ".Import", - A = AppCodes.Accounting.Bank + ".Activity" - }), + PermissionJson = DefaultPermissionJson(AppCodes.Accounting.Bank), DeleteCommand = $"UPDATE \"{TableNameResolver.GetFullTableName(nameof(TableNameEnum.Bank))}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -732,13 +554,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey } }), - EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto - { - AllowDeleting = true, - AllowAdding = true, - AllowUpdating = true, - ConfirmDelete = true, - }), + EditingOptionJson = DefaultEditingOptionJson, EditingFormJson = JsonSerializer.Serialize(new List() { new() { Order = 1, @@ -757,8 +573,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency new EditingFormItemDto { Order = 9, DataField = "PostalCode", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order = 10, DataField = "Phone", ColSpan = 1, EditorType2=EditorTypes.dxTextBox, EditorOptions=EditorOptionValues.PhoneEditorOptions }, new EditingFormItemDto { Order = 11, DataField = "Email", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, - ] - } + ]} }), InsertFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -786,6 +601,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency }) } ); + #region Bank Fields await _listFormFieldRepository.InsertManyAsync(new ListFormField[] { new() { @@ -799,26 +615,10 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, SortIndex = 0, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, // BranchId new() @@ -838,20 +638,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency ValueExpr = "Key", LookupQuery = LookupQueryValues.BranchValues, }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto { IsPivot = true }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -869,23 +658,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -901,23 +676,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -930,23 +691,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -959,23 +706,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -996,23 +729,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency LookupQuery = LookupQueryValues.CountryValues, CascadeEmptyFields = "City,District,Street" }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -1036,23 +755,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency CascadeParentFields = "Country", CascadeEmptyFields = "District,Street" }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -1076,23 +781,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency CascadeParentFields = "Country,City", CascadeEmptyFields = "Street", }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -1105,23 +796,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -1134,23 +811,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formBank.ListFormCode, @@ -1163,27 +826,10 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] - { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.email) } - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Accounting.Bank + ".Create", - R = AppCodes.Accounting.Bank, - U = AppCodes.Accounting.Bank + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ValidationRuleJson = DefaultValidationRuleEmailJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), + PivotSettingsJson = DefaultPivotSettingsJson, }, }); #endregion @@ -1227,64 +873,17 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, SortMode = GridOptions.SortModeSingle, - FilterRowJson = JsonSerializer.Serialize(new GridFilterRowDto - { - Visible = true - }), - HeaderFilterJson = JsonSerializer.Serialize(new - { - Visible = true - }), - SearchPanelJson = JsonSerializer.Serialize(new - { - Visible = true - }), - GroupPanelJson = JsonSerializer.Serialize(new - { - Visible = true - }), - SelectionJson = JsonSerializer.Serialize(new SelectionDto - { - Mode = GridOptions.SelectionModeSingle, - AllowSelectAll = false - }), - ColumnOptionJson = JsonSerializer.Serialize(new - { - ColumnFixingEnabled = true, - ColumnAutoWidth = true, - ColumnChooserEnabled = true - }), - PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - D = TenantManagementPermissions.Tenants.Delete, - E = TenantManagementPermissions.Tenants.Default + ".Export", - I = TenantManagementPermissions.Tenants.Default + ".Import", - A = TenantManagementPermissions.Tenants.Default + ".Activity", - }), - PagerOptionJson = JsonSerializer.Serialize(new GridPagerOptionDto - { - Visible = true, - AllowedPageSizes = "10,20,50,100", - ShowPageSizeSelector = true, - ShowNavigationButtons = true, - ShowInfo = false, - InfoText = "Page {0} of {1} ({2} items)", - DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive, - ScrollingMode = GridColumnOptions.ScrollingModeStandard, - LoadPanelEnabled = "auto", - LoadPanelText = "Loading..." - }), + FilterRowJson = JsonSerializer.Serialize(new GridFilterRowDto { Visible = true }), + HeaderFilterJson = JsonSerializer.Serialize(new { Visible = true }), + SearchPanelJson = JsonSerializer.Serialize(new { Visible = true }), + GroupPanelJson = JsonSerializer.Serialize(new { Visible = true }), + SelectionJson = DefaultSelectionSingleJson, + ColumnOptionJson = DefaultColumnOptionJson, + PermissionJson = DefaultPermissionJson(TenantManagementPermissions.Tenants.Create, TenantManagementPermissions.Tenants.Default, TenantManagementPermissions.Tenants.Update, TenantManagementPermissions.Tenants.Delete, TenantManagementPermissions.Tenants.Default + ".Export", TenantManagementPermissions.Tenants.Default + ".Import", TenantManagementPermissions.Tenants.Default + ".Activity"), + PagerOptionJson = DefaultPagerOptionJson, EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto { - Popup = new GridEditingPopupDto() - { - Title = "Tenant Form", - Width = 900, - Height = 450 - }, + Popup = new GridEditingPopupDto() { Title = AppCodes.Definitions.QuestionPool, Width = 900, Height = 450 }, AllowDeleting = true, AllowAdding = true, AllowUpdating = true, @@ -1292,8 +891,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency }), EditingFormJson = JsonSerializer.Serialize(new List() { - new() { Order=1, ColCount=2, ColSpan=1, ItemType="group", Items = - [ + new() { Order=1, ColCount=2, ColSpan=1, ItemType="group", Items =[ new EditingFormItemDto { Order=1, DataField = "Name", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order=2, DataField = "OrganizationName", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order=3, DataField = "Founder", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxTextBox }, @@ -1303,10 +901,8 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency new EditingFormItemDto { Order=7, DataField = "Phone", ColSpan=1, IsRequired=false, EditorType2=EditorTypes.dxTextBox, EditorOptions=EditorOptionValues.PhoneEditorOptions }, new EditingFormItemDto { Order=8, DataField = "Fax", ColSpan=1, IsRequired=false, EditorType2=EditorTypes.dxTextBox, EditorOptions=EditorOptionValues.PhoneEditorOptions }, new EditingFormItemDto { Order=9, DataField = "IsActive", ColSpan=1, IsRequired=false, EditorType2=EditorTypes.dxCheckBox }, - ] - }, - new() { Order=2, ColCount=2, ColSpan=1, ItemType="group", Items = - [ + ]}, + new() { Order=2, ColCount=2, ColSpan=1, ItemType="group", Items = [ new EditingFormItemDto { Order=1, DataField = "Country", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, new EditingFormItemDto { Order=2, DataField = "City", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, new EditingFormItemDto { Order=3, DataField = "District", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, @@ -1316,8 +912,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency new EditingFormItemDto { Order=7, DataField = "Address2", ColSpan=1, IsRequired=false, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order=8, DataField = "Email", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order=9, DataField = "Website", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxTextBox }, - ] - } + ]} }), CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] { new() { @@ -1360,7 +955,7 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency #region Tenants Fields await _listFormFieldRepository.InsertManyAsync( [ - new ListFormField + new ListFormField { ListFormCode = formTenant.ListFormCode, CultureName = LanguageCodes.En, @@ -1371,23 +966,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Visible = false, IsActive = true, IsDeleted = false, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1401,23 +982,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1431,23 +998,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1461,23 +1014,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1491,23 +1030,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1521,23 +1046,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1559,23 +1070,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency LookupQuery = LookupQueryValues.CountryValues, CascadeEmptyFields = "City,District,Street" }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1600,23 +1097,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency CascadeParentFields = "Country", CascadeEmptyFields = "District,Street" }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1641,23 +1124,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency CascadeParentFields = "Country,City", CascadeEmptyFields = "Street", }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1681,23 +1150,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency CascadeFilterOperator="=", CascadeParentFields = "Country,City,District" }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1711,23 +1166,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1741,23 +1182,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1771,23 +1198,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1805,23 +1218,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency { new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.email) } }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1835,23 +1234,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1865,23 +1250,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1895,23 +1266,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1925,23 +1282,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, new ListFormField { @@ -1954,23 +1297,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Visible = true, IsActive = true, IsDeleted = false, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = TenantManagementPermissions.Tenants.Create, - R = TenantManagementPermissions.Tenants.Default, - U = TenantManagementPermissions.Tenants.Update, - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), + PivotSettingsJson = DefaultPivotSettingsJson, }, ]); #endregion @@ -2013,36 +1342,15 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.QuestionPool)), KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = "\"IsDeleted\" = 'false'", + DefaultFilter = DefaultFilterJson, SortMode = GridOptions.SortModeSingle, FilterRowJson = JsonSerializer.Serialize(new GridFilterRowDto { Visible = true }), HeaderFilterJson = JsonSerializer.Serialize(new { Visible = true }), SearchPanelJson = JsonSerializer.Serialize(new { Visible = true }), GroupPanelJson = JsonSerializer.Serialize(new { Visible = true }), - SelectionJson = JsonSerializer.Serialize(new SelectionDto - { - Mode = GridOptions.SelectionModeSingle, - AllowSelectAll = false - }), - ColumnOptionJson = JsonSerializer.Serialize(new - { - ColumnFixingEnabled = true, - ColumnAutoWidth = true, - ColumnChooserEnabled = true, - AllowColumnResizing = true, - AllowColumnReordering = true, - ColumnResizingMode = "widget", - }), - PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto - { - C = AppCodes.Definitions.QuestionPool + ".Create", - R = AppCodes.Definitions.QuestionPool, - U = AppCodes.Definitions.QuestionPool + ".Update", - D = AppCodes.Definitions.QuestionPool + ".Delete", - E = AppCodes.Definitions.QuestionPool + ".Export", - I = AppCodes.Definitions.QuestionPool + ".Import", - A = AppCodes.Definitions.QuestionPool + ".Activity", - }), + SelectionJson = DefaultSelectionSingleJson, + ColumnOptionJson = DefaultColumnOptionJson, + PermissionJson = DefaultPermissionJson(AppCodes.Definitions.QuestionPool), DeleteCommand = $"UPDATE \"{TableNameResolver.GetFullTableName(nameof(TableNameEnum.QuestionPool))}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -2056,40 +1364,21 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey } }), - PagerOptionJson = JsonSerializer.Serialize(new GridPagerOptionDto - { - Visible = true, - AllowedPageSizes = "10,20,50,100", - ShowPageSizeSelector = true, - ShowNavigationButtons = true, - ShowInfo = false, - InfoText = "Page {0} of {1} ({2} items)", - DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive, - ScrollingMode = GridColumnOptions.ScrollingModeStandard, - LoadPanelEnabled = "auto", - LoadPanelText = "Loading..." - }), + PagerOptionJson = DefaultPagerOptionJson, EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto { - Popup = new GridEditingPopupDto() - { - Title = "Question Pool Form", - Width = 500, - Height = 250 - }, + Popup = new GridEditingPopupDto() { Title = AppCodes.Definitions.QuestionPool, Width = 500, Height = 250 }, AllowDeleting = true, AllowAdding = true, AllowUpdating = true, SendOnlyChangedFormValuesUpdate = false, }), EditingFormJson = JsonSerializer.Serialize(new List() { - new() { Order=1,ColCount=1,ColSpan=2,ItemType="group", Items= - [ + new() { Order=1,ColCount=1,ColSpan=2,ItemType="group", Items=[ new EditingFormItemDto { Order = 1, DataField = "Name", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order = 2, DataField = "Description", ColSpan = 2, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order = 3, DataField = "Tags", ColSpan = 2, EditorType2=EditorTypes.dxTagBox }, - ] - } + ]} }), InsertFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -2124,26 +1413,10 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, SortIndex = 0, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required) } - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Definitions.QuestionPool + ".Create", - R = AppCodes.Definitions.QuestionPool, - U = AppCodes.Definitions.QuestionPool + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.QuestionPool), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formQuestionPool.ListFormCode, @@ -2158,26 +1431,10 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SortIndex = 1, SortDirection = GridColumnOptions.SortOrderAsc, AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required) } - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Definitions.QuestionPool + ".Create", - R = AppCodes.Definitions.QuestionPool, - U = AppCodes.Definitions.QuestionPool + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.QuestionPool), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formQuestionPool.ListFormCode, @@ -2190,23 +1447,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Definitions.QuestionPool + ".Create", - R = AppCodes.Definitions.QuestionPool, - U = AppCodes.Definitions.QuestionPool + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.QuestionPool), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formQuestionPool.ListFormCode, @@ -2225,23 +1468,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency ValueExpr = "Key", LookupQuery = LookupQueryValues.QuestionTagValues }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Definitions.QuestionPool + ".Create", - R = AppCodes.Definitions.QuestionPool, - U = AppCodes.Definitions.QuestionPool + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.QuestionPool), + PivotSettingsJson = DefaultPivotSettingsJson, } }); #endregion @@ -2302,36 +1531,15 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Survey)), KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = "\"IsDeleted\" = 'false'", + DefaultFilter = DefaultFilterJson, SortMode = GridOptions.SortModeSingle, FilterRowJson = JsonSerializer.Serialize(new GridFilterRowDto { Visible = true }), HeaderFilterJson = JsonSerializer.Serialize(new { Visible = true }), SearchPanelJson = JsonSerializer.Serialize(new { Visible = true }), GroupPanelJson = JsonSerializer.Serialize(new { Visible = true }), - SelectionJson = JsonSerializer.Serialize(new SelectionDto - { - Mode = GridOptions.SelectionModeSingle, - AllowSelectAll = false - }), - ColumnOptionJson = JsonSerializer.Serialize(new - { - ColumnFixingEnabled = true, - ColumnAutoWidth = true, - ColumnChooserEnabled = true, - AllowColumnResizing = true, - AllowColumnReordering = true, - ColumnResizingMode = "widget", - }), - PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto - { - C = AppCodes.Hr.Survey + ".Create", - R = AppCodes.Hr.Survey, - U = AppCodes.Hr.Survey + ".Update", - D = AppCodes.Hr.Survey + ".Delete", - E = AppCodes.Hr.Survey + ".Export", - I = AppCodes.Hr.Survey + ".Import", - A = AppCodes.Hr.Survey + ".Activity", - }), + SelectionJson = DefaultSelectionSingleJson, + ColumnOptionJson = DefaultColumnOptionJson, + PermissionJson = DefaultPermissionJson(AppCodes.Hr.Survey), DeleteCommand = $"UPDATE \"{TableNameResolver.GetFullTableName(nameof(TableNameEnum.Survey))}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { @@ -2345,27 +1553,10 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey } }), - PagerOptionJson = JsonSerializer.Serialize(new GridPagerOptionDto - { - Visible = true, - AllowedPageSizes = "10,20,50,100", - ShowPageSizeSelector = true, - ShowNavigationButtons = true, - ShowInfo = false, - InfoText = "Page {0} of {1} ({2} items)", - DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive, - ScrollingMode = GridColumnOptions.ScrollingModeStandard, - LoadPanelEnabled = "auto", - LoadPanelText = "Loading..." - }), + PagerOptionJson = DefaultPagerOptionJson, EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto { - Popup = new GridEditingPopupDto() - { - Title = "Survey Form", - Width = 500, - Height = 450 - }, + Popup = new GridEditingPopupDto() { Title = AppCodes.Hr.Survey, Width = 500, Height = 450 }, AllowDeleting = true, AllowAdding = true, AllowUpdating = true, @@ -2391,15 +1582,13 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency EditingFormJson = JsonSerializer.Serialize(new List() { new() { - Order=1, ColCount=1, ColSpan=2, ItemType="group", Items = - [ + Order=1, ColCount=1, ColSpan=2, ItemType="group", Items =[ new EditingFormItemDto { Order = 1, DataField = "Title", IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, new EditingFormItemDto { Order = 2, DataField = "Description", IsRequired = true, EditorType2 = EditorTypes.dxTextArea }, new EditingFormItemDto { Order = 3, DataField = "Deadline", IsRequired = true, EditorType2 = EditorTypes.dxDateBox }, new EditingFormItemDto { Order = 4, DataField = "Status", IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, new EditingFormItemDto { Order = 5, DataField = "IsAnonymous", IsRequired = true, EditorType2 = EditorTypes.dxCheckBox }, - ] - } + ]} }), FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { @@ -2430,26 +1619,10 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, SortIndex = 0, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required) } - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Intranet.Announcement + ".Create", - R = AppCodes.Intranet.Announcement, - U = AppCodes.Intranet.Announcement + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formSurvey.ListFormCode, @@ -2462,26 +1635,10 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required) } - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Hr.Survey + ".Create", - R = AppCodes.Hr.Survey, - U = AppCodes.Hr.Survey + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formSurvey.ListFormCode, @@ -2494,26 +1651,10 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required) } - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Hr.Survey + ".Create", - R = AppCodes.Hr.Survey, - U = AppCodes.Hr.Survey + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formSurvey.ListFormCode, @@ -2526,23 +1667,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Hr.Survey + ".Create", - R = AppCodes.Hr.Survey, - U = AppCodes.Hr.Survey + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formSurvey.ListFormCode, @@ -2566,26 +1693,10 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency new () { Key= "closed", Name= "Closed" }, }), }), - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required) } - }), - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Hr.Survey + ".Create", - R = AppCodes.Hr.Survey, - U = AppCodes.Hr.Survey + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), + PivotSettingsJson = DefaultPivotSettingsJson, }, new() { ListFormCode = formSurvey.ListFormCode, @@ -2598,23 +1709,9 @@ public class FormSeeder : IDataSeedContributor, ITransientDependency IsActive = true, IsDeleted = false, AllowSearch = true, - ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Hr.Survey + ".Create", - R = AppCodes.Hr.Survey, - U = AppCodes.Hr.Survey + ".Update", - E = true, - I = true, - Deny = false - }), - PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }) + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), + PivotSettingsJson = DefaultPivotSettingsJson, }, ]); #endregion diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/ListSeeder.cs b/api/src/Kurs.Platform.DbMigrator/Seeds/ListSeeder.cs index 85bc10b0..ff9293b5 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/ListSeeder.cs +++ b/api/src/Kurs.Platform.DbMigrator/Seeds/ListSeeder.cs @@ -14,9 +14,10 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories; using Volo.Abp.Identity; using Volo.Abp.TenantManagement; -using static Kurs.Platform.PlatformConsts; using AbpIdentity = Kurs.Platform.Data.Seeds.SeedConsts.AbpIdentity; using AppCodes = Kurs.Platform.Data.Seeds.SeedConsts.AppCodes; +using static Kurs.Platform.PlatformConsts; +using static Kurs.Platform.PlatformSeeder.Utils; namespace Kurs.Platform.Data.Seeds; @@ -42,116 +43,6 @@ public class ListSeeder : IDataSeedContributor, ITransientDependency _configuration = configuration; } - private readonly string DefaultFilterJson = "\"IsDeleted\" = 'false'"; - private readonly string DefaultColumnOptionJson = JsonSerializer.Serialize(new - { - ColumnFixingEnabled = true, - ColumnAutoWidth = true, - ColumnChooserEnabled = true, - AllowColumnResizing = true, - AllowColumnReordering = true, - ColumnResizingMode = "widget", - }); - private readonly string DefaultLayoutJson = JsonSerializer.Serialize(new LayoutDto() - { - Grid = true, - Card = true, - Pivot = true, - Chart = true, - DefaultLayout = "grid", - CardLayoutColumn = 4 - }); - private readonly string DefaultSelectionSingleJson = JsonSerializer.Serialize(new SelectionDto - { - Mode = GridOptions.SelectionModeSingle, - AllowSelectAll = false - }); - private readonly string DefaultSelectionMultipleJson = JsonSerializer.Serialize(new SelectionDto - { - AllowSelectAll = true, - Mode = GridOptions.SelectionModeMultiple, - SelectAllMode = GridOptions.SelectionAllModeAllPages - }); - private readonly string DefaultPagerOptionJson = JsonSerializer.Serialize(new GridPagerOptionDto - { - Visible = true, - AllowedPageSizes = "10,20,50,100", - ShowPageSizeSelector = true, - ShowNavigationButtons = true, - ShowInfo = false, - InfoText = "Page {0} of {1} ({2} items)", - DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive, - ScrollingMode = GridColumnOptions.ScrollingModeStandard, - LoadPanelEnabled = "auto", - LoadPanelText = "Loading..." - }); - private readonly string DefaultColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto - { - AllowReordering = true, - }); - private readonly string DefaultPivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto - { - IsPivot = true - }); - private readonly string DefaultValidationRuleRequiredJson = JsonSerializer.Serialize(new ValidationRuleDto[] - { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required) } - }); - private readonly string DefaultValidationRuleEmailJson = JsonSerializer.Serialize(new ValidationRuleDto[] - { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.email) } - }); - private string DefaultPermissionJson(string c, string r, string u, string d, string e, string i, string a) - { - return JsonSerializer.Serialize(new PermissionCrudDto - { - C = c, - R = r, - U = u, - D = d, - E = e, - I = i, - A = a, - }); - } - private string DefaultPermissionJson(string permissionName) - { - return JsonSerializer.Serialize(new PermissionCrudDto - { - C = permissionName + ".Create", - R = permissionName, - U = permissionName + ".Update", - D = permissionName + ".Delete", - E = permissionName + ".Export", - I = permissionName + ".Import", - A = permissionName + ".Activity", - }); - } - private string DefaultFieldPermissionJson(string permissionName) - { - return JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = permissionName + ".Create", - R = permissionName, - U = permissionName + ".Update", - E = true, - I = false, - Deny = false - }); - } - private string DefaultFieldPermissionJson(string c, string r, string u, bool e, bool i, bool d) - { - return JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = c, - R = r, - U = u, - E = e, - I = i, - Deny = d - }); - } - public async Task SeedAsync(DataSeedContext context) { #region Tenant diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/Utils.cs b/api/src/Kurs.Platform.DbMigrator/Seeds/Utils.cs new file mode 100644 index 00000000..5c13942d --- /dev/null +++ b/api/src/Kurs.Platform.DbMigrator/Seeds/Utils.cs @@ -0,0 +1,128 @@ +using System; +using System.Text.Json; +using Kurs.Platform.Enums; +using Kurs.Platform.ListForms; +using static Kurs.Platform.PlatformConsts; + +namespace Kurs.Platform.PlatformSeeder; + +public static class Utils +{ + public static readonly string DefaultEditingOptionJson = JsonSerializer.Serialize(new GridEditingDto + { + AllowDeleting = true, + AllowAdding = true, + AllowUpdating = true, + ConfirmDelete = true, + }); + + public static readonly string DefaultFilterJson = "\"IsDeleted\" = 'false'"; + public static readonly string DefaultColumnOptionJson = JsonSerializer.Serialize(new + { + ColumnFixingEnabled = true, + ColumnAutoWidth = true, + ColumnChooserEnabled = true, + AllowColumnResizing = true, + AllowColumnReordering = true, + ColumnResizingMode = "widget", + }); + public static readonly string DefaultLayoutJson = JsonSerializer.Serialize(new LayoutDto() + { + Grid = true, + Card = true, + Pivot = true, + Chart = true, + DefaultLayout = "grid", + CardLayoutColumn = 4 + }); + public static readonly string DefaultSelectionSingleJson = JsonSerializer.Serialize(new SelectionDto + { + Mode = GridOptions.SelectionModeSingle, + AllowSelectAll = false + }); + public static readonly string DefaultSelectionMultipleJson = JsonSerializer.Serialize(new SelectionDto + { + AllowSelectAll = true, + Mode = GridOptions.SelectionModeMultiple, + SelectAllMode = GridOptions.SelectionAllModeAllPages + }); + public static readonly string DefaultPagerOptionJson = JsonSerializer.Serialize(new GridPagerOptionDto + { + Visible = true, + AllowedPageSizes = "10,20,50,100", + ShowPageSizeSelector = true, + ShowNavigationButtons = true, + ShowInfo = false, + InfoText = "Page {0} of {1} ({2} items)", + DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive, + ScrollingMode = GridColumnOptions.ScrollingModeStandard, + LoadPanelEnabled = "auto", + LoadPanelText = "Loading..." + }); + public static readonly string DefaultColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto + { + AllowReordering = true, + }); + public static readonly string DefaultPivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto + { + IsPivot = true + }); + public static readonly string DefaultValidationRuleRequiredJson = JsonSerializer.Serialize(new ValidationRuleDto[] + { + new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required) } + }); + public static readonly string DefaultValidationRuleEmailJson = JsonSerializer.Serialize(new ValidationRuleDto[] + { + new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.email) } + }); + public static string DefaultPermissionJson(string c, string r, string u, string d, string e, string i, string a) + { + return JsonSerializer.Serialize(new PermissionCrudDto + { + C = c, + R = r, + U = u, + D = d, + E = e, + I = i, + A = a, + }); + } + public static string DefaultPermissionJson(string permissionName) + { + return JsonSerializer.Serialize(new PermissionCrudDto + { + C = permissionName + ".Create", + R = permissionName, + U = permissionName + ".Update", + D = permissionName + ".Delete", + E = permissionName + ".Export", + I = permissionName + ".Import", + A = permissionName + ".Activity", + }); + } + public static string DefaultFieldPermissionJson(string permissionName) + { + return JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = permissionName + ".Create", + R = permissionName, + U = permissionName + ".Update", + E = true, + I = false, + Deny = false + }); + } + public static string DefaultFieldPermissionJson(string c, string r, string u, bool e, bool i, bool d) + { + return JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = c, + R = r, + U = u, + E = e, + I = i, + Deny = d + }); + } +} \ No newline at end of file diff --git a/api/src/Kurs.Platform.Domain.Shared/Enums/LookUpQueryValues.cs b/api/src/Kurs.Platform.Domain.Shared/Enums/LookUpQueryValues.cs index a06f8805..ad186412 100644 --- a/api/src/Kurs.Platform.Domain.Shared/Enums/LookUpQueryValues.cs +++ b/api/src/Kurs.Platform.Domain.Shared/Enums/LookUpQueryValues.cs @@ -312,7 +312,7 @@ public static class LookupQueryValues $"SELECT \"Name\" AS \"Key\", " + $"CONCAT(\"Name\", ' (', \"DisplayName\", ')') AS \"Name\" " + $"FROM \"AbpPermissions\" " + - $"WHERE \"IsDeleted\" = 'false' " + + $"WHERE \"IsEnabled\" = 'false' " + $"ORDER BY \"Name\";"; public static string MenuCodeValues =