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

@@ -57,6 +57,19 @@ func (r *sceneMarkerRow) resolve() *models.SceneMarker {
return ret
}
type sceneMarkerRowRecord struct {
updateRecord
}
func (r *sceneMarkerRowRecord) fromPartial(o models.SceneMarkerPartial) {
r.setNullString("title", o.Title)
r.setFloat64("seconds", o.Seconds)
r.setInt("primary_tag_id", o.PrimaryTagID)
r.setInt("scene_id", o.SceneID)
r.setTimestamp("created_at", o.CreatedAt)
r.setTimestamp("updated_at", o.UpdatedAt)
}
type SceneMarkerStore struct {
repository
@@ -100,6 +113,24 @@ func (qb *SceneMarkerStore) Create(ctx context.Context, newObject *models.SceneM
return nil
}
func (qb *SceneMarkerStore) UpdatePartial(ctx context.Context, id int, partial models.SceneMarkerPartial) (*models.SceneMarker, error) {
r := sceneMarkerRowRecord{
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 *SceneMarkerStore) Update(ctx context.Context, updatedObject *models.SceneMarker) error {
var r sceneMarkerRow
r.fromSceneMarker(*updatedObject)