Fix bug custom fields default values undefined (#945)

* Fix bug in selected custom fields in admin panel invite user

* WIP

* Fix style

* WIP
This commit is contained in:
LautaroCesso 2020-12-26 17:39:51 -03:00 committed by GitHub
parent a7cb7f376c
commit 534bf3624a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 48 deletions

View File

@ -51,14 +51,7 @@ class AdminPanelViewUser extends React.Component {
} }
renderUserInfo() { renderUserInfo() {
const { const { name, disabled, email, verified, customfields, loading } = this.state;
name,
disabled,
email,
verified,
customfields,
loading
} = this.state;
return ( return (
<div className="admin-panel-view-user__content"> <div className="admin-panel-view-user__content">
@ -187,10 +180,7 @@ class AdminPanelViewUser extends React.Component {
const authorsListWithoutMe = r.data.authors.filter(author => author.id != this.props.params.userId); const authorsListWithoutMe = r.data.authors.filter(author => author.id != this.props.params.userId);
return authorsListWithoutMe.map(author => { return authorsListWithoutMe.map(author => {
const { const { id, name } = author;
id,
name
} = author;
return { return {
name, name,
@ -207,10 +197,7 @@ class AdminPanelViewUser extends React.Component {
transformUserListToAutocomplete() { transformUserListToAutocomplete() {
return( return(
this.state.userList.map((user) => { this.state.userList.map((user) => {
const { const { id, name } = user;
id,
name
} = user;
return ({ return ({
id: id*1, id: id*1,
@ -236,27 +223,20 @@ class AdminPanelViewUser extends React.Component {
} }
renderCustomField(_customfield) { renderCustomField(_customfield) {
const { const { customfield, value, id } = _customfield;
customfield,
value,
id
} = _customfield;
return ( return (
<div className="admin-panel-view-user__info-item" key={`customFieldId__${id}`}> <div className="admin-panel-view-user__info-item" key={`customFieldId__${id}`}>
{customfield} {customfield}
<div className="admin-panel-view-user__info-box"> <div className="admin-panel-view-user__info-box">
{value} {(value !== "") ? value : <div className="admin-panel-view-user__empty-content">Empty</div>}
</div> </div>
</div> </div>
); );
} }
getTicketListProps() { getTicketListProps() {
const { const { tickets, loading } = this.state;
tickets,
loading
} = this.state;
return { return {
type: 'secondary', type: 'secondary',
@ -268,15 +248,7 @@ class AdminPanelViewUser extends React.Component {
} }
onUserRetrieved(result) { onUserRetrieved(result) {
const { const { name, email, verified, tickets, disabled, customfields, userList } = result.data;
name,
email,
verified,
tickets,
disabled,
customfields,
userList
} = result.data;
this.setState({ this.setState({
name, name,

View File

@ -9,6 +9,7 @@
display: inline-block; display: inline-block;
margin-right: 20px; margin-right: 20px;
min-width: 200px; min-width: 200px;
margin-top: 10px;
} }
&-box { &-box {
@ -20,6 +21,11 @@
} }
} }
&__empty-content {
font-style: italic;
color: $dark-grey;
}
&__action-buttons { &__action-buttons {
margin-top: 20px; margin-top: 20px;
} }

View File

@ -28,7 +28,7 @@ class InviteUserWidget extends React.Component {
this.state = { this.state = {
loading: false, loading: false,
email: null, email: null,
customFields: [] customFields: null
}; };
} }
@ -41,6 +41,8 @@ class InviteUserWidget extends React.Component {
} }
render() { render() {
if(!this.state.customFields) return null;
return ( return (
<Widget className={this.getClass()}> <Widget className={this.getClass()}>
<Header title={i18n('INVITE_USER')} description={i18n('INVITE_USER_VIEW_DESCRIPTION')} /> <Header title={i18n('INVITE_USER')} description={i18n('INVITE_USER_VIEW_DESCRIPTION')} />

View File

@ -40,6 +40,7 @@ class MainSignUpWidget extends React.Component {
render() { render() {
if(!this.state.customFields) return null; if(!this.state.customFields) return null;
return ( return (
<Widget className={this.getClass()}> <Widget className={this.getClass()}>
<Header title={i18n('SIGN_UP')} description={i18n('SIGN_UP_VIEW_DESCRIPTION')} /> <Header title={i18n('SIGN_UP')} description={i18n('SIGN_UP_VIEW_DESCRIPTION')} />