fix(apps): data-url onclick for tiles

This commit is contained in:
Claus Lohmar 2026-06-15 19:41:27 +00:00
parent 29782180d9
commit 445c49e77c
2 changed files with 27 additions and 31 deletions

View file

@ -22,19 +22,19 @@ func DefaultApps(role string) []AppTile {
},
{
Name: "Files", Description: "Storage & sharing",
URL: "#", Color: "#2563eb",
URL: "/files", Color: "#2563eb",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>`,
Status: "coming-soon",
},
{
Name: "Mail", Description: "Email client",
URL: "#", Color: "#dc2626",
URL: "/mail", Color: "#dc2626",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></svg>`,
Status: "coming-soon",
},
{
Name: "Calendar", Description: "Schedule & events",
URL: "#", Color: "#059669",
URL: "/calendar", Color: "#059669",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>`,
Status: "coming-soon",
},
@ -64,19 +64,19 @@ func DefaultApps(role string) []AppTile {
},
{
Name: "Contacts", Description: "People & directory",
URL: "#", Color: "#d97706",
URL: "/contacts", Color: "#d97706",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>`,
Status: "coming-soon",
},
{
Name: "Tasks", Description: "Project management",
URL: "#", Color: "#7c3aed",
URL: "/tasks", Color: "#7c3aed",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"/></svg>`,
Status: "coming-soon",
},
{
Name: "Chat", Description: "Team messaging",
URL: "#", Color: "#db2777",
URL: "/chat", Color: "#db2777",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/></svg>`,
Status: "coming-soon",
},
@ -102,8 +102,8 @@ templ AppGrid(apps []AppTile) {
}
templ appTile(a AppTile) {
if a.Status == "coming-soon" {
<div class="app-card disabled"
if a.URL == "#" || a.URL == "" {
<div class="app-card disabled">
oncontextmenu="return false"
ontouchstart="startLongPress(event)" ontouchend="cancelLongPress()"
onmousedown="startLongPress(event)" onmouseup="cancelLongPress()">
@ -112,11 +112,7 @@ templ appTile(a AppTile) {
<div class="app-badge">Coming Soon</div>
</div>
} else {
<div class="app-card" data-url={ a.URL }
onclick="openApp.call(this)"
oncontextmenu="return false"
ontouchstart="startLongPress(event)" ontouchend="cancelLongPress()"
onmousedown="startLongPress(event)" onmouseup="cancelLongPress()">
<div class="app-card" onclick={ "window.location.href='" + a.URL + "'" } oncontextmenu="return false">
<div class="app-icon" style={ "background:" + a.Color }>@templ.Raw(a.Icon)</div>
<div class="app-name">{ a.Name }</div>
<div class="app-badge">Available</div>

View file

@ -30,19 +30,19 @@ func DefaultApps(role string) []AppTile {
},
{
Name: "Files", Description: "Storage & sharing",
URL: "#", Color: "#2563eb",
URL: "/files", Color: "#2563eb",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>`,
Status: "coming-soon",
},
{
Name: "Mail", Description: "Email client",
URL: "#", Color: "#dc2626",
URL: "/mail", Color: "#dc2626",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></svg>`,
Status: "coming-soon",
},
{
Name: "Calendar", Description: "Schedule & events",
URL: "#", Color: "#059669",
URL: "/calendar", Color: "#059669",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>`,
Status: "coming-soon",
},
@ -72,19 +72,19 @@ func DefaultApps(role string) []AppTile {
},
{
Name: "Contacts", Description: "People & directory",
URL: "#", Color: "#d97706",
URL: "/contacts", Color: "#d97706",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>`,
Status: "coming-soon",
},
{
Name: "Tasks", Description: "Project management",
URL: "#", Color: "#7c3aed",
URL: "/tasks", Color: "#7c3aed",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"/></svg>`,
Status: "coming-soon",
},
{
Name: "Chat", Description: "Team messaging",
URL: "#", Color: "#db2777",
URL: "/chat", Color: "#db2777",
Icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/></svg>`,
Status: "coming-soon",
},
@ -161,8 +161,8 @@ func appTile(a AppTile) templ.Component {
templ_7745c5c3_Var2 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
if a.Status == "coming-soon" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<div class=\"app-card disabled\" oncontextmenu=\"return false\" ontouchstart=\"startLongPress(event)\" ontouchend=\"cancelLongPress()\" onmousedown=\"startLongPress(event)\" onmouseup=\"cancelLongPress()\"><div class=\"app-icon\" style=\"")
if a.URL == "#" || a.URL == "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<div class=\"app-card disabled\">oncontextmenu=\"return false\" ontouchstart=\"startLongPress(event)\" ontouchend=\"cancelLongPress()\" onmousedown=\"startLongPress(event)\" onmouseup=\"cancelLongPress()\"><div class=\"app-icon\" style=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -201,27 +201,27 @@ func appTile(a AppTile) templ.Component {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div class=\"app-card\" data-url=\"")
templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, "window.location.href='"+a.URL+"'")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.ResolveAttributeValue(a.URL)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `core/ui/app-grid.templ`, Line: 115, Col: 40}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div class=\"app-card\" onclick=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\" onclick=\"openApp.call(this)\" oncontextmenu=\"return false\" ontouchstart=\"startLongPress(event)\" ontouchend=\"cancelLongPress()\" onmousedown=\"startLongPress(event)\" onmouseup=\"cancelLongPress()\"><div class=\"app-icon\" style=\"")
var templ_7745c5c3_Var5 templ.ComponentScript = "window.location.href='" + a.URL + "'"
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5.Call)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\" oncontextmenu=\"return false\"><div class=\"app-icon\" style=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues("background:" + a.Color)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `core/ui/app-grid.templ`, Line: 120, Col: 56}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `core/ui/app-grid.templ`, Line: 116, Col: 56}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
@ -242,7 +242,7 @@ func appTile(a AppTile) templ.Component {
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(a.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `core/ui/app-grid.templ`, Line: 121, Col: 33}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `core/ui/app-grid.templ`, Line: 117, Col: 33}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {