Loggest thine Stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.1 KiB

package entities
import (
"fmt"
"git.aiterp.net/stufflog3/stufflog3/models"
)
type Scope struct {
ID int `json:"id"`
Name string `json:"name"`
Abbreviation string `json:"abbreviation"`
CustomLabels map[string]string `json:"customLabels"`
}
func (scope *Scope) StatusName(status models.Status) string {
if cl, ok := scope.CustomLabels[fmt.Sprintf("status%d", status)]; ok {
return cl
}
return status.Name()
}
func (scope *Scope) ApplyUpdate(update models.ScopeUpdate) {
if update.Name != nil {
scope.Name = *update.Name
}
if update.Abbreviation != nil {
scope.Abbreviation = *update.Abbreviation
}
if scope.CustomLabels == nil {
scope.CustomLabels = make(map[string]string)
}
for key, value := range update.CustomLabels {
if value == nil {
delete(scope.CustomLabels, key)
} else {
scope.CustomLabels[key] = *value
}
}
if len(scope.CustomLabels) == 0 {
scope.CustomLabels = nil
}
}
type ScopeMember struct {
ScopeID int `json:"scopeId"`
UserID string `json:"userId"`
Name string `json:"name"`
Owner bool `json:"owner"`
}