Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
68 changes: 68 additions & 0 deletions migrations/1776675571_updated_cps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package migrations

import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)

func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("pbc_1556475754")
if err != nil {
return err
}

// update field
if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{
"hidden": false,
"id": "file3309110367",
"maxSelect": 5,
"maxSize": 0,
"mimeTypes": [
"image/png",
"image/jpeg",
"image/webp"
],
"name": "images",
"presentable": false,
"protected": false,
"required": true,
"system": false,
"thumbs": [],
"type": "file"
}`)); err != nil {
return err
}

return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("pbc_1556475754")
if err != nil {
return err
}

// update field
if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{
"hidden": false,
"id": "file3309110367",
"maxSelect": 3,
"maxSize": 0,
"mimeTypes": [
"image/png",
"image/jpeg",
"image/webp"
],
"name": "images",
"presentable": false,
"protected": false,
"required": true,
"system": false,
"thumbs": [],
"type": "file"
}`)); err != nil {
return err
}

return app.Save(collection)
})
}
6 changes: 5 additions & 1 deletion website/src/routes/create/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
!description.trim() ||
!pictures ||
pictures.length < 1 ||
pictures.length > 3 ||
!character1.trim() ||
!character2.trim()
) {
errorText = 'All fields must be filled out';
return;
}

if (pictures.length > 5) {
errorText = 'You can only upload up to 5 images';
return;
}
Comment on lines +35 to +38
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The validation for the maximum number of images (5) should also be implemented in the edit page (website/src/routes/edit/cps/[id]/+page.svelte) to maintain consistency across the application. Currently, the edit page lacks this client-side check, which could result in a poor user experience where the backend rejects the update without immediate feedback in the UI.


if (character1 === character2) {
errorText = 'Character #1 and Character #2 cannot be the same';
return;
Expand Down