diff --git a/assets/templates/items/form.tmpl b/assets/templates/items/form.tmpl
index 4f1a79c..c0b04f3 100644
--- a/assets/templates/items/form.tmpl
+++ b/assets/templates/items/form.tmpl
@@ -18,7 +18,9 @@
Fields
{{ end }}
Relations
+ {{ if $fields_present }}
Shares
+ {{ end }}
@@ -108,7 +110,7 @@
{{ if $shares_present }}
- {{ template "items:fields" (map "FieldsSection" .item.FieldsSection "FieldsValues" .item.FieldsValues "uisection" "fields")}}
+ {{ template "items:shares"}}
{{ end }}
diff --git a/assets/templates/items/shares.tmpl b/assets/templates/items/shares.tmpl
new file mode 100644
index 0000000..cec6e95
--- /dev/null
+++ b/assets/templates/items/shares.tmpl
@@ -0,0 +1,61 @@
+{{define "item:shares"}}
+
+
+
+ Item |
+ Categories |
+ Tags |
+ Relation type |
+ |
+
+
+
+{{ 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 }}
+
+
+ {{ $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 }}
+ {{.Title}}
+
+ |
+
+ {{ if gt (len .Categories) 0 }}
+
+ {{ range (stringToArray .Categories "|")}}
+ {{ $category_name := index $.categoriesMap .}}
+
+ {{ $category_name }}
+
+ {{ end }}
+ {{ end }}
+ |
+
+ {{ if gt (len .Tags) 0 }}
+
+ {{ range (stringToArray .Tags ",")}}
+
+ {{ . }}
+
+ {{ end }}
+ {{ end }}
+ |
+ {{ widget_relation_type $relation_name $relation_type `id="$relation_name"` }} |
+
+
+
+ |
+
+ {{ end }}
+
+
+ {{ end }}
diff --git a/cmd/web/items_handlers.go b/cmd/web/items_handlers.go
index 5686a1b..3517813 100644
--- a/cmd/web/items_handlers.go
+++ b/cmd/web/items_handlers.go
@@ -710,6 +710,7 @@ func (app *application) itemUpdate(w http.ResponseWriter, r *http.Request) {
notebooks := strings.Split(strings.Trim(item.Notebooks, "|"), "|")
categories := strings.Split(strings.Trim(item.Categories, "|"), "|")
relations, _, _ := itemModel.GetRelations(item.Id)
+ shares, _, _ := itemModel.GetShares(item.Id)
data["item"] = itemForm{
Id: item.Id,
@@ -728,6 +729,7 @@ func (app *application) itemUpdate(w http.ResponseWriter, r *http.Request) {
Categories: categories,
Notebooks: notebooks,
Relations: relations,
+ Shares: shares,
}
data["categories"] = categoryModel.AllAsOptions()