Containing Group/Sub-Group relationships (#5105)

* Add UI support for setting containing groups
* Show containing groups in group details panel
* Move tag hierarchical filter code into separate type
* Add depth to scene_count and add sub_group_count
* Add sub-groups tab to groups page
* Add containing groups to edit groups dialog
* Show containing group description in sub-group view
* Show group scene number in group scenes view
* Add ability to drag move grid cards
* Add sub group order option
* Add reorder sub-groups interface
* Separate page size selector component
* Add interfaces to add and remove sub-groups to a group
* Separate MultiSet components
* Allow setting description while setting containing groups
This commit is contained in:
WithoutPants
2024-08-30 11:43:44 +10:00
committed by GitHub
parent 96fdd94a01
commit bcf0fda7ac
99 changed files with 5388 additions and 935 deletions

View File

@@ -78,6 +78,7 @@ const (
sceneIdxWithGrandChildStudio
sceneIdxMissingPhash
sceneIdxWithPerformerParentTag
sceneIdxWithGroupWithParent
// new indexes above
lastSceneIdx
@@ -153,9 +154,15 @@ const (
groupIdxWithTag
groupIdxWithTwoTags
groupIdxWithThreeTags
groupIdxWithGrandChild
groupIdxWithChild
groupIdxWithParentAndChild
groupIdxWithParent
groupIdxWithGrandParent
groupIdxWithParentAndScene
groupIdxWithChildWithScene
// groups with dup names start from the end
// create 7 more basic groups (can remove this if we add more indexes)
groupIdxWithDupName = groupIdxWithStudio + 7
groupIdxWithDupName
groupsNameCase = groupIdxWithDupName
groupsNameNoCase = 1
@@ -390,7 +397,8 @@ var (
}
sceneGroups = linkMap{
sceneIdxWithGroup: {groupIdxWithScene},
sceneIdxWithGroup: {groupIdxWithScene},
sceneIdxWithGroupWithParent: {groupIdxWithParentAndScene},
}
sceneStudios = map[int]int{
@@ -541,15 +549,31 @@ var (
}
)
var (
groupParentLinks = [][2]int{
{groupIdxWithChild, groupIdxWithParent},
{groupIdxWithGrandChild, groupIdxWithParentAndChild},
{groupIdxWithParentAndChild, groupIdxWithGrandParent},
{groupIdxWithChildWithScene, groupIdxWithParentAndScene},
}
)
func indexesToIDs(ids []int, indexes []int) []int {
ret := make([]int, len(indexes))
for i, idx := range indexes {
ret[i] = ids[idx]
ret[i] = indexToID(ids, idx)
}
return ret
}
func indexToID(ids []int, idx int) int {
if idx < 0 {
return invalidID
}
return ids[idx]
}
func indexFromID(ids []int, id int) int {
for i, v := range ids {
if v == id {
@@ -697,6 +721,10 @@ func populateDB() error {
return fmt.Errorf("error linking tags parent: %s", err.Error())
}
if err := linkGroupsParent(ctx, db.Group); err != nil {
return fmt.Errorf("error linking tags parent: %s", err.Error())
}
for _, ms := range markerSpecs {
if err := createMarker(ctx, db.SceneMarker, ms); err != nil {
return fmt.Errorf("error creating scene marker: %s", err.Error())
@@ -1885,6 +1913,24 @@ func linkTagsParent(ctx context.Context, qb models.TagReaderWriter) error {
})
}
func linkGroupsParent(ctx context.Context, qb models.GroupReaderWriter) error {
return doLinks(groupParentLinks, func(parentIndex, childIndex int) error {
groupID := groupIDs[childIndex]
p := models.GroupPartial{
ContainingGroups: &models.UpdateGroupDescriptions{
Groups: []models.GroupIDDescription{
{GroupID: groupIDs[parentIndex]},
},
Mode: models.RelationshipUpdateModeAdd,
},
}
_, err := qb.UpdatePartial(ctx, groupID, p)
return err
})
}
func addTagImage(ctx context.Context, qb models.TagWriter, tagIndex int) error {
return qb.UpdateImage(ctx, tagIDs[tagIndex], []byte("image"))
}