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

View File

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

View File

@ -28,7 +28,7 @@ class InviteUserWidget extends React.Component {
this.state = {
loading: false,
email: null,
customFields: []
customFields: null
};
}
@ -41,17 +41,19 @@ class InviteUserWidget extends React.Component {
}
render() {
if(!this.state.customFields) return null;
return (
<Widget className={this.getClass()}>
<Header title={i18n('INVITE_USER')} description={i18n('INVITE_USER_VIEW_DESCRIPTION')} />
<Form {...this.getFormProps()}>
<div className="invite-user-widget__inputs">
<FormField {...this.getInputProps()} label={i18n('FULL_NAME')} name="name" validation="NAME" required/>
<FormField {...this.getInputProps()} label={i18n('EMAIL')} name="email" validation="EMAIL" required/>
<FormField {...this.getInputProps()} label={i18n('FULL_NAME')} name="name" validation="NAME" required />
<FormField {...this.getInputProps()} label={i18n('EMAIL')} name="email" validation="EMAIL" required />
{this.state.customFields.map(this.renderCustomField.bind(this))}
</div>
<div className="invite-user-widget__captcha">
<Captcha ref="captcha"/>
<Captcha ref="captcha" />
</div>
<div className="invite-user-widget__buttons-container">
<Button onClick={(e) => {e.preventDefault(); ModalContainer.closeModal();}} type="link">{i18n('CANCEL')}</Button>
@ -71,7 +73,7 @@ class InviteUserWidget extends React.Component {
key={key}
label={customField.name}
infoMessage={customField.description}
field="input"/>
field="input" />
);
} else {
const items = customField.options.map(option => ({content: option.name, value: option.name}));
@ -83,7 +85,7 @@ class InviteUserWidget extends React.Component {
label={customField.name}
infoMessage={customField.description}
field="select"
fieldProps={{size:'medium', items}}/>
fieldProps={{size: 'medium', items}} />
);
}
}

View File

@ -40,19 +40,20 @@ class MainSignUpWidget extends React.Component {
render() {
if(!this.state.customFields) return null;
return (
<Widget className={this.getClass()}>
<Header title={i18n('SIGN_UP')} description={i18n('SIGN_UP_VIEW_DESCRIPTION')} />
<Form {...this.getFormProps()}>
<div className="signup-widget__inputs">
<FormField {...this.getInputProps()} label={i18n('FULL_NAME')} name="name" validation="NAME" required/>
<FormField {...this.getInputProps()} label={i18n('EMAIL')} name="email" validation="EMAIL" required/>
<FormField {...this.getInputProps(true)} label={i18n('PASSWORD')} name="password" validation="PASSWORD" required/>
<FormField {...this.getInputProps(true)} label={i18n('REPEAT_PASSWORD')} name="repeated-password" validation="REPEAT_PASSWORD" required/>
<FormField {...this.getInputProps()} label={i18n('FULL_NAME')} name="name" validation="NAME" required />
<FormField {...this.getInputProps()} label={i18n('EMAIL')} name="email" validation="EMAIL" required />
<FormField {...this.getInputProps(true)} label={i18n('PASSWORD')} name="password" validation="PASSWORD" required />
<FormField {...this.getInputProps(true)} label={i18n('REPEAT_PASSWORD')} name="repeated-password" validation="REPEAT_PASSWORD" required />
{this.state.customFields.map(this.renderCustomField.bind(this))}
</div>
<div className="signup-widget__captcha">
<Captcha ref="captcha"/>
<Captcha ref="captcha" />
</div>
<SubmitButton type="primary">{i18n('SIGN_UP')}</SubmitButton>
</Form>
@ -70,7 +71,7 @@ class MainSignUpWidget extends React.Component {
key={key}
label={customField.name}
infoMessage={customField.description}
field="input"/>
field="input" />
);
} else {
const items = customField.options.map(option => ({content: option.name, value: option.name}));
@ -82,7 +83,7 @@ class MainSignUpWidget extends React.Component {
label={customField.name}
infoMessage={customField.description}
field="select"
fieldProps={{size:'medium', items}}/>
fieldProps={{size: 'medium', items}} />
);
}
}