From 1ceb1b4014bc16f2cee8d44495b0bf68948b8236 Mon Sep 17 00:00:00 2001 From: okbel Date: Tue, 10 Apr 2018 11:46:32 -0300 Subject: [PATCH] Save, and edit changes --- .../routes/Configure/components/Configure.js | 13 +++- .../components/OrganizationSettings.css | 27 +++++--- .../components/OrganizationSettings.js | 63 ++++++++++++++----- .../routes/Configure/containers/Configure.js | 5 +- locales/en.yml | 2 + locales/es.yml | 2 + 6 files changed, 88 insertions(+), 24 deletions(-) diff --git a/client/coral-admin/src/routes/Configure/components/Configure.js b/client/coral-admin/src/routes/Configure/components/Configure.js index 69ab4f06c..bcd48c21c 100644 --- a/client/coral-admin/src/routes/Configure/components/Configure.js +++ b/client/coral-admin/src/routes/Configure/components/Configure.js @@ -8,7 +8,14 @@ import SaveChangesDialog from './SaveChangesDialog'; class Configure extends React.Component { render() { - const { canSave, currentUser, root, savePending, settings } = this.props; + const { + canSave, + currentUser, + root, + savePending, + settings, + clearPending, + } = this.props; if (!can(currentUser, 'UPDATE_CONFIG')) { return

{t('configure.access_message')}

; @@ -17,6 +24,9 @@ class Configure extends React.Component { const passProps = { root, settings, + savePending, + clearPending, + canSave, }; return ( @@ -84,6 +94,7 @@ Configure.propTypes = { children: PropTypes.node.isRequired, saveDialog: PropTypes.bool, hideSaveDialog: PropTypes.func.isRequired, + clearPending: PropTypes.func.isRequired, }; export default Configure; diff --git a/client/coral-admin/src/routes/Configure/components/OrganizationSettings.css b/client/coral-admin/src/routes/Configure/components/OrganizationSettings.css index 06ada55c4..d28fced83 100644 --- a/client/coral-admin/src/routes/Configure/components/OrganizationSettings.css +++ b/client/coral-admin/src/routes/Configure/components/OrganizationSettings.css @@ -16,7 +16,7 @@ } .detailValue { - padding: 6px 10px; + padding: 6px 0; border: solid 1px transparent; display: block; font-size: 1em; @@ -24,6 +24,8 @@ } .editable { + padding-left: 10px; + padding-right: 10px; border-color: grey; } @@ -32,20 +34,31 @@ list-style: none; } -.editButton { - position: absolute; - right: 10px; - top: 10px; +.button, .button:disabled { + background: white; + border: solid 1px grey; } .actionBox { position: absolute; - right: 10px; - top: 10px; + right: 20px; + top: 20px; text-align: center; + width: 100px; } .cancelButton { padding: 10px; display: block; + color: #4f5c67; + font-weight: 500; + + &:hover { + cursor: pointer; + } +} + +.changedSave { + background-color: #00796B; + color: white; } \ No newline at end of file diff --git a/client/coral-admin/src/routes/Configure/components/OrganizationSettings.js b/client/coral-admin/src/routes/Configure/components/OrganizationSettings.js index 18fe653e1..06c91926c 100644 --- a/client/coral-admin/src/routes/Configure/components/OrganizationSettings.js +++ b/client/coral-admin/src/routes/Configure/components/OrganizationSettings.js @@ -17,6 +17,12 @@ class OrganizationSettings extends React.Component { })); }; + disableEditing = () => { + this.setState(() => ({ + editing: false, + })); + }; + updateName = event => { const updater = { organizationName: { $set: event.target.value } }; this.props.updatePending({ updater }); @@ -27,32 +33,56 @@ class OrganizationSettings extends React.Component { this.props.updatePending({ updater }); }; + cancelEditing = () => { + this.disableEditing(); + this.props.clearPending(); + }; + + save = async () => { + await this.props.savePending(); + this.disableEditing(); + }; + render() { - const { settings, slotPassthrough } = this.props; + const { settings, slotPassthrough, canSave } = this.props; return (

{t('configure.organization_info_copy')}

{t('configure.organization_info_copy_2')}

{!this.state.editing ? ( - +
+ +
) : (
- - Cancel + {canSave ? ( + + ) : ( + + )} + + {t('cancel')} +
)} - - {console.log(this.props.slotPassthrough)} -