1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-18 20:59:43 +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

@ -115,6 +115,15 @@ const (
// TypePublished happens when a document is moved from Draft to Live.
TypePublished Type = 16
// TypePinned happens when a document is pinned within space.
TypePinned Type = 17
// TypeUnpinned happens when a document is no longer pinned inside a space.
TypeUnpinned Type = 18
// TypePinSequence is when the order of sequenced documents is changed.
TypePinSequence Type = 19
)
// TypeName returns one-work descriptor for activity type
@ -152,6 +161,12 @@ func TypeName(t Type) string {
return "Search"
case TypePublished:
return "Publish"
case TypePinned:
return "Pinned"
case TypeUnpinned:
return "Unpinned"
case TypePinSequence:
return "Sequence"
}
return ""

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
)