1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-18 20:59:43 +02:00

Display category names in documents list (space view)

We pre-fetch category names and attach them to documents.
This commit is contained in:
Harvey Kandola 2019-01-08 12:43:25 +00:00
parent 1d4a20cdfe
commit 5467771542
8 changed files with 804 additions and 722 deletions

View file

@ -39,6 +39,9 @@ type Document struct {
VersionID string `json:"versionId"`
VersionOrder int `json:"versionOrder"`
GroupID string `json:"groupId"`
// Read-only presentation only data
Category []string `json:"category"`
}
// SetDefaults ensures on blanks and cleans.
@ -50,13 +53,20 @@ func (d *Document) SetDefaults() {
}
}
// ByName sorts a collection of documents by document Name.
// ByName sorts a collection of documents by document name.
type ByName []Document
func (a ByName) Len() int { return len(a) }
func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByName) Less(i, j int) bool { return strings.ToLower(a[i].Name) < strings.ToLower(a[j].Name) }
// ByID sorts a collection of documents by document ID.
type ByID []Document
func (a ByID) Len() int { return len(a) }
func (a ByID) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByID) Less(i, j int) bool { return a[i].RefID > a[j].RefID }
// DocumentMeta details who viewed the document.
type DocumentMeta struct {
Viewers []DocumentMetaViewer `json:"viewers"`