Add moduleID to compose page list filter
This commit is contained in:
@@ -173,6 +173,10 @@ endpoints:
|
||||
name: selfID
|
||||
required: false
|
||||
title: Parent page ID
|
||||
- type: uint64
|
||||
name: moduleID
|
||||
required: false
|
||||
title: Module ID
|
||||
- type: string
|
||||
name: query
|
||||
required: false
|
||||
|
||||
@@ -58,6 +58,7 @@ func (ctrl *Page) List(ctx context.Context, r *request.PageList) (interface{}, e
|
||||
err error
|
||||
f = types.PageFilter{
|
||||
NamespaceID: r.NamespaceID,
|
||||
ModuleID: r.ModuleID,
|
||||
ParentID: r.SelfID,
|
||||
Labels: r.Labels,
|
||||
|
||||
|
||||
@@ -46,6 +46,11 @@ type (
|
||||
// Parent page ID
|
||||
SelfID uint64 `json:",string"`
|
||||
|
||||
// ModuleID GET parameter
|
||||
//
|
||||
// Module ID
|
||||
ModuleID uint64 `json:",string"`
|
||||
|
||||
// Query GET parameter
|
||||
//
|
||||
// Search query
|
||||
@@ -279,6 +284,7 @@ func (r PageList) Auditable() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"namespaceID": r.NamespaceID,
|
||||
"selfID": r.SelfID,
|
||||
"moduleID": r.ModuleID,
|
||||
"query": r.Query,
|
||||
"handle": r.Handle,
|
||||
"labels": r.Labels,
|
||||
@@ -298,6 +304,11 @@ func (r PageList) GetSelfID() uint64 {
|
||||
return r.SelfID
|
||||
}
|
||||
|
||||
// Auditable returns all auditable/loggable parameters
|
||||
func (r PageList) GetModuleID() uint64 {
|
||||
return r.ModuleID
|
||||
}
|
||||
|
||||
// Auditable returns all auditable/loggable parameters
|
||||
func (r PageList) GetQuery() string {
|
||||
return r.Query
|
||||
@@ -341,6 +352,12 @@ func (r *PageList) Fill(req *http.Request) (err error) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if val, ok := tmp["moduleID"]; ok && len(val) > 0 {
|
||||
r.ModuleID, err = payload.ParseUint64(val[0]), nil
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if val, ok := tmp["query"]; ok && len(val) > 0 {
|
||||
r.Query, err = val[0], nil
|
||||
if err != nil {
|
||||
|
||||
@@ -58,6 +58,7 @@ type (
|
||||
PageFilter struct {
|
||||
NamespaceID uint64 `json:"namespaceID,string"`
|
||||
ParentID uint64 `json:"parentID,string,omitempty"`
|
||||
ModuleID uint64 `json:"moduleID,string,omitempty"`
|
||||
Root bool `json:"root,omitempty"`
|
||||
Handle string `json:"handle"`
|
||||
Title string `json:"title"`
|
||||
|
||||
@@ -19,6 +19,10 @@ func (s Store) convertComposePageFilter(f types.PageFilter) (query squirrel.Sele
|
||||
query = query.Where("cpg.rel_namespace = ?", f.NamespaceID)
|
||||
}
|
||||
|
||||
if f.ModuleID > 0 {
|
||||
query = query.Where("cpg.rel_module = ?", f.ModuleID)
|
||||
}
|
||||
|
||||
if len(f.LabeledIDs) > 0 {
|
||||
query = query.Where(squirrel.Eq{"cpg.id": f.LabeledIDs})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user