Skip to content

Commit 871107a

Browse files
authored
Feature/plot print (#3049)
* Добавить режим распечатки к элементу вводной * Прятать футер на распечатке
1 parent 16e6c29 commit 871107a

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

src/JoinRpg.Portal/Controllers/PlotController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ await plotService.PublishElementVersion(
353353
}
354354

355355
[HttpGet, MasterAuthorize()]
356-
public async Task<ActionResult> ShowElementVersion(int projectId, int plotFolderId, int plotElementId, int version)
356+
public async Task<ActionResult> ShowElementVersion(int projectId, int plotFolderId, int plotElementId, int version, bool printMode)
357357
{
358358
var folder = await plotRepository.GetPlotFolderAsync(projectId, plotFolderId);
359359
if (folder == null)
@@ -363,7 +363,7 @@ public async Task<ActionResult> ShowElementVersion(int projectId, int plotFolder
363363
var projectInfo = await projectMetadataRepository.GetProjectMetadata(new(projectId));
364364
return View(new PlotElementListItemViewModel(folder.Elements.Single(e => e.PlotElementId == plotElementId),
365365
CurrentUserId,
366-
uriService, projectInfo, version));
366+
uriService, projectInfo, version, printMode));
367367
}
368368

369369
}

src/JoinRpg.Portal/Views/Plot/EditElementPartial.cshtml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
{
66
return;
77
}
8+
9+
@if (Model.PrintMode)
10+
{
11+
@Model.Content
12+
@if (string.IsNullOrWhiteSpace(Model.Content.ToHtmlString()))
13+
{
14+
<i>Вводная пуста</i>
15+
}
16+
17+
return;
18+
}
819
<div class="panel panel-default">
920
<div class="panel-heading">
1021

@@ -91,6 +102,18 @@
91102
@Html.DisplayFor(model => model.PrevModifiedDateTime)
92103
</a>
93104
}
105+
<a
106+
asp-action="ShowElementVersion"
107+
asp-controller="Plot"
108+
asp-route-ProjectId="@Model.ProjectId"
109+
asp-route-PlotFolderId="@Model.PlotFolderId"
110+
asp-route-PlotElementId="@Model.PlotElementId"
111+
asp-route-Version="@Model.CurrentVersion"
112+
asp-route-PrintMode="true"
113+
class="btn btn-default btn-sm">
114+
<span class="glyphicon glyphicon-print"></span>
115+
Печать
116+
</a>
94117
if (Model.NextModifiedDateTime == null)
95118
{
96119
<a class="btn btn-default btn-sm"

src/JoinRpg.Portal/Views/Plot/ShowElementVersion.cshtml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
ViewBag.PlotElementUncollapse = Model.PlotElementId;
66
}
77

8+
@if (!Model.PrintMode){
89

10+
<h2>@ViewBag.Title</h2>
911

10-
<h2>@ViewBag.Title</h2>
11-
12-
@Html.ActionLink("Назад к сюжету", "Edit", new {Model.ProjectId, Model.PlotFolderId}, null)
12+
@Html.ActionLink("Назад к сюжету", "Edit", new {Model.ProjectId, Model.PlotFolderId}, null)
13+
}
1314
@await Html.PartialAsync("EditElementPartial", Model)

src/JoinRpg.Portal/wwwroot/css/site.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,3 +441,10 @@ hr.list-divider {
441441
.validation-message {
442442
color: #a94442;
443443
}
444+
445+
@media print
446+
{
447+
footer {
448+
visibility:collapse
449+
}
450+
}

src/JoinRpg.WebPortal.Models/Plot/EditPlotFolderViewModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public EditPlotElementViewModel(PlotElement e, bool hasManageAccess, IUriService
111111
public class PlotElementListItemViewModel : IProjectIdAware
112112
{
113113

114-
public PlotElementListItemViewModel(PlotElement e, int? currentUserId, IUriService uriService, ProjectInfo projectInfo, int? currentVersion = null)
114+
public PlotElementListItemViewModel(PlotElement e, int? currentUserId, IUriService uriService, ProjectInfo projectInfo, int? currentVersion = null, bool printMode = false)
115115
{
116116
CurrentVersion = currentVersion ?? e.LastVersion().Version;
117117

@@ -146,6 +146,7 @@ public PlotElementListItemViewModel(PlotElement e, int? currentUserId, IUriServi
146146
PlotFolderMasterTitle = e.PlotFolder.MasterTitle;
147147

148148
PublishedVersion = e.Published;
149+
PrintMode = printMode;
149150
}
150151

151152
[ReadOnly(true)]
@@ -189,5 +190,7 @@ public PlotElementListItemViewModel(PlotElement e, int? currentUserId, IUriServi
189190
public int? PublishedVersion { get; }
190191
public string PlotFolderMasterTitle { get; }
191192

193+
public bool PrintMode { get; }
194+
192195
public bool ThisPublished => CurrentVersion == PublishedVersion;
193196
}

0 commit comments

Comments
 (0)