3
0

Add weight to page create

This commit is contained in:
Jože Fortun
2020-05-19 12:52:24 +02:00
parent d09fec19ca
commit c84e798ce7
4 changed files with 37 additions and 0 deletions
+6
View File
@@ -276,6 +276,12 @@
"required": false,
"title": "Description"
},
{
"type": "int",
"name": "weight",
"required": false,
"title": "Page tree weight"
},
{
"type": "bool",
"name": "visible",
+6
View File
@@ -113,6 +113,12 @@
"title": "Description",
"type": "string"
},
{
"name": "weight",
"required": false,
"title": "Page tree weight",
"type": "int"
},
{
"name": "visible",
"required": false,
+1
View File
@@ -87,6 +87,7 @@ func (ctrl *Page) Create(ctx context.Context, r *request.PageCreate) (interface{
Handle: r.Handle,
Description: r.Description,
Visible: r.Visible,
Weight: r.Weight,
}
)
+24
View File
@@ -192,6 +192,10 @@ type PageCreate struct {
rawDescription string
Description string
hasWeight bool
rawWeight string
Weight int
hasVisible bool
rawVisible string
Visible bool
@@ -279,6 +283,11 @@ func (r *PageCreate) Fill(req *http.Request) (err error) {
r.rawDescription = val
r.Description = val
}
if val, ok := post["weight"]; ok {
r.hasWeight = true
r.rawWeight = val
r.Weight = parseInt(val)
}
if val, ok := post["visible"]; ok {
r.hasVisible = true
r.rawVisible = val
@@ -1078,6 +1087,21 @@ func (r *PageCreate) GetDescription() string {
return r.Description
}
// HasWeight returns true if weight was set
func (r *PageCreate) HasWeight() bool {
return r.hasWeight
}
// RawWeight returns raw value of weight parameter
func (r *PageCreate) RawWeight() string {
return r.rawWeight
}
// GetWeight returns casted value of weight parameter
func (r *PageCreate) GetWeight() int {
return r.Weight
}
// HasVisible returns true if visible was set
func (r *PageCreate) HasVisible() bool {
return r.hasVisible