mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Make title optional for non-user created galleries (#3110)
This commit is contained in:
parent
c83ebf7c1c
commit
9df66024d1
4 changed files with 15 additions and 3 deletions
|
|
@ -177,8 +177,8 @@ func (r *mutationResolver) galleryUpdate(ctx context.Context, input models.Galle
|
||||||
|
|
||||||
if input.Title != nil {
|
if input.Title != nil {
|
||||||
// ensure title is not empty
|
// ensure title is not empty
|
||||||
if *input.Title == "" {
|
if *input.Title == "" && originalGallery.IsUserCreated() {
|
||||||
return nil, errors.New("title must not be empty")
|
return nil, errors.New("title must not be empty for user-created galleries")
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedGallery.Title = models.NewOptionalString(*input.Title)
|
updatedGallery.Title = models.NewOptionalString(*input.Title)
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,12 @@ type Gallery struct {
|
||||||
PerformerIDs RelatedIDs `json:"performer_ids"`
|
PerformerIDs RelatedIDs `json:"performer_ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsUserCreated returns true if the gallery was created by the user.
|
||||||
|
// This is determined by whether the gallery has a primary file or folder.
|
||||||
|
func (g *Gallery) IsUserCreated() bool {
|
||||||
|
return g.PrimaryFileID == nil && g.FolderID == nil
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Gallery) LoadFiles(ctx context.Context, l FileLoader) error {
|
func (g *Gallery) LoadFiles(ctx context.Context, l FileLoader) error {
|
||||||
return g.Files.load(func() ([]file.File, error) {
|
return g.Files.load(func() ([]file.File, error) {
|
||||||
return l.GetFiles(ctx, g.ID)
|
return l.GetFiles(ctx, g.ID)
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,13 @@ export const GalleryEditPanel: React.FC<
|
||||||
const [createGallery] = useGalleryCreate();
|
const [createGallery] = useGalleryCreate();
|
||||||
const [updateGallery] = useGalleryUpdate();
|
const [updateGallery] = useGalleryUpdate();
|
||||||
|
|
||||||
|
const titleRequired =
|
||||||
|
isNew || (gallery?.files?.length === 0 && !gallery?.folder);
|
||||||
|
|
||||||
const schema = yup.object({
|
const schema = yup.object({
|
||||||
title: yup.string().required(),
|
title: titleRequired
|
||||||
|
? yup.string().required()
|
||||||
|
: yup.string().optional().nullable(),
|
||||||
details: yup.string().optional().nullable(),
|
details: yup.string().optional().nullable(),
|
||||||
url: yup.string().optional().nullable(),
|
url: yup.string().optional().nullable(),
|
||||||
date: yup.string().optional().nullable(),
|
date: yup.string().optional().nullable(),
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
* Changed Performer height to be numeric, and changed filtering accordingly. ([#3060](https://github.com/stashapp/stash/pull/3060))
|
* Changed Performer height to be numeric, and changed filtering accordingly. ([#3060](https://github.com/stashapp/stash/pull/3060))
|
||||||
|
|
||||||
### 🐛 Bug fixes
|
### 🐛 Bug fixes
|
||||||
|
* Fixed Gallery title being incorrectly marked as mandatory for file- and folder-based galleries. ([#3110](https://github.com/stashapp/stash/pull/3110))
|
||||||
* Fixed Saved Filters not ordered by name. ([#3101](https://github.com/stashapp/stash/pull/3101))
|
* Fixed Saved Filters not ordered by name. ([#3101](https://github.com/stashapp/stash/pull/3101))
|
||||||
* Scene Player no longer always resumes playing when seeking. ([#3020](https://github.com/stashapp/stash/pull/3020))
|
* Scene Player no longer always resumes playing when seeking. ([#3020](https://github.com/stashapp/stash/pull/3020))
|
||||||
* Fixed space bar sometimes no playing/pausing the scene player. ([#3020](https://github.com/stashapp/stash/pull/3020))
|
* Fixed space bar sometimes no playing/pausing the scene player. ([#3020](https://github.com/stashapp/stash/pull/3020))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue