Add document types filtering and rename ISMS to GOVERNANCE
Adds 5 new document types (PLAN, REGISTER, RECORD, REPORT, TEMPLATE), renames ISMS to GOVERNANCE, and implements type-based filtering across GraphQL, MCP, and frontend. Includes migration, enum updates, filter implementation with SQL array support, and frontend dropdown UI with Relay refetch pattern. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -25,6 +25,7 @@ type (
|
||||
trustCenterVisibilities []TrustCenterVisibility
|
||||
published *bool
|
||||
userEmail *mail.Addr
|
||||
documentTypes []DocumentType
|
||||
}
|
||||
)
|
||||
|
||||
@@ -55,6 +56,11 @@ func (f *DocumentFilter) WithUserEmail(userEmail *mail.Addr) *DocumentFilter {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *DocumentFilter) WithDocumentTypes(documentTypes []DocumentType) *DocumentFilter {
|
||||
f.documentTypes = documentTypes
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *DocumentFilter) SQLArguments() pgx.NamedArgs {
|
||||
var visibilities []string
|
||||
if f.trustCenterVisibilities != nil {
|
||||
@@ -63,11 +69,21 @@ func (f *DocumentFilter) SQLArguments() pgx.NamedArgs {
|
||||
visibilities[i] = v.String()
|
||||
}
|
||||
}
|
||||
|
||||
var documentTypes []string
|
||||
if f.documentTypes != nil {
|
||||
documentTypes = make([]string, len(f.documentTypes))
|
||||
for i, dt := range f.documentTypes {
|
||||
documentTypes[i] = dt.String()
|
||||
}
|
||||
}
|
||||
|
||||
return pgx.NamedArgs{
|
||||
"query": f.query,
|
||||
"trust_center_visibilities": visibilities,
|
||||
"published": f.published,
|
||||
"user_email": f.userEmail,
|
||||
"document_types": documentTypes,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,5 +125,11 @@ func (f *DocumentFilter) SQLFragment() string {
|
||||
AND dvs.state IN ('REQUESTED', 'SIGNED')
|
||||
)
|
||||
END
|
||||
AND
|
||||
CASE
|
||||
WHEN @document_types::document_type[] IS NOT NULL THEN
|
||||
document_type = ANY(@document_types::document_type[])
|
||||
ELSE TRUE
|
||||
END
|
||||
)`
|
||||
}
|
||||
|
||||
@@ -24,18 +24,28 @@ type (
|
||||
)
|
||||
|
||||
const (
|
||||
DocumentTypeOther DocumentType = "OTHER"
|
||||
DocumentTypeISMS DocumentType = "ISMS"
|
||||
DocumentTypePolicy DocumentType = "POLICY"
|
||||
DocumentTypeProcedure DocumentType = "PROCEDURE"
|
||||
DocumentTypeOther DocumentType = "OTHER"
|
||||
DocumentTypeGovernance DocumentType = "GOVERNANCE"
|
||||
DocumentTypePolicy DocumentType = "POLICY"
|
||||
DocumentTypeProcedure DocumentType = "PROCEDURE"
|
||||
DocumentTypePlan DocumentType = "PLAN"
|
||||
DocumentTypeRegister DocumentType = "REGISTER"
|
||||
DocumentTypeRecord DocumentType = "RECORD"
|
||||
DocumentTypeReport DocumentType = "REPORT"
|
||||
DocumentTypeTemplate DocumentType = "TEMPLATE"
|
||||
)
|
||||
|
||||
func DocumentTypes() []DocumentType {
|
||||
return []DocumentType{
|
||||
DocumentTypeOther,
|
||||
DocumentTypeISMS,
|
||||
DocumentTypeGovernance,
|
||||
DocumentTypePolicy,
|
||||
DocumentTypeProcedure,
|
||||
DocumentTypePlan,
|
||||
DocumentTypeRegister,
|
||||
DocumentTypeRecord,
|
||||
DocumentTypeReport,
|
||||
DocumentTypeTemplate,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,12 +59,22 @@ func (dt *DocumentType) UnmarshalText(data []byte) error {
|
||||
switch val {
|
||||
case DocumentTypeOther.String():
|
||||
*dt = DocumentTypeOther
|
||||
case DocumentTypeISMS.String():
|
||||
*dt = DocumentTypeISMS
|
||||
case DocumentTypeGovernance.String():
|
||||
*dt = DocumentTypeGovernance
|
||||
case DocumentTypePolicy.String():
|
||||
*dt = DocumentTypePolicy
|
||||
case DocumentTypeProcedure.String():
|
||||
*dt = DocumentTypeProcedure
|
||||
case DocumentTypePlan.String():
|
||||
*dt = DocumentTypePlan
|
||||
case DocumentTypeRegister.String():
|
||||
*dt = DocumentTypeRegister
|
||||
case DocumentTypeRecord.String():
|
||||
*dt = DocumentTypeRecord
|
||||
case DocumentTypeReport.String():
|
||||
*dt = DocumentTypeReport
|
||||
case DocumentTypeTemplate.String():
|
||||
*dt = DocumentTypeTemplate
|
||||
default:
|
||||
return fmt.Errorf("invalid DocumentType value: %q", val)
|
||||
}
|
||||
|
||||
6
pkg/coredata/migrations/20260319T130000Z.sql
Normal file
6
pkg/coredata/migrations/20260319T130000Z.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
ALTER TYPE document_type RENAME VALUE 'ISMS' TO 'GOVERNANCE';
|
||||
ALTER TYPE document_type ADD VALUE 'PLAN';
|
||||
ALTER TYPE document_type ADD VALUE 'REGISTER';
|
||||
ALTER TYPE document_type ADD VALUE 'RECORD';
|
||||
ALTER TYPE document_type ADD VALUE 'REPORT';
|
||||
ALTER TYPE document_type ADD VALUE 'TEMPLATE';
|
||||
Reference in New Issue
Block a user