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}}
{{ $ 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 }}
2024-12-26 21:09:09 +01:00
<a href="/item/view/{{ $ target_id }}" hx-get="/item/view/{{ $ target_id }}" hx-target=" #modal - container " ><i class= " { { . Type_icon } } " title= " { { . Type_title } } " ></i> {{ .Title}}</a>
<input type="hidden" id="{{ $ relation_name_remove }}" name="{{ $ relation_name_remove }}" value=""/>
2024-08-22 10:13:16 +02:00
</td>
<td class="no-label {{ $ relation_name }}-Col">
{{ 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>
<td class="no-label {{ $ relation_name }}-Col">
{{ 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>
2024-11-17 20:12:20 +01:00
<td class="no-label {{ $ relation_name }}-Col">{{ widget_relation_type $ relation_name $ relation_type `id=" $ relation_name " class=" w3-border"` }}</td>
2024-08-22 10:13:16 +02:00
<td class="no-label">
2024-12-26 21:09:09 +01:00
<div class="bar">
<button id="Delete-{{ $ relation_name }}" class="delete" type="button"
2024-08-22 10:13:16 +02:00
_="on click set {value: '1'} on #{{ $ relation_name_remove }} then hide me then show #Undelete - { { $ relation_name } } then add . w3 - opacity - max to . { { $ relation_name } } - Col "
>
2024-11-10 20:52:32 +01:00
<i class="bi bi-x-square" title="Remove"></i><span class="hide-small"> Remove</span>
2024-08-22 10:13:16 +02:00
</button>
2024-12-26 21:09:09 +01:00
<button id="Undelete-{{ $ relation_name }}" style="margin-right: 5px; display: none" class="delete" type="button"
2024-08-22 10:13:16 +02:00
_="on click set {value: ''} on #{{ $ relation_name_remove }} then hide me then show #Delete - { { $ relation_name } } then remove . w3 - opacity - max from . { { $ relation_name } } - Col "
>
2024-11-10 20:52:32 +01:00
<i class="bi bi-arrow-counterclockwise" title="Undo"></i><span class="hide-small"> Undo</span>
2024-08-22 10:13:16 +02:00
</button>
</div>
</td>
</tr>
{{ end }}
</tbody>
</table>
{{ end }}