diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Accounting.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Accounting.cs index d05d2984..c79614f3 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Accounting.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Accounting.cs @@ -43,310 +43,7 @@ public class ListFormSeeder_Accounting : IDataSeedContributor, ITransientDepende public async Task SeedAsync(DataSeedContext context) { - #region FormBank - if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Forms.FormBank)) - { - var formBank = await _listFormRepository.InsertAsync( - new ListForm() - { - ListFormType = ListFormTypeEnum.Form, - IsSubForm = false, - ShowActivity = true, - LayoutJson = DefaultLayoutJson, - SubFormsJson = JsonSerializer.Serialize(new List() { - new { - TabTitle = "Bank Accounts", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.BankAccount, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "BankId" - }, - new { - ParentFieldName = "BranchId", - ChildFieldName = "BranchId" - }, - } - }, - }), - CultureName = LanguageCodes.En, - ListFormCode = ListFormCodes.Forms.FormBank, - Name = AppCodes.Accounting.Bank, - Title = AppCodes.Accounting.Bank, - DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = false, - IsBranch = false, - IsOrganizationUnit = false, - Description = AppCodes.Accounting.Bank, - SelectCommandType = SelectCommandTypeEnum.Table, - SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Bank)), - KeyFieldName = "Id", - KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = DefaultFilterJson, - SortMode = GridOptions.SortModeSingle, - PermissionJson = DefaultPermissionJson(AppCodes.Accounting.Bank), - DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.Bank)), - DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, - EditingOptionJson = DefaultEditingOptionJson(AppCodes.Accounting.Bank, 600, 500, true, true, true, true, false), - EditingFormJson = JsonSerializer.Serialize(new List() { - new() { - Order = 1, ColCount = 2, ColSpan = 2, ItemType = "group", Items = - [ - new EditingFormItemDto { Order = 1, DataField = "BranchId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, - new EditingFormItemDto { Order = 2, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 3, DataField = "IdentifierCode", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox}, - new EditingFormItemDto { Order = 4, DataField = "Address1", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 5, DataField = "Address2", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 6, DataField = "Country", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, - new EditingFormItemDto { Order = 7, DataField = "City", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, - new EditingFormItemDto { Order = 8, DataField = "District", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, - new EditingFormItemDto { Order = 9, DataField = "PostalCode", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 10, DataField = "PhoneNumber", ColSpan = 1, EditorType2=EditorTypes.dxTextBox, EditorOptions=EditorOptionValues.PhoneEditorOptions }, - new EditingFormItemDto { Order = 11, DataField = "Email", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, - ]} - }), - InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, - FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { FieldName = "Country", FieldDbType = DbType.String, Value = "TR", CustomValueType = FieldCustomValueTypeEnum.Value } - }) - } - ); - - #region Bank Fields - await _listFormFieldRepository.InsertManyAsync(new ListFormField[] { - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "Id", - Width = 100, - ListOrderNo = 1, - Visible = false, - IsActive = true, - IsDeleted = false, - SortIndex = 0, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - // BranchId - new() - { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "BranchId", - Width = 150, - ListOrderNo = 2, - Visible = true, - IsActive = true, - IsDeleted = false, - LookupJson = JsonSerializer.Serialize(new LookupDto { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.BranchValues, - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Name", - Width = 150, - ListOrderNo = 3, - Visible = true, - IsActive = true, - IsDeleted = false, - SortIndex = 1, - SortDirection = GridColumnOptions.SortOrderAsc, - AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "IdentifierCode", - Width = 150, - ListOrderNo = 4, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Address1", - Width = 150, - ListOrderNo = 5, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Address2", - Width = 150, - ListOrderNo = 6, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Country", - Width = 100, - ListOrderNo = 7, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.CountryValues, - CascadeEmptyFields = "City,District,Street" - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "City", - Width = 100, - ListOrderNo = 8, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.CityValues, - CascadeRelationField = "Country", - CascadeFilterOperator="=", - CascadeParentFields = "Country", - CascadeEmptyFields = "District,Street" - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "District", - Width = 100, - ListOrderNo = 9, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.DistrictValues, - CascadeRelationField = "City", - CascadeFilterOperator="=", - CascadeParentFields = "Country,City", - CascadeEmptyFields = "Street", - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "PostalCode", - Width = 150, - ListOrderNo = 10, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "PhoneNumber", - Width = 150, - ListOrderNo = 11, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - EditorOptions = EditorOptionValues.PhoneEditorOptions, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formBank.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Email", - Width = 150, - ListOrderNo = 10, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleEmailJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - }); - #endregion - } - #endregion + using var utils = new SeederUtils(); #region Bank if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.Bank)) @@ -384,7 +81,7 @@ public class ListFormSeeder_Accounting : IDataSeedContributor, ITransientDepende PagerOptionJson = DefaultPagerOptionJson, EditingOptionJson = DefaultEditingOptionJson(AppCodes.Accounting.Bank, 600, 600, true, true, true, true, false), EditingFormJson = JsonSerializer.Serialize(new List() { - new() { + new() { Order=1, ColCount=1, ColSpan=1, ItemType="group", Items = [ new EditingFormItemDto { Order = 2, DataField = "BranchId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, @@ -407,17 +104,17 @@ public class ListFormSeeder_Accounting : IDataSeedContributor, ITransientDepende Text ="Manage", UrlTarget="_blank", AuthName = AppCodes.Accounting.BankAccount, - Url=$"/admin/form/{ListFormCodes.Forms.FormBank}/@Id" + Url=$"/admin/form/{utils.GetFormCodes(ListFormCodes.Lists.Bank)}/@Id" }, }), FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { FieldName = "Country", FieldDbType = DbType.String, Value = "TR", CustomValueType = FieldCustomValueTypeEnum.Value } }) } - ); + , autoSave: true); #region Bank Fields - await _listFormFieldRepository.InsertManyAsync(new ListFormField[] { + await _listFormFieldRepository.InsertManyAsync([ new() { ListFormCode = listFormBank.ListFormCode, CultureName = LanguageCodes.En, @@ -642,8 +339,33 @@ public class ListFormSeeder_Accounting : IDataSeedContributor, ITransientDepende PermissionJson = DefaultFieldPermissionJson(AppCodes.Accounting.Bank), PivotSettingsJson = DefaultPivotSettingsJson }, - }); + ], autoSave: true); #endregion + + // Sub Forms for Bank + await utils.CloneListFormWithFieldsAsync( + _listFormRepository, + _listFormFieldRepository, + ListFormCodes.Lists.Bank, + utils.GetFormCodes(ListFormCodes.Lists.Bank), + JsonSerializer.Serialize(new List() { + new { + TabTitle = "Bank Accounts", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.BankAccount, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "BankId" + }, + new { + ParentFieldName = "BranchId", + ChildFieldName = "BranchId" + }, + } + }, + }) + ); } #endregion @@ -684,7 +406,7 @@ public class ListFormSeeder_Accounting : IDataSeedContributor, ITransientDepende InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, EditingOptionJson = DefaultEditingOptionJson(AppCodes.Accounting.BankAccount, 600, 300, true, true, true, true, false), EditingFormJson = JsonSerializer.Serialize(new List() { - new() { + new() { Order=1, ColCount=1, ColSpan=1, ItemType="group", Items = [ new EditingFormItemDto { Order = 1, DataField = "BankId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs index 646400b0..712a6b6a 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs @@ -13,7 +13,6 @@ using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories; using Volo.Abp.Identity; -using Volo.Abp.TenantManagement; using AbpIdentity = Erp.Platform.Data.Seeds.SeedConsts.AbpIdentity; using AppCodes = Erp.Platform.Data.Seeds.SeedConsts.AppCodes; using static Erp.Platform.PlatformConsts; @@ -47,202 +46,7 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep { var configurationSection = _configuration.GetSection("OpenIddict:Applications"); var swaggerRootUrl = configurationSection["Platform_Swagger:RootUrl"]?.TrimEnd('/'); - - #region FormSkillType - if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Forms.FormSkillType)) - { - var formSkillType = await _listFormRepository.InsertAsync( - new ListForm() - { - ListFormType = ListFormTypeEnum.Form, - IsSubForm = false, - ShowActivity = true, - LayoutJson = DefaultLayoutJson, - SubFormsJson = JsonSerializer.Serialize(new List() { - new { - TabTitle = "Skill Levels", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.SkillLevel, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "SkillTypeId" - } - } - }, - new { - TabTitle = "Skills", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.Skill, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "SkillTypeId" - } - } - } - }), - CultureName = LanguageCodes.En, - ListFormCode = ListFormCodes.Forms.FormSkillType, - Name = AppCodes.Definitions.SkillType, - Title = AppCodes.Definitions.SkillType, - DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = false, - IsBranch = false, - IsOrganizationUnit = false, - Description = AppCodes.Definitions.SkillType, - SelectCommandType = SelectCommandTypeEnum.Table, - SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.SkillType)), - KeyFieldName = "Id", - KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = DefaultFilterJson, - SortMode = GridOptions.SortModeSingle, - PermissionJson = DefaultPermissionJson(AppCodes.Definitions.SkillType), - DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.SkillType)), - DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, - EditingOptionJson = DefaultEditingOptionJson(AppCodes.Definitions.SkillType, 400, 200, true, true, true, true, false), - EditingFormJson = JsonSerializer.Serialize(new List() { - new() { - Order = 1, ColCount = 1, ColSpan = 1, ItemType = "group", Items = - [ - new() { Order = 1, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - ]} - }), - InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, - FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { FieldName = "IsEnabled", FieldDbType = DbType.Boolean, Value = "true", CustomValueType = FieldCustomValueTypeEnum.Value } - }) - } - ); - - await _listFormFieldRepository.InsertManyAsync([ - new() { - ListFormCode = formSkillType.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "Id", - Width = 100, - ListOrderNo = 0, - Visible = false, - IsActive = true, - IsDeleted = false, - SortIndex = 0, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.SkillType), - }, - new() { - ListFormCode = formSkillType.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Name", - Width = 150, - ListOrderNo = 1, - Visible = true, - IsActive = true, - IsDeleted = false, - SortIndex = 1, - SortDirection = GridColumnOptions.SortOrderAsc, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.SkillType), - }, - ]); - } - #endregion - - #region FormUomCategory - if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Forms.FormUomCategory)) - { - var formUomCategory = await _listFormRepository.InsertAsync( - new ListForm() - { - ListFormType = ListFormTypeEnum.Form, - IsSubForm = false, - ShowActivity = true, - LayoutJson = DefaultLayoutJson, - SubFormsJson = JsonSerializer.Serialize(new List() { - new { - TabTitle = "Uoms", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.Uom, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "UomCategoryId" - } - } - }, - }), - CultureName = LanguageCodes.En, - ListFormCode = ListFormCodes.Forms.FormUomCategory, - Name = AppCodes.Definitions.UomCategory, - Title = AppCodes.Definitions.UomCategory, - DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = false, - IsBranch = false, - IsOrganizationUnit = false, - Description = AppCodes.Definitions.UomCategory, - SelectCommandType = SelectCommandTypeEnum.Table, - SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.UomCategory)), - KeyFieldName = "Id", - KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = DefaultFilterJson, - SortMode = GridOptions.SortModeSingle, - PermissionJson = DefaultPermissionJson(AppCodes.Definitions.UomCategory), - DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.UomCategory)), - DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, - EditingOptionJson = DefaultEditingOptionJson(AppCodes.Definitions.UomCategory, 400, 200, true, true, true, true, false), - EditingFormJson = JsonSerializer.Serialize(new List() - { - new() { - Order = 1, ColCount = 1, ColSpan = 1, ItemType = "group", Items = - [ - new() { Order = 1, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - ]} - }), - InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, - FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { FieldName = "IsEnabled", FieldDbType = DbType.Boolean, Value = "true", CustomValueType = FieldCustomValueTypeEnum.Value } - }) - } - ); - - await _listFormFieldRepository.InsertManyAsync([ - new() { - ListFormCode = formUomCategory.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "Id", - Width = 100, - ListOrderNo = 0, - Visible = false, - IsActive = true, - IsDeleted = false, - SortIndex = 0, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.UomCategory), - }, - new() { - ListFormCode = formUomCategory.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Name", - Width = 150, - ListOrderNo = 1, - Visible = true, - IsActive = true, - IsDeleted = false, - SortIndex = 1, - SortDirection = GridColumnOptions.SortOrderAsc, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.UomCategory), - }, - ]); - } - #endregion + using var utils = new SeederUtils(); #region Permission Group if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.PermissionGroup)) @@ -4266,14 +4070,14 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep Text ="Manage", UrlTarget="_blank", AuthName = AppCodes.Definitions.Skill, - Url=$"/admin/form/{ListFormCodes.Forms.FormSkillType}/@Id" + Url=$"/admin/form/{utils.GetFormCodes(ListFormCodes.Lists.SkillType)}/@Id" }, }), - }); + }, autoSave: true); #region SkillType Fields await _listFormFieldRepository.InsertManyAsync([ - new () + new() { ListFormCode = listFormSkillType.ListFormCode, CultureName = LanguageCodes.En, @@ -4303,8 +4107,40 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep ColumnCustomizationJson = DefaultColumnCustomizationJson, PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.SkillType), } - ]); + ], autoSave: true); #endregion + + // Sub Forms for SkillType + await utils.CloneListFormWithFieldsAsync( + _listFormRepository, + _listFormFieldRepository, + ListFormCodes.Lists.SkillType, + utils.GetFormCodes(ListFormCodes.Lists.SkillType), + JsonSerializer.Serialize(new List() { + new { + TabTitle = "Skill Levels", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.SkillLevel, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "SkillTypeId" + } + } + }, + new { + TabTitle = "Skills", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.Skill, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "SkillTypeId" + } + } + } + }) + ); } #endregion @@ -4555,8 +4391,7 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.UomCategory)) { var listFormUomCategory = await _listFormRepository.InsertAsync( - new ListForm - { + new ListForm { ListFormType = ListFormTypeEnum.List, IsSubForm = false, LayoutJson = DefaultLayoutJson, @@ -4602,10 +4437,10 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep Text ="Manage", UrlTarget="_blank", AuthName = AppCodes.Definitions.Uom, - Url=$"/admin/form/{ListFormCodes.Forms.FormUomCategory}/@Id" + Url=$"/admin/form/{utils.GetFormCodes(ListFormCodes.Lists.UomCategory)}/@Id" }, }), - }); + }, autoSave: true); #region UomCategory Fields await _listFormFieldRepository.InsertManyAsync([ @@ -4639,8 +4474,29 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep ColumnCustomizationJson = DefaultColumnCustomizationJson, PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.UomCategory), } - ]); + ], autoSave: true); #endregion + + // Sub Forms for UomCategory + await utils.CloneListFormWithFieldsAsync( + _listFormRepository, + _listFormFieldRepository, + ListFormCodes.Lists.UomCategory, + utils.GetFormCodes(ListFormCodes.Lists.UomCategory), + JsonSerializer.Serialize(new List() { + new { + TabTitle = "Uoms", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.Uom, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "UomCategoryId" + } + } + }, + }) + ); } #endregion diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Coordinator.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Coordinator.cs index 80ef55ca..38ff9df9 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Coordinator.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Coordinator.cs @@ -43,136 +43,7 @@ public class ListFormSeeder_Coordinator : IDataSeedContributor, ITransientDepend public async Task SeedAsync(DataSeedContext context) { - #region FormQuestionPool - if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Forms.FormQuestionPool)) - { - var formQuestionPool = await _listFormRepository.InsertAsync( - new ListForm() - { - ListFormType = ListFormTypeEnum.Form, - IsSubForm = false, - LayoutJson = DefaultLayoutJson, - SubFormsJson = JsonSerializer.Serialize(new List() { - new { - TabTitle = "Questions", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.Question, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "QuestionPoolId" - } - } - } - }), - CultureName = LanguageCodes.En, - ListFormCode = ListFormCodes.Forms.FormQuestionPool, - Name = AppCodes.Definitions.QuestionPool, - Title = AppCodes.Definitions.QuestionPool, - DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = true, - IsBranch = false, - IsOrganizationUnit = false, - Description = AppCodes.Definitions.QuestionPool, - SelectCommandType = SelectCommandTypeEnum.Table, - SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.QuestionPool)), - KeyFieldName = "Id", - KeyFieldDbSourceType = DbType.Guid, - 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 = DefaultSelectionSingleJson, - ColumnOptionJson = DefaultColumnOptionJson, - PermissionJson = DefaultPermissionJson(AppCodes.Definitions.QuestionPool), - DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.QuestionPool)), - DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, - PagerOptionJson = DefaultPagerOptionJson, - EditingOptionJson = DefaultEditingOptionJson(AppCodes.Definitions.QuestionPool, 500, 250, true, true, true, true, false), - EditingFormJson = JsonSerializer.Serialize(new List() { - new() { Order=1, ColCount=1, ColSpan=1, ItemType="group", Items=[ - new EditingFormItemDto { Order = 1, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 2, DataField = "Description", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 3, DataField = "Tags", ColSpan = 1, EditorType2=EditorTypes.dxTagBox }, - ]} - }), - InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, - } - ); - - #region Question Pool Fields - await _listFormFieldRepository.InsertManyAsync(new ListFormField[] { - new() { - ListFormCode = formQuestionPool.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "Id", - Width = 100, - ListOrderNo = 1, - Visible = false, - IsActive = true, - IsDeleted = false, - SortIndex = 0, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.QuestionPool), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formQuestionPool.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Name", - Width = 250, - ListOrderNo = 2, - Visible = true, - IsActive = true, - IsDeleted = false, - SortIndex = 1, - SortDirection = GridColumnOptions.SortOrderAsc, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.QuestionPool), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formQuestionPool.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Description", - Width = 400, - ListOrderNo = 3, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.QuestionPool), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formQuestionPool.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Tags", - Width = 100, - ListOrderNo = 4, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.QuestionTag), "Id", "Name"), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.QuestionPool), - PivotSettingsJson = DefaultPivotSettingsJson, - } - }); - #endregion - } - #endregion + using var utils = new SeederUtils(); #region Program if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.Program)) @@ -2167,14 +2038,14 @@ public class ListFormSeeder_Coordinator : IDataSeedContributor, ITransientDepend Text ="Questions", UrlTarget="_blank", AuthName = AppCodes.Definitions.Question, - Url=$"/admin/form/{ListFormCodes.Forms.FormQuestionPool}/@Id" + Url=$"/admin/form/{utils.GetFormCodes(ListFormCodes.Lists.QuestionPool)}/@Id", }, }), - } + }, autoSave: true ); #region Question Pool Fields - await _listFormFieldRepository.InsertManyAsync(new ListFormField[] { + await _listFormFieldRepository.InsertManyAsync([ new() { ListFormCode = listFormQuestionPool.ListFormCode, CultureName = LanguageCodes.En, @@ -2240,8 +2111,29 @@ public class ListFormSeeder_Coordinator : IDataSeedContributor, ITransientDepend PermissionJson = DefaultFieldPermissionJson(AppCodes.Definitions.QuestionPool), PivotSettingsJson = DefaultPivotSettingsJson } - }); + ], autoSave: true); #endregion + + // Sub Forms for Question Pool + await utils.CloneListFormWithFieldsAsync( + _listFormRepository, + _listFormFieldRepository, + ListFormCodes.Lists.QuestionPool, + utils.GetFormCodes(ListFormCodes.Lists.QuestionPool), + JsonSerializer.Serialize(new List() { + new { + TabTitle = "Questions", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.Question, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "QuestionPoolId" + } + } + } + }) + ); } #endregion diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Hr.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Hr.cs index 7389fdd4..d88b30ff 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Hr.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Hr.cs @@ -44,196 +44,7 @@ public class ListFormSeeder_Hr : IDataSeedContributor, ITransientDependency public async Task SeedAsync(DataSeedContext context) { - #region FormSurvey - if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Forms.FormSurvey)) - { - var formSurvey = await _listFormRepository.InsertAsync( - new ListForm() - { - ListFormType = ListFormTypeEnum.Form, - IsSubForm = false, - LayoutJson = DefaultLayoutJson, - SubFormsJson = JsonSerializer.Serialize(new List() { - new { - TabTitle = "Questions", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.SurveyQuestion, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "SurveyId" - } - } - }, - new { - TabTitle = "Responses", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.SurveyResponse, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "SurveyId" - } - } - } - }), - CultureName = LanguageCodes.En, - ListFormCode = ListFormCodes.Forms.FormSurvey, - Name = AppCodes.Hr.Survey, - Title = AppCodes.Hr.Survey, - DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = true, - IsBranch = false, - IsOrganizationUnit = false, - Description = AppCodes.Hr.Survey, - SelectCommandType = SelectCommandTypeEnum.Table, - SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Survey)), - KeyFieldName = "Id", - KeyFieldDbSourceType = DbType.Guid, - 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 = DefaultSelectionSingleJson, - ColumnOptionJson = DefaultColumnOptionJson, - PermissionJson = DefaultPermissionJson(AppCodes.Hr.Survey), - DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.Survey)), - DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, - PagerOptionJson = DefaultPagerOptionJson, - EditingOptionJson = DefaultEditingOptionJson(AppCodes.Hr.Survey, 500, 450, true, true, true, true, false), - InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, - EditingFormJson = JsonSerializer.Serialize(new List() - { - new() { - Order=1, ColCount=1, ColSpan=1, ItemType="group", Items =[ - new EditingFormItemDto { Order = 1, DataField = "Title", ColSpan=1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 2, DataField = "Description", ColSpan=1, IsRequired = true, EditorType2 = EditorTypes.dxTextArea }, - new EditingFormItemDto { Order = 3, DataField = "Deadline", ColSpan=1, IsRequired = true, EditorType2 = EditorTypes.dxDateBox }, - new EditingFormItemDto { Order = 4, DataField = "Status", ColSpan=1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 5, DataField = "IsAnonymous", ColSpan=1, IsRequired = true, EditorType2 = EditorTypes.dxCheckBox }, - ]} - }), - FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] - { - new() { FieldName = "IsAnonymous", FieldDbType = DbType.Boolean, Value = "false", CustomValueType = FieldCustomValueTypeEnum.Value }, - new() { FieldName = "Status", FieldDbType = DbType.String, Value = "draft", CustomValueType = FieldCustomValueTypeEnum.Value } - }), - } - ); - - #region Survey Fields - await _listFormFieldRepository.InsertManyAsync([ - new() { - ListFormCode = formSurvey.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "Id", - Width = 100, - ListOrderNo = 1, - Visible = false, - IsActive = true, - IsDeleted = false, - SortIndex = 0, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formSurvey.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Title", - Width = 200, - ListOrderNo = 2, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formSurvey.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Date, - FieldName = "Deadline", - Width = 100, - ListOrderNo = 3, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formSurvey.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Int32, - FieldName = "Responses", - Width = 100, - ListOrderNo = 4, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formSurvey.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Status", - Width = 100, - ListOrderNo = 5, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.StaticData, - DisplayExpr = "name", - ValueExpr = "key", - LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { - new () { Key= "draft", Name= "Draft" }, - new () { Key= "active", Name= "Active" }, - new () { Key= "closed", Name= "Closed" }, - }), - }), - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new() { - ListFormCode = formSurvey.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Boolean, - FieldName = "IsAnonymous", - Width = 100, - ListOrderNo = 6, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - ]); - #endregion - } - #endregion + using var utils = new SeederUtils(); #region EmploymentType if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.EmploymentType)) @@ -4221,10 +4032,10 @@ public class ListFormSeeder_Hr : IDataSeedContributor, ITransientDependency Text ="Manage", UrlTarget="_blank", AuthName = AppCodes.Hr.Survey + ".Update", - Url="/admin/form/form-survey/@Id" + Url=$"/admin/form/{utils.GetFormCodes(ListFormCodes.Lists.Survey)}/@Id", } }), - } + }, autoSave: true ); #region Survey Fields @@ -4334,8 +4145,41 @@ public class ListFormSeeder_Hr : IDataSeedContributor, ITransientDependency PermissionJson = DefaultFieldPermissionJson(AppCodes.Hr.Survey), PivotSettingsJson = DefaultPivotSettingsJson }, - ]); + ], autoSave: true); #endregion + + // Sub Forms for Survey + await utils.CloneListFormWithFieldsAsync( + _listFormRepository, + _listFormFieldRepository, + ListFormCodes.Lists.Survey, + utils.GetFormCodes(ListFormCodes.Lists.Survey), + JsonSerializer.Serialize(new List() { + new { + TabTitle = "Questions", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.SurveyQuestion, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "SurveyId" + } + } + }, + new { + TabTitle = "Responses", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.SurveyResponse, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "SurveyId" + } + } + } + }) + ); + } #endregion diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Saas.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Saas.cs index 1d5c5322..cef5002a 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Saas.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Saas.cs @@ -46,618 +46,7 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency { var configurationSection = _configuration.GetSection("OpenIddict:Applications"); var swaggerRootUrl = configurationSection["Platform_Swagger:RootUrl"]?.TrimEnd('/'); - - #region FormTenant - if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Forms.FormTenant)) - { - var formTenant = await _listFormRepository.InsertAsync( - new ListForm() - { - ListFormType = ListFormTypeEnum.Form, - IsSubForm = false, - ShowActivity = true, - LayoutJson = DefaultLayoutJson, - SubFormsJson = JsonSerializer.Serialize(new List() { - new { - TabTitle = "Branches", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.Branch, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "TenantId" - } - } - } - }), - CultureName = LanguageCodes.En, - ListFormCode = ListFormCodes.Forms.FormTenant, - Name = TenantManagementPermissions.Tenants.Default, - Title = TenantManagementPermissions.Tenants.Default, - DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = false, - IsBranch = false, - IsOrganizationUnit = false, - Description = TenantManagementPermissions.Tenants.Default, - SelectCommandType = SelectCommandTypeEnum.Table, - SelectCommand = "AbpTenants", - 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 = 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 = DefaultEditingOptionJson(TenantManagementPermissions.Tenants.Default, 800, 800, true, true, true, true, false), - EditingFormJson = JsonSerializer.Serialize(new List() - { - 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 }, - new EditingFormItemDto { Order=4, DataField = "VknTckn", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxNumberBox }, - new EditingFormItemDto { Order=5, DataField = "TaxOffice", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order=6, DataField = "MobileNumber", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxTextBox, EditorOptions=EditorOptionValues.PhoneEditorOptions }, - new EditingFormItemDto { Order=7, DataField = "PhoneNumber", ColSpan=1, IsRequired=false, EditorType2=EditorTypes.dxTextBox, EditorOptions=EditorOptionValues.PhoneEditorOptions }, - new EditingFormItemDto { Order=8, DataField = "FaxNumber", 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 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 }, - new EditingFormItemDto { Order=4, DataField = "Street", ColSpan=1, IsRequired=true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, - new EditingFormItemDto { Order=5, DataField = "PostalCode", ColSpan=1, IsRequired=false, EditorType2=EditorTypes.dxTextBox, EditorOptions=EditorOptionValues.ShowClearButton }, - new EditingFormItemDto { Order=6, DataField = "Address1", ColSpan=1, IsRequired=false, EditorType2=EditorTypes.dxTextBox }, - 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() { - Hint = "Seed", - Text = "Seed", - AuthName = TenantManagementPermissions.Tenants.ManageConnectionStrings, - DialogName = "TenantsConnectionString", - DialogParameters = JsonSerializer.Serialize(new { - name = "@Name", - id = "@Id" - }) - }, - }), - InsertServiceAddress = "list-form-dynamic-api/tenant-insert", - UpdateServiceAddress = "list-form-dynamic-api/tenant-update", - DeleteCommand = "DELETE FROM \"AbpTenants\" WHERE \"Id\"=@Id", - DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { FieldName = "Id", FieldDbType = DbType.Guid, Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey } - }), - FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { FieldName = "IsActive", FieldDbType = DbType.Boolean, Value = "true", CustomValueType = FieldCustomValueTypeEnum.Value }, - new() { FieldName = "Country", FieldDbType = DbType.String, Value = "TR", CustomValueType = FieldCustomValueTypeEnum.Value } - }) - - } - ); - - #region Tenants Fields - await _listFormFieldRepository.InsertManyAsync( - [ - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "Id", - Width = 500, - ListOrderNo = 1, - Visible = false, - IsActive = true, - IsDeleted = false, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Name", - Width = 100, - ListOrderNo = 2, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "OrganizationName", - Width = 200, - ListOrderNo = 3, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Founder", - Width = 200, - ListOrderNo = 4, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Int64, - FieldName = "VknTckn", - Width = 100, - ListOrderNo = 5, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "TaxOffice", - Width = 150, - ListOrderNo = 6, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Country", - Width = 100, - ListOrderNo = 7, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.CountryValues, - CascadeEmptyFields = "City,District,Street" - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "City", - Width = 100, - ListOrderNo = 8, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.CityValues, - CascadeRelationField = "Country", - CascadeFilterOperator="=", - CascadeParentFields = "Country", - CascadeEmptyFields = "District,Street" - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "District", - Width = 100, - ListOrderNo = 9, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.DistrictValues, - CascadeRelationField = "City", - CascadeFilterOperator="=", - CascadeParentFields = "Country,City", - CascadeEmptyFields = "Street", - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Street", - Width = 100, - ListOrderNo = 10, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.StreetValues, - CascadeRelationField = "District", - CascadeFilterOperator="=", - CascadeParentFields = "Country,City,District" - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Address1", - Width = 150, - ListOrderNo = 11, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Address2", - Width = 150, - ListOrderNo = 12, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "PostalCode", - Width = 100, - ListOrderNo = 13, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Email", - Width = 170, - ListOrderNo = 14, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] - { - new ValidationRuleDto() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.email) } - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Website", - Width = 170, - ListOrderNo = 15, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "MobileNumber", - Width = 100, - ListOrderNo = 16, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - EditorOptions = EditorOptionValues.PhoneEditorOptions, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "PhoneNumber", - Width = 100, - ListOrderNo = 17, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - EditorOptions = EditorOptionValues.PhoneEditorOptions, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Int64, - FieldName = "FaxNumber", - Width = 100, - ListOrderNo = 18, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - EditorOptions = EditorOptionValues.PhoneEditorOptions, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - new ListFormField - { - ListFormCode = formTenant.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Boolean, - FieldName = "IsActive", - Width = 100, - ListOrderNo = 19, - Visible = true, - IsActive = true, - IsDeleted = false, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Default), - PivotSettingsJson = DefaultPivotSettingsJson, - }, - ]); - #endregion - - } - #endregion - - #region FormLanguage - if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Forms.FormLanguage)) - { - var formLanguage = await _listFormRepository.InsertAsync( - new ListForm() - { - ListFormType = ListFormTypeEnum.Form, - IsSubForm = false, - ShowActivity = true, - LayoutJson = DefaultLayoutJson, - SubFormsJson = JsonSerializer.Serialize(new List() { - 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, - Name = AppCodes.Languages.Language, - Title = AppCodes.Languages.Language, - DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = false, - IsBranch = false, - IsOrganizationUnit = false, - Description = AppCodes.Languages.Language, - SelectCommandType = SelectCommandTypeEnum.Table, - SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Language)), - KeyFieldName = "Id", - KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = DefaultFilterJson, - SortMode = GridOptions.SortModeSingle, - PermissionJson = DefaultPermissionJson(AppCodes.Languages.Language), - DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.Language)), - DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, - EditingOptionJson = DefaultEditingOptionJson(AppCodes.Languages.Language, 600, 300, true, true, true, true, false), - EditingFormJson = JsonSerializer.Serialize(new List() { - new() { - Order = 1, ColCount = 1, ColSpan = 1, ItemType = "group", Items = - [ - new() { Order = 1, DataField = "CultureName", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new() { Order = 2, DataField = "UiCultureName", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new() { Order = 3, DataField = "DisplayName", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new() { Order = 4, DataField = "IsEnabled", ColSpan = 1, EditorType2=EditorTypes.dxCheckBox }, - ] - } - }), - InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, - FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { FieldName = "IsEnabled", FieldDbType = DbType.Boolean, Value = "true", CustomValueType = FieldCustomValueTypeEnum.Value } - }) - } - ); - - await _listFormFieldRepository.InsertManyAsync([ - new() { - ListFormCode = formLanguage.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "Id", - Width = 100, - ListOrderNo = 0, - Visible = false, - IsActive = true, - IsDeleted = false, - SortIndex = 0, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), - }, - new() { - ListFormCode = formLanguage.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "CultureName", - Width = 150, - ListOrderNo = 1, - Visible = true, - IsActive = true, - IsDeleted = false, - SortIndex = 1, - SortDirection = GridColumnOptions.SortOrderAsc, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), - }, - new() - { - ListFormCode = formLanguage.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "UiCultureName", - Width = 150, - ListOrderNo = 2, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), - }, - new() - { - ListFormCode = formLanguage.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "DisplayName", - Width = 150, - ListOrderNo = 3, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), - }, - new() - { - ListFormCode = formLanguage.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Boolean, - FieldName = "IsEnabled", - Width = 125, - ListOrderNo = 4, - Visible = true, - IsActive = true, - IsDeleted = false, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), - }, - new() - { - ListFormCode = formLanguage.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.DateTime, - FieldName = "CreationTime", - Width = 125, - ListOrderNo = 5, - Visible = true, - IsActive = true, - IsDeleted = false, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), - }, - ]); - } - #endregion + using var utils = new SeederUtils(); #region Tenant if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.Tenant)) @@ -667,6 +56,7 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency { ListFormType = ListFormTypeEnum.List, IsSubForm = false, + ShowActivity = true, LayoutJson = DefaultLayoutJson, CultureName = LanguageCodes.En, ListFormCode = ListFormCodes.Lists.Tenant, @@ -736,7 +126,7 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency Hint = "Branches", Text = "Branches", AuthName = AppCodes.Branches, - Url = "/admin/form/form-tenant/@Id", + Url=$"/admin/form/{utils.GetFormCodes(ListFormCodes.Lists.Tenant)}/@Id", }, }), InsertServiceAddress = "list-form-dynamic-api/tenant-insert", @@ -750,8 +140,7 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency new() { FieldName = "Country", FieldDbType = DbType.String, Value = "TR", CustomValueType = FieldCustomValueTypeEnum.Value } }) - } - ); + }, autoSave: true); #region Tenants Fields await _listFormFieldRepository.InsertManyAsync( @@ -1126,10 +515,31 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency PermissionJson = DefaultFieldPermissionJson(TenantManagementPermissions.Tenants.Create, TenantManagementPermissions.Tenants.Default, TenantManagementPermissions.Tenants.Update, true, true, false), PivotSettingsJson = DefaultPivotSettingsJson }, - ]); + ], autoSave: true); #endregion + // Sub Forms for Tenant + await utils.CloneListFormWithFieldsAsync( + _listFormRepository, + _listFormFieldRepository, + ListFormCodes.Lists.Tenant, + utils.GetFormCodes(ListFormCodes.Lists.Tenant), + JsonSerializer.Serialize(new List() { + new { + TabTitle = "Branches", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.Branch, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "TenantId" + } + } + } } + ) + ); } + #endregion #region Branche @@ -2148,11 +1558,11 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency Text ="Manage", UrlTarget="_blank", AuthName = AppCodes.Languages.LanguageText, - Url=$"/admin/form/{ListFormCodes.Forms.FormLanguage}/@Id" + Url=$"/admin/form/{utils.GetFormCodes(ListFormCodes.Lists.Language)}/@Id" }, }), } - ); + , autoSave: true); #region Language Fields await _listFormFieldRepository.InsertManyAsync([ @@ -2236,9 +1646,29 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency PermissionJson = DefaultFieldPermissionJson(AppCodes.Languages.Language), PivotSettingsJson = DefaultPivotSettingsJson }, - ]); - + ], autoSave: true); #endregion + + // Sub Forms for Tenant + await utils.CloneListFormWithFieldsAsync( + _listFormRepository, + _listFormFieldRepository, + ListFormCodes.Lists.Language, + utils.GetFormCodes(ListFormCodes.Lists.Language), + JsonSerializer.Serialize(new List() { + new { + TabTitle = "Language Texts", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.LanguageText, + Relation = new List() { + new { + ParentFieldName = "CultureName", + ChildFieldName = "CultureName" + } + } + } + }) + ); } #endregion @@ -4126,7 +3556,7 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency EditingOptionJson = DefaultEditingOptionJson(AppCodes.Definitions.ContactTag, 400, 200, true, true, true, true, false), EditingFormJson = JsonSerializer.Serialize(new List { - new() { + new() { Order = 1, ColCount = 1, ColSpan = 1, ItemType = "group", Items = [ new EditingFormItemDto { Order = 1, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_SupplyChain.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_SupplyChain.cs index a6bcc316..afd6eabc 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_SupplyChain.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_SupplyChain.cs @@ -43,695 +43,7 @@ public class ListFormSeeder_SupplyChain : IDataSeedContributor, ITransientDepend public async Task SeedAsync(DataSeedContext context) { - #region FormSupplier - if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Forms.FormSupply)) - { - var listForm = await _listFormRepository.InsertAsync(new ListForm() - { - ListFormType = ListFormTypeEnum.Form, - IsSubForm = false, - ShowActivity = true, - LayoutJson = DefaultLayoutJson, - SubFormsJson = JsonSerializer.Serialize(new List() { - new { - TabTitle = "Banks", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.SupplyBank, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "PartnerId" - } - } - }, - new { - TabTitle = "Certificates", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.SupplyCertificate, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "PartnerId" - } - } - }, - new { - TabTitle = "Contacts", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.Lists.SupplyContact, - Relation = new List() { - new { - ParentFieldName = "Id", - ChildFieldName = "PartnerId" - } - } - } - }), - CultureName = LanguageCodes.En, - ListFormCode = ListFormCodes.Forms.FormSupply, - Name = AppCodes.SupplyChain.Supply, - Title = AppCodes.SupplyChain.Supply, - DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = true, - IsBranch = false, - IsOrganizationUnit = false, - Description = AppCodes.SupplyChain.Supply, - SelectCommandType = SelectCommandTypeEnum.Table, - SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Partner)), - KeyFieldName = "Id", - KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = "\"IsDeleted\" = 'false' AND \"PartyType\" = 'Supplier'", - 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 = DefaultSelectionSingleJson, - ColumnOptionJson = DefaultColumnOptionJson, - PermissionJson = DefaultPermissionJson(AppCodes.SupplyChain.Supply), - DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.Partner)), - DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, - PagerOptionJson = DefaultPagerOptionJson, - EditingOptionJson = DefaultEditingOptionJson(AppCodes.SupplyChain.Supply, 900, 800, true, true, true, true, false), - EditingFormJson = JsonSerializer.Serialize(new List() - { - new() - { - Order = 1, Caption = "General", ColCount = 2, ColSpan = 2, ItemType = "group", Items = - [ - new EditingFormItemDto { Order = 1, DataField = "Code", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 2, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 3, DataField = "PartyType", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 4, DataField = "SectorId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 5, DataField = "TaxNumber", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxNumberBox }, - new EditingFormItemDto { Order = 6, DataField = "TaxOffice", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 7, DataField = "CurrencyId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 8, DataField = "PaymentTermId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 9, DataField = "CreditLimit", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxNumberBox }, - ] - }, - new() - { - Order = 2, Caption = "Address", ColCount = 2, ColSpan = 2, ItemType = "group", Items = - [ - new EditingFormItemDto { Order = 10, DataField = "Country", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 11, DataField = "City", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 12, DataField = "District", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 13, DataField = "Street", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 14, DataField = "Address1", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 15, DataField = "Address2", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 16, DataField = "PostalCode", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 17, DataField = "PhoneNumber", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 18, DataField = "MobileNumber", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 19, DataField = "FaxNumber", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 20, DataField = "Email", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 21, DataField = "Website", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, - ] - }, - new() - { - Order = 3, Caption="Supply Card", ColCount = 2, ColSpan = 2, ItemType = "group", Items = - [ - new EditingFormItemDto { Order = 22, DataField = "SupplierTypeId", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 23, DataField = "SupplyCardTypeId", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox }, - new EditingFormItemDto { Order = 24, DataField = "CardNumber", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 25, DataField = "ValidFrom", ColSpan = 1, EditorType2 = EditorTypes.dxDateBox }, - new EditingFormItemDto { Order = 26, DataField = "ValidTo", ColSpan = 1, EditorType2 = EditorTypes.dxDateBox }, - new EditingFormItemDto { Order = 27, DataField = "CurrentBalance", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox }, - new EditingFormItemDto { Order = 28, DataField = "DiscountRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox }, - new EditingFormItemDto { Order = 29, DataField = "Status", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, - ] - } - }), - InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, - FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] - { - new() { FieldName = "PartyType", FieldDbType = DbType.String, Value = "Supplier", CustomValueType = FieldCustomValueTypeEnum.Value }, - new() { FieldName = "CreditLimit", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, - new() { FieldName = "CurrentBalance", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, - new() { FieldName = "DiscountRate", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, - new() { FieldName = "Status", FieldDbType = DbType.String, Value = "Aktif", CustomValueType = FieldCustomValueTypeEnum.Value }, - new() { FieldName = "Country", FieldDbType = DbType.String, Value = "TR", CustomValueType = FieldCustomValueTypeEnum.Value }, - }) - }); - - await _listFormFieldRepository.InsertManyAsync( - [ - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "Id", - Width = 100, - ListOrderNo = 1, - Visible = false, - IsActive = true, - IsDeleted = false, - SortIndex = 0, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Code", - Width = 140, - ListOrderNo = 2, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Name", - Width = 250, - ListOrderNo = 3, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - SortIndex = 1, - SortDirection = GridColumnOptions.SortOrderAsc, - ValidationRuleJson = DefaultValidationRuleRequiredJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "PartyType", - Width = 100, - ListOrderNo = 4, - Visible = true, - IsActive = true, - IsDeleted = false, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.StaticData, - DisplayExpr = "name", - ValueExpr = "key", - LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { - new() { Key="Customer", Name="Customer" }, - new() { Key="Supplier", Name="Supplier" }, - new() { Key="Both", Name="Both" }, - new() { Key="Other", Name="Other" }, - }), - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "SectorId", - Width = 100, - ListOrderNo = 5, - Visible = true, - IsActive = true, - IsDeleted = false, - LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Sector), "Id", "Name"), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Int64, - FieldName = "TaxNumber", - Width = 100, - ListOrderNo = 6, - Visible = true, - IsActive = true, - IsDeleted = false, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "TaxOffice", - Width = 100, - ListOrderNo = 7, - Visible = true, - IsActive = true, - IsDeleted = false, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "CurrencyId", - Width = 100, - ListOrderNo = 8, - Visible = true, - IsActive = true, - IsDeleted = false, - LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Currency), "Id", "Name"), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "PaymentTermId", - Width = 100, - ListOrderNo = 9, - Visible = true, - IsActive = true, - IsDeleted = false, - LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.PaymentTerm), "Id", "Name"), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() - { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Decimal, - FieldName = "CreditLimit", - Width = 100, - ListOrderNo = 10, - Visible = true, - IsActive = true, - IsDeleted = false, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Country", - Width = 100, - ListOrderNo = 11, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.CountryValues, - CascadeEmptyFields = "City,District,Street" - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "City", - Width = 100, - ListOrderNo = 12, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.CityValues, - CascadeRelationField = "Country", - CascadeFilterOperator="=", - CascadeParentFields = "Country", - CascadeEmptyFields = "District,Street" - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "District", - Width = 100, - ListOrderNo = 13, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.DistrictValues, - CascadeRelationField = "City", - CascadeFilterOperator="=", - CascadeParentFields = "Country,City", - CascadeEmptyFields = "Street", - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Street", - Width = 100, - ListOrderNo = 14, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = LookupQueryValues.StreetValues, - CascadeRelationField = "District", - CascadeFilterOperator="=", - CascadeParentFields = "Country,City,District", - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Address1", - Width = 150, - ListOrderNo = 15, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Address2", - Width = 150, - ListOrderNo = 16, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "PostalCode", - Width = 100, - ListOrderNo = 17, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "PhoneNumber", - Width = 100, - ListOrderNo = 18, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "MobileNumber", - Width = 100, - ListOrderNo = 19, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "FaxNumber", - Width = 100, - ListOrderNo = 20, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Email", - Width = 100, - ListOrderNo = 21, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = DefaultValidationRuleEmailJson, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Website", - Width = 100, - ListOrderNo = 22, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "SupplierTypeId", - Width = 100, - ListOrderNo = 23, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.StaticData, - DisplayExpr = "name", - ValueExpr = "key", - LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { - new() { Key="Manufacturer", Name="Manufacturer" }, - new() { Key="Distributor", Name="Distributor" }, - new() { Key="Wholesaler", Name="Wholesaler" }, - new() { Key="ServiceProvider", Name="ServiceProvider" }, - new() { Key="Other", Name="Other" }, - }), - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "SupplyCardTypeId", - Width = 100, - ListOrderNo = 24, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.StaticData, - DisplayExpr = "name", - ValueExpr = "key", - LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { - new() { Key="Standard", Name="Standard" }, - new() { Key="Premium", Name="Premium" }, - new() { Key="Strategic", Name="Strategic" }, - new() { Key="Preferred", Name="Preferred" }, - }), - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "Status", - Width = 100, - ListOrderNo = 25, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.StaticData, - DisplayExpr = "name", - ValueExpr = "key", - LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { - new() { Key="Prospect", Name="Prospect" }, - new() { Key="Active", Name="Active" }, - new() { Key="Inactive", Name="Inactive" }, - new() { Key="Blocked", Name="Blocked" }, - }), - }), - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "CardNumber", - Width = 100, - ListOrderNo = 26, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Date, - FieldName = "ValidFrom", - Width = 100, - ListOrderNo = 27, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Date, - FieldName = "ValidTo", - Width = 100, - ListOrderNo = 28, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Decimal, - FieldName = "CurrentBalance", - Width = 100, - ListOrderNo = 29, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Decimal, - FieldName = "DiscountRate", - Width = 100, - ListOrderNo = 30, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnCustomizationJson = DefaultColumnCustomizationJson, - PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), - PivotSettingsJson = DefaultPivotSettingsJson - }, - ]); - } - #endregion + using var utils = new SeederUtils(); #region Material Type if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.MaterialType)) @@ -1825,10 +1137,10 @@ public class ListFormSeeder_SupplyChain : IDataSeedContributor, ITransientDepend Text ="Manage", UrlTarget="_blank", AuthName = AppCodes.SupplyChain.Supply, - Url=$"/admin/form/{ListFormCodes.Forms.FormSupply}/@Id" + Url=$"/admin/form/{utils.GetFormCodes(ListFormCodes.Lists.Supply)}/@Id" }, }), - }); + }, autoSave: true); await _listFormFieldRepository.InsertManyAsync( [ @@ -2384,7 +1696,50 @@ public class ListFormSeeder_SupplyChain : IDataSeedContributor, ITransientDepend PermissionJson = DefaultFieldPermissionJson(AppCodes.SupplyChain.Supply), PivotSettingsJson = DefaultPivotSettingsJson }, - ]); + ], autoSave: true); + + // Sub Forms for Supply + await utils.CloneListFormWithFieldsAsync( + _listFormRepository, + _listFormFieldRepository, + ListFormCodes.Lists.Supply, + utils.GetFormCodes(ListFormCodes.Lists.Supply), + JsonSerializer.Serialize(new List() { + new { + TabTitle = "Banks", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.SupplyBank, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "PartnerId" + } + } + }, + new { + TabTitle = "Certificates", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.SupplyCertificate, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "PartnerId" + } + } + }, + new { + TabTitle = "Contacts", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.SupplyContact, + Relation = new List() { + new { + ParentFieldName = "Id", + ChildFieldName = "PartnerId" + } + } + } + }) + ); } #endregion diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/SeederUtils.cs b/api/src/Erp.Platform.DbMigrator/Seeds/SeederUtils.cs new file mode 100644 index 00000000..c44b4e6d --- /dev/null +++ b/api/src/Erp.Platform.DbMigrator/Seeds/SeederUtils.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Erp.Platform.Entities; +using Volo.Abp.Domain.Repositories; + +namespace Erp.Platform.Data.Seeds; + +public class SeederUtils : IDisposable +{ + public async Task CloneListFormWithFieldsAsync( + IRepository listFormRepository, + IRepository listFormFieldRepository, + string sourceListFormCode, + string targetListFormCode, + string subFormsJson = "") + { + // load source form + var sourceForm = await listFormRepository.FirstOrDefaultAsync(f => f.ListFormCode == sourceListFormCode); + if (sourceForm == null) + { + return null!; + } + + // create a shallow copy of the source form and set the target code + var clonedForm = new ListForm + { + ListFormType = sourceForm.ListFormType, + IsSubForm = sourceForm.IsSubForm, + ShowActivity = sourceForm.ShowActivity, + LayoutJson = sourceForm.LayoutJson, + SubFormsJson = subFormsJson ?? sourceForm.SubFormsJson, + CultureName = sourceForm.CultureName, + ListFormCode = targetListFormCode, + Name = sourceForm.Name, + Title = sourceForm.Title, + DataSourceCode = sourceForm.DataSourceCode, + IsTenant = sourceForm.IsTenant, + IsBranch = sourceForm.IsBranch, + IsOrganizationUnit = sourceForm.IsOrganizationUnit, + Description = sourceForm.Description, + SelectCommandType = sourceForm.SelectCommandType, + SelectCommand = sourceForm.SelectCommand, + KeyFieldName = sourceForm.KeyFieldName, + KeyFieldDbSourceType = sourceForm.KeyFieldDbSourceType, + DefaultFilter = sourceForm.DefaultFilter, + SortMode = sourceForm.SortMode, + PermissionJson = sourceForm.PermissionJson, + DeleteCommand = sourceForm.DeleteCommand, + DeleteFieldsDefaultValueJson = sourceForm.DeleteFieldsDefaultValueJson, + EditingOptionJson = sourceForm.EditingOptionJson, + EditingFormJson = sourceForm.EditingFormJson, + InsertFieldsDefaultValueJson = sourceForm.InsertFieldsDefaultValueJson, + FormFieldsDefaultValueJson = sourceForm.FormFieldsDefaultValueJson, + CommandColumnJson = sourceForm.CommandColumnJson, + InsertServiceAddress = sourceForm.InsertServiceAddress, + UpdateServiceAddress = sourceForm.UpdateServiceAddress, + FilterRowJson = sourceForm.FilterRowJson, + HeaderFilterJson = sourceForm.HeaderFilterJson, + SearchPanelJson = sourceForm.SearchPanelJson, + GroupPanelJson = sourceForm.GroupPanelJson, + SelectionJson = sourceForm.SelectionJson, + ColumnOptionJson = sourceForm.ColumnOptionJson, + PagerOptionJson = sourceForm.PagerOptionJson, + }; + + // insert cloned form + var insertedForm = await listFormRepository.InsertAsync(clonedForm); + + // copy fields + var fields = await listFormFieldRepository.GetListAsync(f => f.ListFormCode == sourceListFormCode); + if (fields != null && fields.Count > 0) + { + var clonedFields = new List(); + foreach (var f in fields) + { + var newField = new ListFormField + { + ListFormCode = targetListFormCode, + CultureName = f.CultureName, + SourceDbType = f.SourceDbType, + FieldName = f.FieldName, + Width = f.Width, + ListOrderNo = f.ListOrderNo, + Visible = f.Visible, + IsActive = f.IsActive, + IsDeleted = f.IsDeleted, + AllowSearch = f.AllowSearch, + LookupJson = f.LookupJson, + ColumnCustomizationJson = f.ColumnCustomizationJson, + PermissionJson = f.PermissionJson, + PivotSettingsJson = f.PivotSettingsJson, + ValidationRuleJson = f.ValidationRuleJson, + EditorOptions = f.EditorOptions, + SortIndex = f.SortIndex, + SortDirection = f.SortDirection, + }; + clonedFields.Add(newField); + } + + await listFormFieldRepository.InsertManyAsync(clonedFields); + } + + return insertedForm; + } + + public string GetFormCodes(string listCode) + { + return listCode.Replace("list-", "form-"); + } + + private bool _disposed; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (_disposed) + { + return; + } + + if (disposing) + { + // If the class ever holds disposable fields, dispose them here. + // Currently SeederUtils does not own any IDisposable resources. + } + + _disposed = true; + } +} \ No newline at end of file diff --git a/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs b/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs index b67e19dd..343f9746 100644 --- a/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs +++ b/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs @@ -395,18 +395,7 @@ public static class PlatformConsts public static class ListFormCodes { - public static class Forms - { - public const string FormLanguage = "form-language"; - public const string FormUomCategory = "form-uomcategory"; - public const string FormSkillType = "form-skilltype"; - public const string FormTenant = "form-tenant"; - public const string FormQuestionPool = "form-questionpool"; - public const string FormBank = "form-bank"; - public const string FormSurvey = "form-survey"; - public const string FormSupply = "form-supply"; - } - + //TODO: Lists yerine her birini kendi menüsüne koyabiliriz. public static class Lists { public const string Tenant = "list-tenant";