Keep settings page position after editing (#6)

This commit is contained in:
Ivan R. 2023-11-01 22:49:15 +05:00
parent 77ddb3747b
commit 113d5860ff
No known key found for this signature in database
GPG key ID: 56C7BAAE859B302C
3 changed files with 44 additions and 42 deletions

View file

@ -9,7 +9,7 @@
<a href="/">Main page</a>
{{range .groups}}
<h2>Group "{{.Name}}"</h2>
<h2 id="group-{{.ID}}">Group "{{.Name}}"</h2>
<div class="row">
<form method="POST" action="/api/groups/{{.ID}}/put" class="innerForm">
<input
@ -36,7 +36,7 @@
</div>
{{range .Links}}
<div class="row">
<div class="row" id="link-{{.ID}}">
<form method="POST" action="/api/links/{{.ID}}/put" class="innerForm">
<!-- method: put -->
<input

View file

@ -1,6 +1,7 @@
package views
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/ordinary-dev/phoenix/database"
"gorm.io/gorm"
@ -20,7 +21,7 @@ func CreateGroup(db *gorm.DB) gin.HandlerFunc {
}
// This page is called from the settings, return the user back.
ctx.Redirect(http.StatusFound, "/settings")
ctx.Redirect(http.StatusFound, fmt.Sprintf("/settings#group-%v", group.ID))
}
}
@ -45,7 +46,7 @@ func UpdateGroup(db *gorm.DB) gin.HandlerFunc {
}
// This page is called from the settings, return the user back.
ctx.Redirect(http.StatusFound, "/settings")
ctx.Redirect(http.StatusFound, fmt.Sprintf("/settings#group-%v", group.ID))
}
}

View file

@ -1,6 +1,7 @@
package views
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/ordinary-dev/phoenix/database"
"gorm.io/gorm"
@ -33,7 +34,7 @@ func CreateLink(db *gorm.DB) gin.HandlerFunc {
}
// Redirect to settings.
ctx.Redirect(http.StatusFound, "/settings")
ctx.Redirect(http.StatusFound, fmt.Sprintf("/settings#link-%v", link.ID))
}
}
@ -65,7 +66,7 @@ func UpdateLink(db *gorm.DB) gin.HandlerFunc {
}
// Redirect to settings.
ctx.Redirect(http.StatusFound, "/settings")
ctx.Redirect(http.StatusFound, fmt.Sprintf("/settings#link-%v", link.ID))
}
}