From ec438afab545bd4c8613157aff7e0baf12288618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Tue, 16 Jun 2026 15:54:01 +0300 Subject: [PATCH] =?UTF-8?q?ReportCategory=20ve=20ReportTemplate=20aras?= =?UTF-8?q?=C4=B1ndaki=20ba=C4=9Flant=C4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Seeds/ListFormSeeder_Administration.cs | 10 +-- .../Administration/Report/ReportCategory.cs | 7 +- .../Administration/Report/ReportTemplate.cs | 8 ++- .../EntityFrameworkCore/PlatformDbContext.cs | 14 ++-- ....cs => 20260616123136_Initial.Designer.cs} | 15 ++-- ...0_Initial.cs => 20260616123136_Initial.cs} | 6 +- .../PlatformDbContextModelSnapshot.cs | 13 ++-- .../Seeds/TenantData.json | 15 ++-- .../Seeds/TenantDataSeeder.cs | 6 +- .../DynamicListFormReport.cs | 6 +- .../views/report/DevexpressReportViewer.tsx | 68 +++++++++++++++++-- 11 files changed, 121 insertions(+), 47 deletions(-) rename api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/{20260615110840_Initial.Designer.cs => 20260616123136_Initial.Designer.cs} (99%) rename api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/{20260615110840_Initial.cs => 20260616123136_Initial.cs} (99%) diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs b/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs index 7220b59..e39e2f1 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs @@ -1443,8 +1443,8 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep ]} }), DeleteCommand = $"UPDATE \"{FullNameTable(TableNameEnum.ReportCategory)}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", - DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson(), - InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson(), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson(DbType.String), + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson(DbType.String, "Name"), }); #region Report Categories Fields @@ -1586,7 +1586,7 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep AuthName = listFormName, Url=$"/admin/reports/TemplateReport/view?id=@Id", IsVisible = true, - VisibleExpression = "((e)=> e.row.data.Description !== 'Liste Raporları')" + VisibleExpression = "((e)=> e.row.data.CategoryId !== 'Listeler')" }, new() { Hint = "App.Platform.Design", @@ -1595,7 +1595,7 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep AuthName = listFormName + ".Update", Url=$"/admin/reports/TemplateReport/design?id=@Id", IsVisible = true, - VisibleExpression = "((e)=> e.row.data.Description !== 'Liste Raporları')" + VisibleExpression = "((e)=> e.row.data.CategoryId !== 'Listeler')" }, new() { Hint = "App.Platform.View", @@ -1604,7 +1604,7 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep AuthName = listFormName, Url=$"/admin/reports/DynamicListFormReport/view?listFormCode=@Name", IsVisible = true, - VisibleExpression = "((e)=> e.row.data.Description !== 'Liste Raporları')" + VisibleExpression = "((e)=> e.row.data.CategoryId === 'Listeler')" }, }), } diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Report/ReportCategory.cs b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Report/ReportCategory.cs index e134cd0..a2f2ff7 100644 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Report/ReportCategory.cs +++ b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Report/ReportCategory.cs @@ -5,7 +5,7 @@ using Volo.Abp.MultiTenancy; namespace Sozsoft.Platform.Entities { - public class ReportCategory : FullAuditedEntity, IMultiTenant + public class ReportCategory : FullAuditedEntity, IMultiTenant { public Guid? TenantId { get; set; } @@ -14,6 +14,11 @@ namespace Sozsoft.Platform.Entities public string Icon { get; set; } public ICollection ReportTemplates { get; set; } + + public ReportCategory(string id) + { + Id = id; + } } } diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Report/ReportTemplate.cs b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Report/ReportTemplate.cs index d6278c4..6031383 100644 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Report/ReportTemplate.cs +++ b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Report/ReportTemplate.cs @@ -11,17 +11,19 @@ namespace Sozsoft.Platform.Entities public string Name { get; set; } public string Description { get; set; } public string HtmlContent { get; set; } - public Guid CategoryId { get; set; } + + public string CategoryId { get; set; } + public ReportCategory ReportCategory { get; set; } + public string Status { get; set; } - public ReportCategory ReportCategory { get; set; } public ReportTemplate( Guid id, string name, string description, string htmlContent, - Guid categoryId, + string categoryId, string status ) : base(id) { diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs index f1e7b4b..755706a 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs @@ -648,17 +648,12 @@ public class PlatformDbContext : b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.ReportCategory)), Prefix.DbSchema); b.ConfigureByConvention(); + b.Property(x => x.Id).HasMaxLength(256); b.Property(x => x.Name).IsRequired().HasMaxLength(256); b.Property(x => x.Description).HasMaxLength(4096); // JSON string b.Property(x => x.Icon).HasMaxLength(64); b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); - - b.HasMany(x => x.ReportTemplates) - .WithOne(x => x.ReportCategory) - .HasForeignKey(x => x.CategoryId) - .HasPrincipalKey(c => c.Id) - .OnDelete(DeleteBehavior.Cascade); }); builder.Entity(b => @@ -667,11 +662,18 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(x => x.Name).IsRequired().HasMaxLength(256); + b.Property(x => x.CategoryId).HasMaxLength(256); b.Property(x => x.Description).HasMaxLength(1024); b.Property(x => x.HtmlContent).IsRequired(); b.Property(x => x.Status).HasMaxLength(20); b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); + + b.HasOne(x => x.ReportCategory) + .WithMany(x => x.ReportTemplates) + .HasPrincipalKey(x => x.Id) + .HasForeignKey(x => x.CategoryId) + .OnDelete(DeleteBehavior.Restrict); }); //Administration diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260615110840_Initial.Designer.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260616123136_Initial.Designer.cs similarity index 99% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260615110840_Initial.Designer.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260616123136_Initial.Designer.cs index da3fe50..6ef80b1 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260615110840_Initial.Designer.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260616123136_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Sozsoft.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20260615110840_Initial")] + [Migration("20260616123136_Initial")] partial class Initial { /// @@ -4289,8 +4289,9 @@ namespace Sozsoft.Platform.Migrations modelBuilder.Entity("Sozsoft.Platform.Entities.ReportCategory", b => { - b.Property("Id") - .HasColumnType("uniqueidentifier"); + b.Property("Id") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("CreationTime") .HasColumnType("datetime2") @@ -4353,8 +4354,9 @@ namespace Sozsoft.Platform.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); + b.Property("CategoryId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("CreationTime") .HasColumnType("datetime2") @@ -8586,8 +8588,7 @@ namespace Sozsoft.Platform.Migrations b.HasOne("Sozsoft.Platform.Entities.ReportCategory", "ReportCategory") .WithMany("ReportTemplates") .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .OnDelete(DeleteBehavior.Restrict); b.Navigation("ReportCategory"); }); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260615110840_Initial.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260616123136_Initial.cs similarity index 99% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260615110840_Initial.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260616123136_Initial.cs index 8ffba73..8d249e1 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260615110840_Initial.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260616123136_Initial.cs @@ -651,7 +651,7 @@ namespace Sozsoft.Platform.Migrations name: "Adm_T_ReportCategory", columns: table => new { - Id = table.Column(type: "uniqueidentifier", nullable: false), + Id = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), TenantId = table.Column(type: "uniqueidentifier", nullable: true), Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), Description = table.Column(type: "nvarchar(max)", maxLength: 4096, nullable: true), @@ -2244,7 +2244,7 @@ namespace Sozsoft.Platform.Migrations Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), Description = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true), HtmlContent = table.Column(type: "nvarchar(max)", nullable: false), - CategoryId = table.Column(type: "uniqueidentifier", nullable: false), + CategoryId = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), Status = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), CreationTime = table.Column(type: "datetime2", nullable: false), CreatorId = table.Column(type: "uniqueidentifier", nullable: true), @@ -2262,7 +2262,7 @@ namespace Sozsoft.Platform.Migrations column: x => x.CategoryId, principalTable: "Adm_T_ReportCategory", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index e36709a..5c326e1 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -4286,8 +4286,9 @@ namespace Sozsoft.Platform.Migrations modelBuilder.Entity("Sozsoft.Platform.Entities.ReportCategory", b => { - b.Property("Id") - .HasColumnType("uniqueidentifier"); + b.Property("Id") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("CreationTime") .HasColumnType("datetime2") @@ -4350,8 +4351,9 @@ namespace Sozsoft.Platform.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); + b.Property("CategoryId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("CreationTime") .HasColumnType("datetime2") @@ -8583,8 +8585,7 @@ namespace Sozsoft.Platform.Migrations b.HasOne("Sozsoft.Platform.Entities.ReportCategory", "ReportCategory") .WithMany("ReportTemplates") .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .OnDelete(DeleteBehavior.Restrict); b.Navigation("ReportCategory"); }); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json index 8ad2e37..0845426 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json @@ -1362,20 +1362,25 @@ } ], "ReportCategories": [ - { - "name": "Genel Raporlar", - "description": "Şirket içi genel tüm raporlar", - "icon": "📊" - }, { "name": "Taahhütnameler", "description": "Kursiyeler ile ilgili taahhütname raporları", "icon": "✍️" }, + { + "name": "Raporlar", + "description": "Şirket içi genel tüm raporlar", + "icon": "📊" + }, { "name": "Listeler", "description": "Tüm listelerin raporları", "icon": "📜" + }, + { + "name": "Formlar", + "description": "Tüm single formların raporları", + "icon": "📜" } ], "ReportTemplates": [ diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs index 2d06abd..9d099ac 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs @@ -490,7 +490,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency private readonly IRepository _globalSearch; private readonly IRepository _customEndpointRepository; private readonly IRepository _customComponentRepository; - private readonly IRepository _reportCategoriesRepository; + private readonly IRepository _reportCategoriesRepository; private readonly IRepository _reportTemplatesRepository; private readonly IRepository _homeRepository; private readonly IRepository _aboutRepository; @@ -547,7 +547,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency IRepository skillLevelRepository, IRepository customEndpointRepository, IRepository customComponentRepository, - IRepository reportCategoriesRepository, + IRepository reportCategoriesRepository, IRepository reportTemplatesRepository, IRepository homeRepository, IRepository aboutRepository, @@ -865,7 +865,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency if (!exists) { - await _reportCategoriesRepository.InsertAsync(new ReportCategory + await _reportCategoriesRepository.InsertAsync(new ReportCategory(item.Name) { Name = item.Name, Description = item.Description, diff --git a/api/src/Sozsoft.Platform.HttpApi.Host/PredefinedReports/DynamicListFormReport.cs b/api/src/Sozsoft.Platform.HttpApi.Host/PredefinedReports/DynamicListFormReport.cs index bbf7f62..5d367b3 100644 --- a/api/src/Sozsoft.Platform.HttpApi.Host/PredefinedReports/DynamicListFormReport.cs +++ b/api/src/Sozsoft.Platform.HttpApi.Host/PredefinedReports/DynamicListFormReport.cs @@ -224,7 +224,7 @@ public class DynamicListFormReport : XtraReport var topMargin = new TopMarginBand { HeightF = Margins.Top }; var bottomMargin = new BottomMarginBand { HeightF = 32 }; - var reportHeader = new ReportHeaderBand { HeightF = 42 }; + var reportHeader = new ReportHeaderBand { HeightF = 32 }; var pageHeader = new PageHeaderBand { HeightF = 28 }; var detail = new DetailBand { HeightF = 24 }; var reportFooter = new ReportFooterBand { HeightF = HasAnySummary(fields) ? 28 : 0 }; @@ -244,11 +244,11 @@ public class DynamicListFormReport : XtraReport { PageInfo = PageInfo.DateTime, TextFormatString = "{0:dd.MM.yyyy HH:mm}", - BoundsF = new System.Drawing.RectangleF(0, 30, pageWidth / 2, 12), + BoundsF = new System.Drawing.RectangleF(0, 0, pageWidth / 2, 18), Font = new DXFont("Arial", 7.5F), TextAlignment = TextAlignment.MiddleLeft }; - reportHeader.Controls.Add(generatedAt); + bottomMargin.Controls.Add(generatedAt); var pageInfo = new XRPageInfo { diff --git a/ui/src/views/report/DevexpressReportViewer.tsx b/ui/src/views/report/DevexpressReportViewer.tsx index 7ef5c17..d6e3c64 100644 --- a/ui/src/views/report/DevexpressReportViewer.tsx +++ b/ui/src/views/report/DevexpressReportViewer.tsx @@ -8,12 +8,29 @@ import ReportViewer, { } from 'devexpress-reporting-react/dx-report-viewer' import { ajaxSetup } from '@devexpress/analytics-core/analytics-utils-native' import { APP_NAME } from '@/constants/app.constant' +import { MODE_DARK } from '@/constants/theme.constant' import { useStoreState } from '@/store' -const loadViewerCss = () => { +const VIEWER_THEME_LINK_ID = 'devexpress-report-viewer-theme' +const VIEWER_DARK_OVERRIDES_ID = 'devexpress-report-viewer-dark-overrides' + +const getViewerClassName = (isDarkMode: boolean) => + [ + 'dx-viewport', + 'dx-device-desktop', + 'dx-device-generic', + 'dx-theme-generic', + 'dx-theme-generic-typography', + isDarkMode ? 'dx-color-scheme-dark' : 'dx-color-scheme-light', + 'report-viewer-shell', + isDarkMode ? 'report-viewer-shell-dark' : '', + ] + .filter(Boolean) + .join(' ') + +const loadViewerCss = (isDarkMode: boolean) => { const styles = [ new URL('@devexpress/analytics-core/dist/css/dx-analytics.common.css', import.meta.url).href, - new URL('@devexpress/analytics-core/dist/css/dx-analytics.light.css', import.meta.url).href, new URL('devexpress-reporting/dist/css/dx-webdocumentviewer.css', import.meta.url).href, ] @@ -24,6 +41,45 @@ const loadViewerCss = () => { link.href = href document.head.appendChild(link) }) + + const themeHref = isDarkMode + ? new URL('@devexpress/analytics-core/dist/css/dx-analytics.dark.css', import.meta.url).href + : new URL('@devexpress/analytics-core/dist/css/dx-analytics.light.css', import.meta.url).href + + let themeLink = document.getElementById(VIEWER_THEME_LINK_ID) as HTMLLinkElement | null + if (!themeLink) { + themeLink = document.createElement('link') + themeLink.id = VIEWER_THEME_LINK_ID + themeLink.rel = 'stylesheet' + document.head.appendChild(themeLink) + } + if (themeLink.href !== themeHref) { + themeLink.href = themeHref + } + + if (!document.getElementById(VIEWER_DARK_OVERRIDES_ID)) { + const style = document.createElement('style') + style.id = VIEWER_DARK_OVERRIDES_ID + style.textContent = ` + .report-viewer-shell { + min-height: calc(100vh - 4rem); + } + + .report-viewer-shell-dark { + background: #111827; + color: #e5e7eb; + } + + .report-viewer-shell-dark .dxrd-preview, + .report-viewer-shell-dark .dxrd-preview-wrapper, + .report-viewer-shell-dark .dxrd-toolbar-wrapper, + .report-viewer-shell-dark .dxrd-right-panel, + .report-viewer-shell-dark .dxrd-search-wrapper { + background-color: #111827; + } + ` + document.head.appendChild(style) + } } const DevexpressReportViewer: React.FC = () => { @@ -31,11 +87,13 @@ const DevexpressReportViewer: React.FC = () => { const { id } = useParams<{ id: string }>() const location = useLocation() const token = useStoreState((state) => state.auth.session.token) + const themeMode = useStoreState((state) => state.theme.mode) const [isRequestAuthReady, setIsRequestAuthReady] = useState(false) + const isDarkMode = themeMode === MODE_DARK useEffect(() => { - loadViewerCss() - }, []) + loadViewerCss(isDarkMode) + }, [isDarkMode]) useEffect(() => { setIsRequestAuthReady(false) @@ -65,7 +123,7 @@ const DevexpressReportViewer: React.FC = () => { if (!id) return null return ( - +