add toggle buttons to pub field form elements#665
Merged
Conversation
1dac72f to
885ff73
Compare
allisonking
approved these changes
Sep 26, 2024
Contributor
allisonking
left a comment
There was a problem hiding this comment.
this looks good for the most part! just two things I found while playing around that may not be need to be addressed in this PR:
- I can't create a pub with all disabled fields (I get a db error)
[16:15:08.231] ERROR: syntax error at or near ")"
package: "core"
err: {
"type": "DatabaseError",
"message": "syntax error at or near \")\"",
"stack":
error: syntax error at or near ")"
at /Users/allisonking/workspace/kf/v7/node_modules/.pnpm/pg@8.12.0/node_modules/pg/lib/client.js:526:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PostgresConnection.executeQuery (/Users/allisonking/workspace/kf/v7/core/.next/server/chunks/ssr/33c0b_kysely_dist_esm_85a464._.js:3973:28)
- The create form doesn't seem to close after submitting (not sure if that was introduced in this PR)
Collaborator
Author
There was a problem hiding this comment.
uhh yeah not sure where this came from, ty!
885ff73 to
894aec4
Compare
3mcd
commented
Sep 26, 2024
| sql<PubValues>`(select coalesce(json_object_agg(${sql.ref(alias)}.slug, ${sql.ref( | ||
| alias | ||
| )}.value) from ${subquery})`; | ||
| )}.value), '{}') from ${subquery})`; |
Collaborator
Author
There was a problem hiding this comment.
This just coalesces the value to {} in the case the pub has no pub values.
dcedeac to
b0aa527
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue(s) Resolved
Closes knowledgefutures/pubpub#3179
(Looks like this issue was accidentally created in the pubpub/pubpub repo)
High-level Explanation of PR
This PR adds a button to the left side of form elements within the pub create form. Clicking the button toggles the disabled state for that field. By default all fields are enabled.
Disabled fields are omitted from the form when submitted. This means that submitting a form with all fields disabled will create a pub with no pub values.
Test Plan
Screenshots (if applicable)
The pub creation form with a disabled title field and invalid email field. The "Create Pub" button is disabled because of the enabled, invalid field.
The same pub creation form after disabling the invalid email field. The "Create Pub" button is now enabled because the invalid field was disabled.
The pub page of the newly created pub. Notice that the only field associated with the pub is "Member ID": the only enabled field on the form in the previous screenshot.Notes