Skip to content

Commit

Permalink
Merge pull request #104 from mraron/issue101-no-tags
Browse files Browse the repository at this point in the history
Put tags in <details> on the problem page by default
  • Loading branch information
mraron authored Jun 13, 2024
2 parents a3b09d5 + 127abf7 commit 0a7c1b9
Show file tree
Hide file tree
Showing 3 changed files with 257 additions and 228 deletions.
7 changes: 4 additions & 3 deletions internal/web/handlers/problemset/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func GetProblem(tags njudge.Tags) echo.HandlerFunc {
Title: title,
Problemset: prob.Problemset,
Name: name,
ShowTags: true,
ShowTags: false,
Tags: prob.Tags.ToTags(),
TaskTypeName: storedData.GetTaskType().Name(),
Languages: storedData.Languages(),
Expand Down Expand Up @@ -84,9 +84,10 @@ func GetProblem(tags njudge.Tags) echo.HandlerFunc {
if info.UserInfo != nil {
if info.UserInfo.SolvedStatus == njudge.Solved {
vm.CanAddTags = true
vm.ShowTags = true
} else {
if u := c.Get("user").(*njudge.User); u != nil && !u.Settings.ShowUnsolvedTags {
vm.ShowTags = false
if u := c.Get("user").(*njudge.User); u != nil && u.Settings.ShowUnsolvedTags {
vm.ShowTags = true
}
}
}
Expand Down
26 changes: 16 additions & 10 deletions internal/web/templates/problem.templ
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,14 @@ templ tagListProblem(tags []njudge.Tag, add bool) {
</span>
&#32;
}
if add {
<span class="badge badge-secondary">
<a href="#" class="text-reset text-decoration-none" data-toggle="modal" data-target="#tagModal">+</a>
</span>
}
}


templ problemInfoCard(vm ProblemViewModel) {
<div class="card">
<div class="card-header">
Expand All @@ -116,17 +122,17 @@ templ problemInfoCard(vm ProblemViewModel) {
<div class="col-6">{Tr(ctx, "Memory limit")}:</div>
<div class="col-6">{memMiB(vm.MemoryLimit)} MiB</div>
}
if vm.ShowTags {
<div class="col-6">{Tr(ctx, "Tags")}:</div>
<div class="col-6">
<div class="col-6">{Tr(ctx, "Tags")}:</div>
<div class="col-6">
if !vm.ShowTags {
<details>
<summary>{Tr(ctx, "show")}</summary>
@tagListProblem(vm.Tags, vm.CanAddTags)
</details>
}else {
@tagListProblem(vm.Tags, vm.CanAddTags)
if vm.CanAddTags {
<span class="badge badge-secondary">
<a href="#" class="text-reset text-decoration-none" data-toggle="modal" data-target="#tagModal">+</a>
</span>
}
</div>
}
}
</div>
<div class="col-6">{Tr(ctx, "Task type")}:</div>
<div class="col-6">{vm.TaskTypeName}</div>
</div>
Expand Down
Loading

0 comments on commit 0a7c1b9

Please sign in to comment.