BrainMinder/assets/templates/items/form.tmpl

143 lines
6.0 KiB
Cheetah
Raw Normal View History

2024-08-22 10:13:16 +02:00
{{ define "page:content" }}
{{ $fields_present := false }}
{{ if (gt (len (index .item.FieldsSection "fields")) 0) }}
{{ $fields_present = true }}
{{ end }}
2024-10-20 20:25:59 +02:00
<form method="POST" hx-post="{{.formAction}}" hx-target="{{.formTarget}}">
<div class="page-container">
<div class="tab-bar">
<a class="active tab-button" onclick="bm_open_tab(this, 'tab-button', 'tab', 'general')">General</a>
2024-08-22 10:13:16 +02:00
{{ if $fields_present }}
2024-10-20 20:25:59 +02:00
<a class="tab-button" onclick="bm_open_tab(this, 'tab-button', 'tab', 'fields')">Fields</a>
2024-08-22 10:13:16 +02:00
{{ end }}
2024-10-20 20:25:59 +02:00
<a class="tab-button" onclick="bm_open_tab(this, 'tab-button', 'tab', 'relationsSection')">Relations</a>
2024-08-22 10:13:16 +02:00
</div>
<div id="general" class="tab" style="display: block">
2024-11-21 18:14:12 +01:00
<div class="row">
<div class="col half">
2024-08-22 10:13:16 +02:00
<p>
<label for="item-title">Title</label>
2024-10-20 20:25:59 +02:00
<input name="Title" id="item-title" type="text" value="{{.item.Title}}" />
2024-08-22 10:13:16 +02:00
</p>
<p>
{{ widget_select "Type_id" "Type" .item.Type_id .types `style="width: 100%"` }}
2024-08-22 10:13:16 +02:00
</p>
</div>
2024-11-21 18:14:12 +01:00
<div class="col half">
2024-08-22 10:13:16 +02:00
<p>
{{ widget_checkboxes "Notebooks" "Notebooks" .item.Notebooks .notebooks `` }}
2024-08-22 10:13:16 +02:00
</p>
</div>
</div>
<div id="fields-general">
{{ template "items:fields" (map "FieldsSection" .item.FieldsSection "FieldsValues" .item.FieldsValues "uisection" "general")}}
</div>
{{ if eq .item.Type_show_summary 1}}
<p>
<label for="item-summary">Summary</label>
<textarea name="Summary" id="item-summary" type="text" rows="5">{{.item.Summary}}</textarea>
2024-08-22 10:13:16 +02:00
</p>
{{ end }}
{{ if eq .item.Type_show_description 1}}
<p>
<label for="item-description">Description</label>
2024-11-17 20:12:20 +01:00
<textarea name="Description" class=" w3-border" id="item-description" rows="10">{{.item.Description}}</textarea>
2024-08-22 10:13:16 +02:00
</p>
{{ end }}
2024-11-21 18:14:12 +01:00
<div class="row">
<div class="col half">
2024-08-22 10:13:16 +02:00
<p>
<label for="item-tags">Tags</label>
2024-10-20 20:25:59 +02:00
<input name="Tags" id="item-tags" type="text" value="{{.item.Tags}}" />
2024-08-22 10:13:16 +02:00
</p>
</div>
2024-11-21 18:14:12 +01:00
<div class="col half">
2024-08-22 10:13:16 +02:00
<p>
{{ widget_slim_select "Categories" "Categories" .item.Categories .categories `multiple="true"` }}
2024-08-22 10:13:16 +02:00
</p>
</div>
</div>
<p>
2024-10-20 20:25:59 +02:00
<label class="switch">
<input id="on_dashboard" name="On_dashboard" type="checkbox" value="1" {{if eq .item.On_dashboard 1}} checked="checked" {{end}} />
2024-10-20 20:25:59 +02:00
<span class="slider round"></span>
</label>
2024-10-20 20:25:59 +02:00
<label for="on_dashboard" class="label-checkbox">On dashboard</label>
2024-08-22 10:13:16 +02:00
</p>
</div>
{{ if $fields_present }}
2024-10-25 18:08:01 +02:00
<div class="tab" id="fields" style="display: none">
2024-08-22 10:13:16 +02:00
<div id="fields-fields">
{{ template "items:fields" (map "FieldsSection" .item.FieldsSection "FieldsValues" .item.FieldsValues "uisection" "fields")}}
</div>
</div>
{{ end }}
2024-10-25 18:08:01 +02:00
<div class="tab" id="relationsSection" style="display: none">
2024-08-22 10:13:16 +02:00
<fieldset class="w3-round-medium" style="margin-top: 10px;">
<legend>Related items</legend>
<div id="relations" style="margin-top: 8px;">
{{ template "item:relations" . }}
</div>
</fieldset>
<fieldset class="w3-round-medium" style="margin-top: 8px;">
<legend>Add items</legend>
2024-11-21 18:14:12 +01:00
<div class="row">
<div class="col l6 m9 s10">
2024-10-20 20:25:59 +02:00
<input id="search-item-relation" name="SearchText" type="text" value="" placeholder="Search" hx-get="/items/search-for-relations/{{.item.Id}}" hx-trigger="search-item-relation, keyup changed delay:1s" hx-vals="js:{SearchText: document.getElementById('search-item-relation').value}" hx-target="#items-list-for-relations"
2024-08-22 10:13:16 +02:00
/>
</div>
2024-11-21 18:14:12 +01:00
<div class="col l6 m3 s1" style="padding-left: 10px;">
<a class="button main" hx-vals="js:{SearchText: document.getElementById('search-item-relation').value}" hx-target="#items-list-for-relations" hx-get="/items/search-for-relations/{{.item.Id}}"><i class="bi bi-search"></i><span class="hide-small"> Find</span></a>
2024-08-22 10:13:16 +02:00
</div>
</div>
<div id="items-list-for-relations" style="margin-top:10px">
</div>
</fieldset>
</div>
</div>
2024-11-10 20:52:32 +01:00
<p class="hide-small w3-container">
2024-11-21 18:14:12 +01:00
<button class="main">
2024-08-22 10:13:16 +02:00
<i class="bi bi-floppy"></i> Save
</button>
{{ if not (eq .item.Id 0) }}
2024-11-21 18:14:12 +01:00
<a class="button secondary" href="/item/read/{{.item.Id}}" hx-get="/item/read/{{.item.Id}}" hx-push-url="true" hx-target="#page-content"><i class="bi bi-binoculars"></i> View</a>
<a class="button delete" hx-delete="/item/delete/{{.item.Id}}" hx-target="#page-content" hx-trigger="confirmed" onClick="bm_show_confirm(this, 'Items', 'Delete this item ?')"><i class="bi bi-trash"></i> Delete</a>
<a class="button secondary" href="#" hx-target="#modal-container" hx-get="/item/share/{{.item.Id}}" title="Share"><i class="bi bi-share-fill"></i> Share</a>
2024-08-22 10:13:16 +02:00
{{ end }}
2024-11-21 18:14:12 +01:00
<a class="button secondary" hx-target="#page-content" hx-push-url="true" hx-get="/items/type/{{.item.Type_id}}"><i class="bi bi-arrow-left-circle"></i> Back</a>
2024-08-22 10:13:16 +02:00
</p>
2024-11-21 18:14:12 +01:00
<div id="footer-navbar-container">
<div id="footer-navbar" class="bar hide-medium hide-large">
<div class="bar-item">
<button type="submit" class="main" title="Save">
2024-08-22 10:13:16 +02:00
<i class="bi bi-floppy"></i>
</button>
</div>
{{ if not (eq .item.Id 0) }}
2024-11-21 18:14:12 +01:00
<div class="bar-item">
<a class="button delete" hx-delete="/item/delete/{{.item.Id}}" hx-target="#page-content" hx-trigger="confirmed" onClick="bm_show_confirm(this, 'Items', 'Delete this item ?')" title="Delete"><i class="bi bi-trash"></i>
2024-08-22 10:13:16 +02:00
</a>
</div>
2024-11-21 18:14:12 +01:00
<div class="bar-item">
<a class="button secondary" href="#" hx-target="#modal-container" hx-get="/item/share/{{.item.Id}}" title="Share"><i class="bi bi-share-fill"></i></a>
2024-08-22 10:13:16 +02:00
</div>
2024-11-21 18:14:12 +01:00
<div class="bar-item">
<a class="button secondary" href="/item/read/{{.item.Id}}" hx-get="/item/read/{{.item.Id}}" hx-push-url="true" hx-target="#page-content" title="View"><i class="bi bi-binoculars"></i>
2024-08-22 10:13:16 +02:00
</a>
</div>
{{ end }}
</div>
</div>
</form>
{{ end }}