Statuses import, an icon picker, folder-scoped CSV import, and site name
- Statuses can now be bulk-imported/updated via CSV (Name, Color columns; matches and updates existing statuses by name). New internal/statuses/csv.go, tested. - Icon fields (folder create/rename, item type form) are now a searchable dropdown of the 50 most common Bootstrap Icons instead of a free-text box, via a small reusable .icon-picker widget in app.js/app.css. - CSV asset import is now folder-scoped when triggered from the tree: right-click a folder (or its background) > Import CSV... imports every row directly into that folder, so the CSV needs no Folder column at all, and the option no longer appears at the top level. The original global, Folder-path-aware import (with auto-create-missing-folders) moved to a new admin-only Settings > Import / Export page, alongside the new Statuses import and format examples for both. assets.Import gained ImportOptions.TargetFolderID to drive the folder-scoped mode. - Site Name (Settings > General) now actually renders in the navbar brand and <title>, via a per-App "siteName" template func bound in loadTemplates. The brand is plain text now, not a link to /inventory.
This commit is contained in:
+17
-3
@@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
@@ -94,8 +95,21 @@ type templateSet struct {
|
||||
// each page can define a block named "content" without colliding with the
|
||||
// others (html/template templates sharing one *template.Template must have
|
||||
// unique names, but isolated clones may reuse the same name freely).
|
||||
func loadTemplates() (*templateSet, error) {
|
||||
shared := template.New("root").Funcs(templateFuncs)
|
||||
func loadTemplates(a *App) (*templateSet, error) {
|
||||
// siteName is bound per-App (rather than living in the package-level
|
||||
// templateFuncs) since it needs a live DB read through a.Settings; it's
|
||||
// used by layout.html for the <title> and navbar brand text.
|
||||
appFuncs := template.FuncMap{
|
||||
"siteName": func() string {
|
||||
name, err := a.Settings.Get(context.Background(), "site_name", "inventree")
|
||||
if err != nil || name == "" {
|
||||
return "inventree"
|
||||
}
|
||||
return name
|
||||
},
|
||||
}
|
||||
|
||||
shared := template.New("root").Funcs(templateFuncs).Funcs(appFuncs)
|
||||
|
||||
shared, err := shared.ParseFS(content.TemplatesFS, "templates/layout.html")
|
||||
if err != nil {
|
||||
@@ -124,7 +138,7 @@ func loadTemplates() (*templateSet, error) {
|
||||
pages[name] = clone
|
||||
}
|
||||
|
||||
login := template.New("login-root").Funcs(templateFuncs)
|
||||
login := template.New("login-root").Funcs(templateFuncs).Funcs(appFuncs)
|
||||
login, err = login.ParseFS(content.TemplatesFS, "templates/login.html")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse login: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user