From b31603554a09dfd28799b81f49b607784cafce68 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Thu, 15 Jan 2026 13:23:08 +0100 Subject: [PATCH] Document: Add IsPreview to indicate that a document may only be viewed by internal staff --- Elwig/Documents/CreditNote.cs | 1 + Elwig/Documents/Document.cs | 11 ++++++----- Elwig/Documents/Document.cshtml | 8 ++++---- Elwig/Documents/PaymentVariantSummary.cs | 1 + Elwig/Helpers/Utils.cs | 14 ++++++++++++++ Elwig/Windows/MailWindow.xaml.cs | 22 +++++++++++++++++----- 6 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Elwig/Documents/CreditNote.cs b/Elwig/Documents/CreditNote.cs index 5c4e357..7893fcf 100644 --- a/Elwig/Documents/CreditNote.cs +++ b/Elwig/Documents/CreditNote.cs @@ -39,6 +39,7 @@ namespace Elwig.Documents { Data = data; Payment = p; Credit = p.Credit; + IsPreview = Payment == null || Credit == null; var season = p.Variant.Season; if (considerCustomModifiers) { CustomPayment = ctx.CustomPayments.Find(p.Year, p.MgNr); diff --git a/Elwig/Documents/Document.cs b/Elwig/Documents/Document.cs index 26a0e29..37e23a1 100644 --- a/Elwig/Documents/Document.cs +++ b/Elwig/Documents/Document.cs @@ -18,10 +18,11 @@ namespace Elwig.Documents { protected string? _pdfPath; protected string? PdfPath => _pdfPath ?? _pdfFile?.FilePath; public int? TotalPages { get; private set; } - public int? Pages => TotalPages / (DoublePaged ? 2 : 1); + public int? Pages => TotalPages / (IsDoublePaged ? 2 : 1); public bool ShowFoldMarks = App.Config.Debug; - public bool DoublePaged = false; + public bool IsDoublePaged = false; + public bool IsPreview = false; public string DocumentsPath; public int CurrentNextSeason; @@ -129,7 +130,7 @@ namespace Elwig.Documents { progress?.Report(GenerationProportion * 100 * i / n); } progress?.Report(GenerationProportion * 100); - var pages = await Pdf.Convert(tmpFiles, pdf.FileName, DoublePaged, new Progress(v => progress?.Report(GenerationProportion * 100 + v * (1 - GenerationProportion)))); + var pages = await Pdf.Convert(tmpFiles, pdf.FileName, IsDoublePaged, new Progress(v => progress?.Report(GenerationProportion * 100 + v * (1 - GenerationProportion)))); TotalPages = pages.Pages; foreach (var tmp in tmpHtmls) { tmp.Dispose(); @@ -140,7 +141,7 @@ namespace Elwig.Documents { using (var tmpHtml = new TempFile("html")) { await File.WriteAllTextAsync(tmpHtml.FilePath, await Render(), Utils.UTF8); progress?.Report(50.0); - var pages = await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath, DoublePaged); + var pages = await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath, IsDoublePaged); TotalPages = pages.Pages; } _pdfFile = pdf; @@ -155,7 +156,7 @@ namespace Elwig.Documents { public async Task Print(int copies = 1) { if (PdfPath == null) throw new InvalidOperationException("Pdf file has not been generated yet"); - await Pdf.Print(PdfPath, copies, DoublePaged); + await Pdf.Print(PdfPath, copies, IsDoublePaged); } public void Show() { diff --git a/Elwig/Documents/Document.cshtml b/Elwig/Documents/Document.cshtml index 0f77c08..bc48103 100644 --- a/Elwig/Documents/Document.cshtml +++ b/Elwig/Documents/Document.cshtml @@ -10,7 +10,7 @@ - @if (Model.DoublePaged) { + @if (Model.IsDoublePaged) {