The tree and main panels now behave like a native file manager: right click (or the keyboard Menu key) on a folder, asset, breadcrumb crumb, or empty tree/panel background brings up the relevant actions instead of a row of always-visible buttons. - New generic showContextMenu() in app.js with per-target-kind menu builders (folder/asset/tree background/panel background), gated by admin role the same way the old buttons were. - Removed: the "..." tree-row action button, and the New Folder/Add Asset/Rename/Delete/Edit/Move/Duplicate/Import/Export buttons from the inventory toolbar and every panel. Expand All/Collapse All shrank to two icon-only buttons next to the search box; everything else creation- or mutation-related is right-click only. - Replaced the per-asset embedded "Move" modal with one shared #moveAssetModal populated via a new GET /app/folders/options endpoint, since move can now be triggered from any asset row, not just its own detail view. - Breadcrumb crumbs (including the current folder) and folder/asset table rows are now valid right-click targets too, not just tree rows.
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package web
|
|
|
|
import "context"
|
|
|
|
// FolderOption is a flattened, indented folder choice for <select> dropdowns
|
|
// (asset create/edit, move-to pickers).
|
|
type FolderOption struct {
|
|
ID int64 `json:"id"`
|
|
Path string `json:"path"`
|
|
Depth int `json:"depth"`
|
|
}
|
|
|
|
// folderOptions returns every folder as a flat, depth-first ordered list
|
|
// with indentable depth, suitable for a folder-picker <select>.
|
|
func (a *App) folderOptions(ctx context.Context) ([]FolderOption, error) {
|
|
all, err := a.Folders.All(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
byParent := map[int64][]struct {
|
|
ID int64
|
|
Name string
|
|
}{}
|
|
var top []struct {
|
|
ID int64
|
|
Name string
|
|
}
|
|
for _, f := range all {
|
|
item := struct {
|
|
ID int64
|
|
Name string
|
|
}{f.ID, f.Name}
|
|
if f.ParentID == nil {
|
|
top = append(top, item)
|
|
} else {
|
|
byParent[*f.ParentID] = append(byParent[*f.ParentID], item)
|
|
}
|
|
}
|
|
|
|
var out []FolderOption
|
|
var walk func(id int64, name, prefix string, depth int)
|
|
walk = func(id int64, name, prefix string, depth int) {
|
|
path := name
|
|
if prefix != "" {
|
|
path = prefix + " / " + name
|
|
}
|
|
out = append(out, FolderOption{ID: id, Path: path, Depth: depth})
|
|
for _, child := range byParent[id] {
|
|
walk(child.ID, child.Name, path, depth+1)
|
|
}
|
|
}
|
|
for _, t := range top {
|
|
walk(t.ID, t.Name, "", 0)
|
|
}
|
|
return out, nil
|
|
}
|