1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00

Pinned documents

Closes #278

Pin documents to the top of each space.
This commit is contained in:
sauls8t 2020-02-03 21:00:35 +00:00
parent 2b66d0096a
commit e014f5b5c1
18 changed files with 541 additions and 88 deletions

View file

@ -38,6 +38,7 @@ type Document struct {
Versioned bool `json:"versioned"`
VersionID string `json:"versionId"`
VersionOrder int `json:"versionOrder"`
Sequence int `json:"sequence"`
GroupID string `json:"groupId"`
// Read-only presentation only data
@ -67,6 +68,13 @@ 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 }
// BySeq sorts a collection of documents by sequenced number.
type BySeq []Document
func (a BySeq) Len() int { return len(a) }
func (a BySeq) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a BySeq) Less(i, j int) bool { return a[i].Sequence < a[j].Sequence }
// DocumentMeta details who viewed the document.
type DocumentMeta struct {
Viewers []DocumentMetaViewer `json:"viewers"`
@ -118,3 +126,15 @@ type DuplicateModel struct {
DocumentID string `json:"documentId"`
Name string `json:"documentName"`
}
// SortedDocs provides list od pinned and unpinned documents
// sorted by sequence and name respectively.
type SortedDocs struct {
Pinned []Document `json:"pinned"`
Unpinned []Document `json:"unpinned"`
}
const (
// Unsequenced tells us if document is pinned or not
Unsequenced int = 99999
)