Fix scene marker/gallery chapter update overwriting created at date (#3945)

* Add UpdatePartial to gallery chapter
* Add UpdatePartial to gallery marker
* Fix UI, use yup and useFormik
This commit is contained in:
DingDongSoLong4
2023-07-27 01:44:06 +02:00
committed by GitHub
parent b3fa3c326a
commit 2ae30028ac
17 changed files with 599 additions and 479 deletions

View File

@@ -49,6 +49,18 @@ func (r *galleryChapterRow) resolve() *models.GalleryChapter {
return ret
}
type galleryChapterRowRecord struct {
updateRecord
}
func (r *galleryChapterRowRecord) fromPartial(o models.GalleryChapterPartial) {
r.setString("title", o.Title)
r.setInt("image_index", o.ImageIndex)
r.setInt("gallery_id", o.GalleryID)
r.setTimestamp("created_at", o.CreatedAt)
r.setTimestamp("updated_at", o.UpdatedAt)
}
type GalleryChapterStore struct {
repository
@@ -103,6 +115,24 @@ func (qb *GalleryChapterStore) Update(ctx context.Context, updatedObject *models
return nil
}
func (qb *GalleryChapterStore) UpdatePartial(ctx context.Context, id int, partial models.GalleryChapterPartial) (*models.GalleryChapter, error) {
r := galleryChapterRowRecord{
updateRecord{
Record: make(exp.Record),
},
}
r.fromPartial(partial)
if len(r.Record) > 0 {
if err := qb.tableMgr.updateByID(ctx, id, r.Record); err != nil {
return nil, err
}
}
return qb.find(ctx, id)
}
func (qb *GalleryChapterStore) Destroy(ctx context.Context, id int) error {
return qb.destroyExisting(ctx, []int{id})
}