Item shares form page
This commit is contained in:
parent
986bf27899
commit
9413240165
@ -18,7 +18,9 @@
|
|||||||
<a class="tab-button" onclick="bm_open_tab(this, 'tab-button', 'tab', 'fields')">Fields</a>
|
<a class="tab-button" onclick="bm_open_tab(this, 'tab-button', 'tab', 'fields')">Fields</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<a class="tab-button" onclick="bm_open_tab(this, 'tab-button', 'tab', 'relationsSection')">Relations</a>
|
<a class="tab-button" onclick="bm_open_tab(this, 'tab-button', 'tab', 'relationsSection')">Relations</a>
|
||||||
|
{{ if $fields_present }}
|
||||||
<a class="tab-button" onclick="bm_open_tab(this, 'tab-button', 'tab', 'sharesSection')">Shares</a>
|
<a class="tab-button" onclick="bm_open_tab(this, 'tab-button', 'tab', 'sharesSection')">Shares</a>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="general" class="tab" style="display: block">
|
<div id="general" class="tab" style="display: block">
|
||||||
@ -108,7 +110,7 @@
|
|||||||
{{ if $shares_present }}
|
{{ if $shares_present }}
|
||||||
<div class="tab" id="shares" style="display: none">
|
<div class="tab" id="shares" style="display: none">
|
||||||
<div id="shares">
|
<div id="shares">
|
||||||
{{ template "items:fields" (map "FieldsSection" .item.FieldsSection "FieldsValues" .item.FieldsValues "uisection" "fields")}}
|
{{ template "items:shares"}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
61
assets/templates/items/shares.tmpl
Normal file
61
assets/templates/items/shares.tmpl
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
{{define "item:shares"}}
|
||||||
|
<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="shares-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 }}
|
@ -710,6 +710,7 @@ func (app *application) itemUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
notebooks := strings.Split(strings.Trim(item.Notebooks, "|"), "|")
|
notebooks := strings.Split(strings.Trim(item.Notebooks, "|"), "|")
|
||||||
categories := strings.Split(strings.Trim(item.Categories, "|"), "|")
|
categories := strings.Split(strings.Trim(item.Categories, "|"), "|")
|
||||||
relations, _, _ := itemModel.GetRelations(item.Id)
|
relations, _, _ := itemModel.GetRelations(item.Id)
|
||||||
|
shares, _, _ := itemModel.GetShares(item.Id)
|
||||||
|
|
||||||
data["item"] = itemForm{
|
data["item"] = itemForm{
|
||||||
Id: item.Id,
|
Id: item.Id,
|
||||||
@ -728,6 +729,7 @@ func (app *application) itemUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
Categories: categories,
|
Categories: categories,
|
||||||
Notebooks: notebooks,
|
Notebooks: notebooks,
|
||||||
Relations: relations,
|
Relations: relations,
|
||||||
|
Shares: shares,
|
||||||
}
|
}
|
||||||
|
|
||||||
data["categories"] = categoryModel.AllAsOptions()
|
data["categories"] = categoryModel.AllAsOptions()
|
||||||
|
Loading…
Reference in New Issue
Block a user