62 lines
2.6 KiB
Cheetah
62 lines
2.6 KiB
Cheetah
{{define "item:relations"}}
|
|
<table class="table-all striped responsive">
|
|
<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}}
|
|
{{ $relation_name := printf "%s%v-%v" "ItemRelation-" .Item_id .Related_item_id }}
|
|
{{ $relation_name_remove := printf "%s%v-%v" "ItemRelation-ToRemove-" .Item_id .Related_item_id }}
|
|
<tr id="{{$relation_name}}-Row">
|
|
<td class="no-label {{$relation_name}}-Col">
|
|
{{ $target_id := .Related_item_id}}
|
|
{{ $relation_type := .Relation_type }}
|
|
{{ if eq .Related_item_id $.item.Id }}
|
|
{{ $target_id = .Item_id}}
|
|
{{ if eq "Parent" .Relation_type}}
|
|
{{ $relation_type = "Child" }}
|
|
{{ else if eq "Child" .Relation_type}}
|
|
{{ $relation_type = "Parent" }}
|
|
{{ end }}
|
|
{{ end }}
|
|
<a href="/item/view/{{$target_id}}" hx-get="/item/view/{{$target_id}}" hx-target="body" hx-swap="beforeend"><i class="{{.Type_icon}}" title="{{.Type_title}}"></i> {{.Title}}</a>
|
|
<input type="hidden" id="{{$relation_name_remove}}" name="{{$relation_name_remove}}" value=""/>
|
|
</td>
|
|
<td class="no-label {{$relation_name}}-Col">
|
|
{{ if gt (len .Categories) 0 }}
|
|
<i class="hide-medium hide-large bi bi-tags-fill"></i>
|
|
{{ range (stringToArray .Categories "|")}}
|
|
{{ $category_name := index $.categoriesMap .}}
|
|
<div class="tag" style="padding: 3px">
|
|
{{ $category_name }}
|
|
</div>
|
|
{{ end }}
|
|
{{ end }}
|
|
</td>
|
|
<td class="no-label {{$relation_name}}-Col">
|
|
{{ if gt (len .Tags) 0 }}
|
|
<i class="hide-medium hide-large bi bi-tags"></i>
|
|
{{ range (stringToArray .Tags ",")}}
|
|
<div class="tag" style="padding: 3px">
|
|
{{ . }}
|
|
</div>
|
|
{{ end }}
|
|
{{ end }}
|
|
</td>
|
|
<td class="no-label {{$relation_name}}-Col">{{ widget_relation_type $relation_name $relation_type `id="$relation_name"` }}</td>
|
|
<td class="no-label">
|
|
<button id="Delete-{{$relation_name}}" class="delete" type="button" onclick="bm_item_relation_delete(this, {{$relation_name}}, {{$relation_name_remove}})"><i class="bi bi-x-square" title="Remove"></i><span>Remove</span></button>
|
|
<button id="Undelete-{{$relation_name}}" style="margin-right: 5px;" class="delete" type="button" onclick="bm_item_relation_undelete(this, {{$relation_name}}, {{$relation_name_remove}})" hidden><i class="bi bi-arrow-counterclockwise" title="Undo"></i><span>Undo</span></button>
|
|
</td>
|
|
</tr>
|
|
{{ end }}
|
|
</tbody>
|
|
</table>
|
|
{{ end }}
|