-
Notifications
You must be signed in to change notification settings - Fork 22
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
#2870 Add ability to pass in an array variable or template for dropdown field options #2915
Merged
Merged
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2daaddc
2870 using ArrayWidget for dropdown options in the Form Builder
BALEHOK e96fa49
2870 fixing preview
BALEHOK e16575b
2870 Pull fields and widgets from BS4 theme
BALEHOK 431b87b
Merge remote-tracking branch 'origin/main' into feature/2870-dd-varia…
BALEHOK 37f5531
Merge remote-tracking branch 'origin/main' into feature/2870-dd-varia…
BALEHOK de665d2
2870 Dropdown with labels
BALEHOK 5be51ed
2870 tests
BALEHOK 16deb54
2870 fixing types
BALEHOK d82da8c
2870 fixing types
BALEHOK d335cb8
2870 Fixing default and no option errors
BALEHOK cb408b7
Merge remote-tracking branch 'origin/main' into feature/2870-dd-varia…
BALEHOK 5761b04
2870 Dropdown text option tests
BALEHOK 573b231
2870 Enable var in Dropdown with labels
BALEHOK d9ba8b3
2870 removing options mapping
BALEHOK 8e0975c
Merge remote-tracking branch 'origin/main' into feature/2870-dd-varia…
BALEHOK f145e93
2870 Fixing merge conflicts
BALEHOK da2c141
2870 linting
BALEHOK 02b25da
Merge remote-tracking branch 'origin/main' into feature/2870-dd-varia…
BALEHOK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
File renamed without changes.
This file contains 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
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions
40
src/components/formBuilder/preview/SelectWidgetPreview.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) 2022 PixieBrix, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { utils, WidgetProps } from "@rjsf/core"; | ||
import React from "react"; | ||
import { FormGroup, FormLabel } from "react-bootstrap"; | ||
|
||
const RjsfArrayField = utils.getDefaultRegistry().widgets.SelectWidget; | ||
|
||
const SelectWidgetPreview: React.VFC<WidgetProps> = (props) => { | ||
console.log("FormPreviewArrayField props:", props); | ||
if (typeof props.schema.enum === "string") { | ||
return ( | ||
<FormGroup> | ||
<FormLabel>{props.schema.title}</FormLabel> | ||
<div className="text-muted form-text"> | ||
Dropdown options defined by a variable are not displayed in preview. | ||
</div> | ||
</FormGroup> | ||
); | ||
} | ||
|
||
return <RjsfArrayField {...props} />; | ||
}; | ||
|
||
export default SelectWidgetPreview; |
File renamed without changes.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could show a disabled input here with the variable name or something to indicate in the preview which variable is wired up, like when you put a variable in one of the options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!