mirror of
https://github.com/ordinary-dev/phoenix
synced 2024-09-19 19:30:28 +05:00
Keep settings page position after editing (#6)
This commit is contained in:
parent
77ddb3747b
commit
113d5860ff
|
@ -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,43 +36,43 @@
|
|||
</div>
|
||||
|
||||
{{range .Links}}
|
||||
<div class="row">
|
||||
<form method="POST" action="/api/links/{{.ID}}/put" class="innerForm">
|
||||
<!-- method: put -->
|
||||
<input
|
||||
class="small-row"
|
||||
value="{{ if .Icon }}{{ .Icon }}{{ end }}"
|
||||
name="icon"
|
||||
placeholder="Icon"
|
||||
/>
|
||||
<input
|
||||
class="small-row"
|
||||
value="{{.Name}}"
|
||||
name="linkName"
|
||||
placeholder="Name"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
value="{{.Href}}"
|
||||
name="href"
|
||||
placeholder="Href"
|
||||
required
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
aria-label="Save the link"
|
||||
>
|
||||
<img src="/assets/svg/floppy-disk-solid.svg" width="16px" height="16px" />
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" action="/api/links/{{.ID}}/delete">
|
||||
<button
|
||||
type="submit"
|
||||
aria-label="Delete the link"
|
||||
>
|
||||
<img src="/assets/svg/trash-solid.svg" width="16px" height="16px" />
|
||||
</button>
|
||||
</form>
|
||||
<div class="row" id="link-{{.ID}}">
|
||||
<form method="POST" action="/api/links/{{.ID}}/put" class="innerForm">
|
||||
<!-- method: put -->
|
||||
<input
|
||||
class="small-row"
|
||||
value="{{ if .Icon }}{{ .Icon }}{{ end }}"
|
||||
name="icon"
|
||||
placeholder="Icon"
|
||||
/>
|
||||
<input
|
||||
class="small-row"
|
||||
value="{{.Name}}"
|
||||
name="linkName"
|
||||
placeholder="Name"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
value="{{.Href}}"
|
||||
name="href"
|
||||
placeholder="Href"
|
||||
required
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
aria-label="Save the link"
|
||||
>
|
||||
<img src="/assets/svg/floppy-disk-solid.svg" width="16px" height="16px" />
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" action="/api/links/{{.ID}}/delete">
|
||||
<button
|
||||
type="submit"
|
||||
aria-label="Delete the link"
|
||||
>
|
||||
<img src="/assets/svg/trash-solid.svg" width="16px" height="16px" />
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue