196 lines
10 KiB
Plaintext
196 lines
10 KiB
Plaintext
@using Helpdesk.Web.Api
|
||
@model IssueDetailViewModel
|
||
@{
|
||
var issue = Model.Issue;
|
||
ViewData["Title"] = $"Závada #{issue.Id}";
|
||
var transitions = Model.Transitions.ToList();
|
||
var canAssign = Model.Can(IssueActions.Assign);
|
||
}
|
||
|
||
<section class="app-page-head">
|
||
<a asp-action="Index" class="app-back-link">Moje hlášení</a>
|
||
<span class="app-issue-id d-block mt-2">Hlášení #@issue.Id</span>
|
||
<div class="d-flex flex-wrap align-items-center gap-3">
|
||
<h1 class="mb-0">@issue.Title</h1>
|
||
<partial name="_StatusBadge" model="new StatusBadgeModel(issue.Status)" />
|
||
</div>
|
||
</section>
|
||
|
||
<div class="row g-4">
|
||
<div class="col-lg-8 d-grid gap-4 align-content-start">
|
||
<section class="app-card" aria-labelledby="udaje">
|
||
<h2 id="udaje" class="visually-hidden">Údaje hlášení</h2>
|
||
<dl class="app-facts">
|
||
<dt>Kategorie</dt>
|
||
<dd>@Model.CategoryName</dd>
|
||
<dt>Místo</dt>
|
||
<dd>@(Model.Location ?? "Neuvedeno")</dd>
|
||
<dt>Nahlásil/a</dt>
|
||
<dd>@Model.ReporterName</dd>
|
||
<dt>Řešitel</dt>
|
||
<dd>@(Model.AssigneeName ?? "Zatím nepřiřazen")</dd>
|
||
<dt>Priorita</dt>
|
||
<dd>@IssuePriorities.Label(issue.Priority)</dd>
|
||
<dt>Nahlášeno</dt>
|
||
<dd><time datetime="@issue.CreatedAt.ToString("O")">@DisplayTime.Format(issue.CreatedAt)</time></dd>
|
||
</dl>
|
||
<h3 class="h6 fw-bold">Popis</h3>
|
||
<p class="app-text mb-0">@issue.Description</p>
|
||
@if (Model.Can(IssueActions.Edit))
|
||
{
|
||
<a asp-action="Edit" asp-route-id="@issue.Id" class="btn btn-outline-primary btn-sm mt-3">Upravit hlášení</a>
|
||
}
|
||
</section>
|
||
|
||
<section class="app-card" id="prilohy" aria-labelledby="prilohy-nadpis">
|
||
<h2 id="prilohy-nadpis" class="h5 fw-bold">Přílohy</h2>
|
||
@if (issue.Attachments.Count == 0)
|
||
{
|
||
<p class="text-body-secondary">Bez příloh.</p>
|
||
}
|
||
else
|
||
{
|
||
<ul class="app-attachments">
|
||
@foreach (var file in issue.Attachments)
|
||
{
|
||
var opens = IssueDetailViewModel.OpensInBrowser(file.ContentType);
|
||
<li>
|
||
<a asp-action="Attachment" asp-route-attachmentId="@file.Id"
|
||
target="@(opens ? "_blank" : null)" rel="@(opens ? "noopener" : null)">@file.FileName</a>
|
||
<span class="text-body-secondary">@IssueDetailViewModel.FileSize(file.SizeBytes)</span>
|
||
</li>
|
||
}
|
||
</ul>
|
||
}
|
||
@if (Model.Can(IssueActions.AddAttachments))
|
||
{
|
||
<form method="post" asp-action="Attachments" asp-route-id="@issue.Id" enctype="multipart/form-data" class="mt-3">
|
||
<label for="files" class="form-label">Doplnit fotografie nebo soubory</label>
|
||
<div class="d-flex flex-wrap gap-2">
|
||
<input id="files" name="Files" type="file" class="form-control w-auto flex-grow-1" multiple required
|
||
accept="@AttachmentRules.Accept" aria-describedby="filesHelp" />
|
||
<button type="submit" class="btn btn-outline-primary">Nahrát</button>
|
||
</div>
|
||
<div id="filesHelp" class="form-text">Nejvýše @AttachmentRules.MaxFiles souborů po 10 MB – JPG, PNG, HEIC, PDF nebo DOCX.</div>
|
||
</form>
|
||
}
|
||
</section>
|
||
|
||
<section class="app-card" id="prubeh" aria-labelledby="prubeh-nadpis">
|
||
<h2 id="prubeh-nadpis" class="h5 fw-bold mb-3">Průběh řešení a komentáře</h2>
|
||
<ol class="app-timeline">
|
||
@foreach (var entry in Model.Timeline)
|
||
{
|
||
<li class="app-timeline-item @(entry.IsComment ? "is-comment" : "")">
|
||
<div class="app-timeline-head">
|
||
<span><strong>@entry.Event.ActorName</strong> @entry.Text</span>
|
||
<time datetime="@entry.Event.OccurredAt.ToString("O")">@DisplayTime.Format(entry.Event.OccurredAt)</time>
|
||
</div>
|
||
@if (entry.IsComment)
|
||
{
|
||
<p class="app-comment app-text">@entry.Note</p>
|
||
}
|
||
else if (!string.IsNullOrWhiteSpace(entry.Note))
|
||
{
|
||
<p class="app-timeline-note">
|
||
@if (entry.NoteLabel is not null)
|
||
{
|
||
<strong>@entry.NoteLabel:</strong>
|
||
}
|
||
<span class="app-text">@entry.Note</span>
|
||
</p>
|
||
}
|
||
@if (entry.Status is not null)
|
||
{
|
||
<partial name="_StatusBadge" model="new StatusBadgeModel(entry.Status)" />
|
||
}
|
||
</li>
|
||
}
|
||
</ol>
|
||
|
||
@if (Model.Can(IssueActions.Comment))
|
||
{
|
||
<form method="post" asp-action="Comment" asp-route-id="@issue.Id" id="komentar" class="mt-4">
|
||
<label for="comment" class="form-label">Napsat komentář</label>
|
||
<textarea id="comment" name="Text" class="form-control" rows="3" required maxlength="@IssueActionForm.MaxTextLength"
|
||
placeholder="Doplňující informace, dotaz na řešitele nebo hlásiče…"></textarea>
|
||
<button type="submit" class="btn btn-primary mt-2">Odeslat komentář</button>
|
||
</form>
|
||
}
|
||
else if (Model.IsClosed)
|
||
{
|
||
<p class="text-body-secondary mt-3 mb-0">Závada je uzavřená, komentáře už nejde přidávat.</p>
|
||
}
|
||
</section>
|
||
</div>
|
||
|
||
<aside class="col-lg-4">
|
||
<section class="app-card app-next-step" aria-labelledby="dalsi-krok">
|
||
<h2 id="dalsi-krok" class="h5 fw-bold">Další krok</h2>
|
||
@if (transitions.Count == 0 && !canAssign)
|
||
{
|
||
<p class="text-body-secondary mb-0">@Model.NextStepText</p>
|
||
}
|
||
|
||
@foreach (var action in transitions)
|
||
{
|
||
var primary = action is IssueActions.StartWork or IssueActions.SubmitForVerification or IssueActions.Confirm;
|
||
var buttonClass = primary ? "btn-primary" : action == IssueActions.Reject ? "btn-outline-danger" : "btn-outline-primary";
|
||
|
||
if (!IssueActions.AcceptsText(action))
|
||
{
|
||
<form method="post" asp-action="Transition" asp-route-id="@issue.Id">
|
||
<input type="hidden" name="Action" value="@action" />
|
||
<input type="hidden" name="RowVersion" value="@issue.RowVersion" />
|
||
<button type="submit" class="btn @buttonClass w-100">@IssueActions.Label(action)</button>
|
||
</form>
|
||
}
|
||
else
|
||
{
|
||
var required = IssueActions.RequiresReason(action);
|
||
var textId = $"text-{action.ToLowerInvariant()}";
|
||
@* <details> rozbalí formulář s důvodem bez JavaScriptu (CSP nepovoluje inline skripty). *@
|
||
<details class="app-action">
|
||
<summary class="btn @buttonClass w-100">@IssueActions.Label(action)…</summary>
|
||
<form method="post" asp-action="Transition" asp-route-id="@issue.Id" class="app-action-form">
|
||
<input type="hidden" name="Action" value="@action" />
|
||
<input type="hidden" name="RowVersion" value="@issue.RowVersion" />
|
||
<label for="@textId" class="form-label">@(required ? "Důvod" : "Poznámka pro hlásiče (nepovinná)")</label>
|
||
<textarea id="@textId" name="Text" class="form-control" rows="3" maxlength="@IssueActionForm.MaxTextLength"
|
||
required="@required"></textarea>
|
||
<button type="submit" class="btn @buttonClass mt-2">@IssueActions.Label(action)</button>
|
||
</form>
|
||
</details>
|
||
}
|
||
}
|
||
|
||
@if (canAssign)
|
||
{
|
||
<form method="post" asp-action="Assign" asp-route-id="@issue.Id" class="app-assign @(transitions.Count > 0 ? "mt-3 pt-3 border-top" : "")">
|
||
<input type="hidden" name="RowVersion" value="@issue.RowVersion" />
|
||
<div class="mb-2">
|
||
<label for="assignee" class="form-label">@(issue.AssigneeId is null ? "Přiřadit řešiteli" : "Přeřadit na jiného řešitele")</label>
|
||
<select id="assignee" name="AssigneeId" class="form-select" required>
|
||
<option value="">Vyberte řešitele</option>
|
||
@foreach (var person in Model.OtherAssignees)
|
||
{
|
||
<option value="@person.Id">@person.FullName (@UserRoles.DisplayName(person.Role).ToLowerInvariant(), otevřené: @person.OpenIssues)</option>
|
||
}
|
||
</select>
|
||
</div>
|
||
<div class="mb-2">
|
||
<label for="priority" class="form-label">Priorita</label>
|
||
<select id="priority" name="Priority" class="form-select">
|
||
@foreach (var priority in IssuePriorities.All)
|
||
{
|
||
<option value="@priority" selected="@(priority == issue.Priority)">@IssuePriorities.Label(priority)</option>
|
||
}
|
||
</select>
|
||
</div>
|
||
<button type="submit" class="btn btn-primary w-100">@(issue.AssigneeId is null ? "Přiřadit" : "Přeřadit")</button>
|
||
</form>
|
||
}
|
||
</section>
|
||
</aside>
|
||
</div>
|