2020-02-04 05:18:22 +01:00
|
|
|
package form
|
|
|
|
|
2020-06-24 12:01:25 +02:00
|
|
|
import "strings"
|
|
|
|
|
2020-02-04 05:18:22 +01:00
|
|
|
type Selection struct {
|
2021-09-17 14:26:12 +02:00
|
|
|
Files []string `json:"files"`
|
|
|
|
Photos []string `json:"photos"`
|
|
|
|
Albums []string `json:"albums"`
|
|
|
|
Labels []string `json:"labels"`
|
|
|
|
Places []string `json:"places"`
|
|
|
|
Subjects []string `json:"subjects"`
|
2020-02-04 05:18:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f Selection) Empty() bool {
|
2020-05-25 19:10:44 +02:00
|
|
|
switch {
|
|
|
|
case len(f.Files) > 0:
|
|
|
|
return false
|
|
|
|
case len(f.Photos) > 0:
|
|
|
|
return false
|
|
|
|
case len(f.Albums) > 0:
|
|
|
|
return false
|
|
|
|
case len(f.Labels) > 0:
|
|
|
|
return false
|
|
|
|
case len(f.Places) > 0:
|
2020-02-04 05:18:22 +01:00
|
|
|
return false
|
2021-09-17 14:26:12 +02:00
|
|
|
case len(f.Subjects) > 0:
|
|
|
|
return false
|
2020-02-04 05:18:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
2020-06-24 12:01:25 +02:00
|
|
|
|
|
|
|
func (f Selection) All() []string {
|
|
|
|
var all []string
|
|
|
|
|
|
|
|
copy(all, f.Files)
|
|
|
|
|
|
|
|
all = append(all, f.Photos...)
|
|
|
|
all = append(all, f.Albums...)
|
|
|
|
all = append(all, f.Labels...)
|
|
|
|
all = append(all, f.Places...)
|
2021-09-17 14:26:12 +02:00
|
|
|
all = append(all, f.Subjects...)
|
2020-06-24 12:01:25 +02:00
|
|
|
|
|
|
|
return all
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f Selection) String() string {
|
|
|
|
return strings.Join(f.All(), ", ")
|
|
|
|
}
|