Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove null (gap) to prevent validation errors #728

Merged
merged 8 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/VideoAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public function validatePoints(array $points = [])
throw new Exception('The number of key frames does not match the number of annotation coordinates.');
}

array_map([$this, 'parent::validatePoints'], $this->points);
// Gaps are represented as empty arrays
array_map(function ($point) { if (count($point)) { parent::validatePoints($point); } }, $this->points);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions resources/assets/js/videos/models/Annotation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,16 @@ export default Vue.extend({
this.frames.splice(index, 1);
this.points.splice(index, 1);

// Remove "null" elements of adjacent gaps to
// avoid multiple consecutive "null"s.
if (index === 0 && this.frames[0] === null) {
this.frames.splice(0, 1);
this.points.splice(0, 1);
} else if (this.frames[index - 1] === null) {
this.frames.splice(index - 1, 1);
this.points.splice(index - 1, 1);
}

return VideoAnnotationApi.update({id: this.id}, {
frames: this.frames,
points: this.points
Expand Down