-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add delete button for additionalProperties key-value pair #1123
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
Changes from all commits
b59a9eb
a748ee1
6559d1d
8f5f597
ba1181d
939209c
d4569a9
eb72a4e
759d338
c4719af
d21e0aa
7f1a7f4
a558246
967e319
73cde14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { ADDITIONAL_PROPERTY_FLAG } from "../../utils"; | ||
| import IconButton from "../IconButton"; | ||
| import React from "react"; | ||
| import PropTypes from "prop-types"; | ||
|
|
||
|
|
@@ -107,7 +108,6 @@ function ErrorList(props) { | |
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function DefaultTemplate(props) { | ||
| const { | ||
| id, | ||
|
|
@@ -121,35 +121,57 @@ function DefaultTemplate(props) { | |
| required, | ||
| displayLabel, | ||
| onKeyChange, | ||
| onDropIndexClick, | ||
| } = props; | ||
| if (hidden) { | ||
| return children; | ||
| } | ||
|
|
||
| const additional = props.schema.hasOwnProperty(ADDITIONAL_PROPERTY_FLAG); | ||
| const keyLabel = `${label} Key`; | ||
|
|
||
| return ( | ||
| <div className={classNames}> | ||
| {additional && ( | ||
| <div className="form-group"> | ||
| <Label label={keyLabel} required={required} id={`${id}-key`} /> | ||
| <LabelInput | ||
| label={label} | ||
| required={required} | ||
| id={`${id}-key`} | ||
| onChange={onKeyChange} | ||
| /> | ||
| <div className={additional ? "row" : ""}> | ||
| {additional && ( | ||
| <div className="col-xs-5 form-additional"> | ||
| <div className="form-group"> | ||
| <Label label={keyLabel} required={required} id={`${id}-key`} /> | ||
| <LabelInput | ||
| label={label} | ||
| required={required} | ||
| id={`${id}-key`} | ||
| onChange={onKeyChange} | ||
| /> | ||
| </div> | ||
| </div> | ||
| )} | ||
|
|
||
| <div | ||
| className={additional ? "form-additional form-group col-xs-5" : ""}> | ||
| {displayLabel && <Label label={label} required={required} id={id} />} | ||
| {displayLabel && description ? description : null} | ||
| {children} | ||
| {errors} | ||
| {help} | ||
| </div> | ||
| <div className="col-xs-2"> | ||
| {additional && ( | ||
| <IconButton | ||
| type="danger" | ||
| icon="remove" | ||
| className="array-item-remove btn-block" | ||
| tabIndex="-1" | ||
| style={{ border: "0" }} | ||
| disabled={props.disabled || props.readonly} | ||
| onClick={onDropIndexClick(props.label)} | ||
| /> | ||
| )} | ||
| </div> | ||
| )} | ||
| {displayLabel && <Label label={label} required={required} id={id} />} | ||
| {displayLabel && description ? description : null} | ||
| {children} | ||
| {errors} | ||
| {help} | ||
| </div> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pieplu I agree that lines 134 and 135 of this file can surely be merged into one (mistake on my side), which would probably leave just one empty div which is in line 150, but I at the first glance I don't know how to achieve same appearence using Bootstrap 3, and have a look at this: #1123 (comment)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I can try PR a fix with bootstrap style |
||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (process.env.NODE_ENV !== "production") { | ||
| DefaultTemplate.propTypes = { | ||
| id: PropTypes.string, | ||
|
|
@@ -186,6 +208,7 @@ function SchemaFieldRender(props) { | |
| idPrefix, | ||
| name, | ||
| onKeyChange, | ||
| onDropIndexClick, | ||
| required, | ||
| registry = getDefaultRegistry(), | ||
| } = props; | ||
|
|
@@ -285,6 +308,7 @@ function SchemaFieldRender(props) { | |
| label, | ||
| hidden, | ||
| onKeyChange, | ||
| onDropIndexClick, | ||
| required, | ||
| disabled, | ||
| readonly, | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.