2024-08-22 10:13:16 +02:00
|
|
|
{{define "item:relations"}}
|
2024-12-26 21:09:09 +01:00
|
|
|
<table class="table-all striped responsive">
|
2024-08-22 10:13:16 +02:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Item</th>
|
|
|
|
<th>Categories</th>
|
|
|
|
<th>Tags</th>
|
|
|
|
<th>Relation type</th>
|
|
|
|
<th></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="relations-items">
|
|
|
|
{{ range .item.Relations}}
|
2025-02-28 17:50:41 +01:00
|
|
|
{{ $relationName := printf "%s%v-%v" "ItemRelation-" .ItemId .RelatedItemId }}
|
|
|
|
{{ $relationNameRemove := printf "%s%v-%v" "ItemRelation-ToRemove-" .ItemId .RelatedItemId }}
|
|
|
|
<tr id="{{$relationName}}-Row">
|
|
|
|
<td class="no-label {{$relationName}}-Col">
|
|
|
|
{{ $targetId := .RelatedItemId}}
|
|
|
|
{{ $relationType := .RelationType }}
|
|
|
|
{{ if eq .RelatedItemId $.item.Id }}
|
|
|
|
{{ $targetId = .ItemId}}
|
|
|
|
{{ if eq "Parent" .RelationType}}
|
|
|
|
{{ $relationType = "Child" }}
|
|
|
|
{{ else if eq "Child" .RelationType}}
|
|
|
|
{{ $relationType = "Parent" }}
|
2024-08-22 10:13:16 +02:00
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
2025-02-28 17:50:41 +01:00
|
|
|
<a href="/item/view/{{$targetId}}" hx-get="/item/view/{{$targetId}}" hx-target="body" hx-swap="beforeend"><i class="{{.TypeIcon}}" title="{{.TypeTitle}}"></i> {{.Title}}</a>
|
|
|
|
<input type="hidden" id="{{$relationNameRemove}}" name="{{$relationNameRemove}}" value=""/>
|
2024-08-22 10:13:16 +02:00
|
|
|
</td>
|
2025-02-28 17:50:41 +01:00
|
|
|
<td class="no-label {{$relationName}}-Col">
|
2024-08-22 10:13:16 +02:00
|
|
|
{{ if gt (len .Categories) 0 }}
|
2024-11-10 20:52:32 +01:00
|
|
|
<i class="hide-medium hide-large bi bi-tags-fill"></i>
|
2024-08-22 10:13:16 +02:00
|
|
|
{{ range (stringToArray .Categories "|")}}
|
|
|
|
{{ $category_name := index $.categoriesMap .}}
|
2024-12-26 21:09:09 +01:00
|
|
|
<div class="tag" style="padding: 3px">
|
2024-08-22 10:13:16 +02:00
|
|
|
{{ $category_name }}
|
|
|
|
</div>
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
</td>
|
2025-02-28 17:50:41 +01:00
|
|
|
<td class="no-label {{$relationName}}-Col">
|
2024-08-22 10:13:16 +02:00
|
|
|
{{ if gt (len .Tags) 0 }}
|
2024-11-10 20:52:32 +01:00
|
|
|
<i class="hide-medium hide-large bi bi-tags"></i>
|
2024-08-22 10:13:16 +02:00
|
|
|
{{ range (stringToArray .Tags ",")}}
|
|
|
|
<div class="tag" style="padding: 3px">
|
|
|
|
{{ . }}
|
|
|
|
</div>
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
</td>
|
2025-02-28 17:50:41 +01:00
|
|
|
<td class="no-label {{$relationName}}-Col">{{ widget_relation_type $relationName $relationType `id="$relation_name"` }}</td>
|
2024-08-22 10:13:16 +02:00
|
|
|
<td class="no-label">
|
2025-02-28 17:50:41 +01:00
|
|
|
<button id="Delete-{{$relationName}}" class="delete" type="button" onclick="bm_element_list_delete(this, {{$relationName}}, {{$relationNameRemove}})"><i class="bi bi-x-square" title="Remove"></i><span>Remove</span></button>
|
|
|
|
<button id="Undelete-{{$relationName}}" style="margin-right: 5px;" class="delete" type="button" onclick="bm_element_list_undelete(this, {{$relationName}}, {{$relationNameRemove}})" hidden><i class="bi bi-arrow-counterclockwise" title="Undo"></i><span>Undo</span></button>
|
2024-08-22 10:13:16 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{{ end }}
|