item_draft.go

 1package board
 2
 3import (
 4	"github.com/MichaelMure/git-bug/entities/identity"
 5	"github.com/MichaelMure/git-bug/entity"
 6	"github.com/dustin/go-humanize"
 7
 8	"github.com/MichaelMure/git-bug/entities/common"
 9	"github.com/MichaelMure/git-bug/util/timestamp"
10)
11
12var _ Item = &Draft{}
13
14type Draft struct {
15	// combinedId should be the result of entity.CombineIds with the Board id and the id
16	// of the Operation that created the Draft
17	combinedId entity.CombinedId
18
19	author  identity.Interface
20	status  common.Status
21	title   string
22	message string
23
24	// Creation time of the comment.
25	// Should be used only for human display, never for ordering as we can't rely on it in a distributed system.
26	unixTime timestamp.Timestamp
27}
28
29func (d *Draft) CombinedId() entity.CombinedId {
30	if d.combinedId == "" || d.combinedId == entity.UnsetCombinedId {
31		// simply panic as it would be a coding error (no id provided at construction)
32		panic("no combined id")
33	}
34	return d.combinedId
35}
36
37func (d *Draft) Status() common.Status {
38	// TODO implement me
39	panic("implement me")
40}
41
42// FormatTimeRel format the UnixTime of the comment for human consumption
43func (d *Draft) FormatTimeRel() string {
44	return humanize.Time(d.unixTime.Time())
45}
46
47func (d *Draft) FormatTime() string {
48	return d.unixTime.Time().Format("Mon Jan 2 15:04:05 2006 +0200")
49}
50
51// IsAuthored is a sign post method for gqlgen
52func (d *Draft) IsAuthored() {}