fix(my-joy-beta): don't update header when editing keyValue

This commit is contained in:
Sérgio Ramos 2018-01-04 10:56:10 +00:00 committed by Sérgio Ramos
parent 4678addd7a
commit 0bccbc1988
2 changed files with 24 additions and 17 deletions

View File

@ -114,6 +114,7 @@ export const KeyValue = ({
input = 'input', input = 'input',
type = 'metadata', type = 'metadata',
method = 'add', method = 'add',
initialValues = {},
error = null, error = null,
expanded = true, expanded = true,
submitting = false, submitting = false,
@ -142,18 +143,14 @@ export const KeyValue = ({
<H4>{`${titleCase(method)} ${type}`}</H4> <H4>{`${titleCase(method)} ${type}`}</H4>
) : ( ) : (
<CollapsedKeyValue> <CollapsedKeyValue>
<Field <span>
name="name" {!expanded ? (
type="text" `${initialValues.name}: `
component={({ input = {} }) => ) : (
!expanded ? `${input.value}: ` : <b>{`${input.value}: `}</b> <b>{`${initialValues.name}: `}</b>
} )}
/>, </span>
<Field <span>{initialValues.value}</span>
name="value"
type="text"
component={({ input = {} }) => <span>{input.value}</span>}
/>
</CollapsedKeyValue> </CollapsedKeyValue>
)} )}
</CardHeaderMeta> </CardHeaderMeta>
@ -233,6 +230,10 @@ KeyValue.propTypes = {
input: PropTypes.oneOf(['input', 'textarea']).isRequired, input: PropTypes.oneOf(['input', 'textarea']).isRequired,
type: PropTypes.string.isRequired, type: PropTypes.string.isRequired,
method: PropTypes.oneOf(['add', 'edit']).isRequired, method: PropTypes.oneOf(['add', 'edit']).isRequired,
initialValues: PropTypes.shape({
name: PropTypes.string,
value: PropTypes.string
}).isRequired,
removing: PropTypes.bool.isRequired, removing: PropTypes.bool.isRequired,
expanded: PropTypes.bool.isRequired, expanded: PropTypes.bool.isRequired,
onToggleExpanded: PropTypes.func, onToggleExpanded: PropTypes.func,

View File

@ -92,12 +92,18 @@ export const Tags = ({
form={editing.form} form={editing.form}
initialValues={{ name: editing.name, value: editing.value }} initialValues={{ name: editing.name, value: editing.value }}
onSubmit={handleEdit} onSubmit={handleEdit}
onCancel={() => handleToggleEditing(false)}
onToggleExpanded={() => handleToggleEditing(false)}
onRemove={() => handleRemove(editing.form, editing)}
removing={editing.removing}
> >
{TagsEditForm} {props => (
<TagsEditForm
{...props}
/* yeah, we need this here too */
initialValues={{ name: editing.name, value: editing.value }}
onCancel={() => handleToggleEditing(false)}
onToggleExpanded={() => handleToggleEditing(false)}
onRemove={() => handleRemove(editing.form, editing)}
removing={editing.removing}
/>
)}
</ReduxForm> </ReduxForm>
) : null; ) : null;