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:
parent
a7cb7f376c
commit
534bf3624a
|
@ -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,
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,17 +41,19 @@ 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')} />
|
||||||
<Form {...this.getFormProps()}>
|
<Form {...this.getFormProps()}>
|
||||||
<div className="invite-user-widget__inputs">
|
<div className="invite-user-widget__inputs">
|
||||||
<FormField {...this.getInputProps()} label={i18n('FULL_NAME')} name="name" validation="NAME" 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()} label={i18n('EMAIL')} name="email" validation="EMAIL" required />
|
||||||
{this.state.customFields.map(this.renderCustomField.bind(this))}
|
{this.state.customFields.map(this.renderCustomField.bind(this))}
|
||||||
</div>
|
</div>
|
||||||
<div className="invite-user-widget__captcha">
|
<div className="invite-user-widget__captcha">
|
||||||
<Captcha ref="captcha"/>
|
<Captcha ref="captcha" />
|
||||||
</div>
|
</div>
|
||||||
<div className="invite-user-widget__buttons-container">
|
<div className="invite-user-widget__buttons-container">
|
||||||
<Button onClick={(e) => {e.preventDefault(); ModalContainer.closeModal();}} type="link">{i18n('CANCEL')}</Button>
|
<Button onClick={(e) => {e.preventDefault(); ModalContainer.closeModal();}} type="link">{i18n('CANCEL')}</Button>
|
||||||
|
@ -71,7 +73,7 @@ class InviteUserWidget extends React.Component {
|
||||||
key={key}
|
key={key}
|
||||||
label={customField.name}
|
label={customField.name}
|
||||||
infoMessage={customField.description}
|
infoMessage={customField.description}
|
||||||
field="input"/>
|
field="input" />
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const items = customField.options.map(option => ({content: option.name, value: option.name}));
|
const items = customField.options.map(option => ({content: option.name, value: option.name}));
|
||||||
|
@ -83,7 +85,7 @@ class InviteUserWidget extends React.Component {
|
||||||
label={customField.name}
|
label={customField.name}
|
||||||
infoMessage={customField.description}
|
infoMessage={customField.description}
|
||||||
field="select"
|
field="select"
|
||||||
fieldProps={{size:'medium', items}}/>
|
fieldProps={{size: 'medium', items}} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,19 +40,20 @@ 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')} />
|
||||||
<Form {...this.getFormProps()}>
|
<Form {...this.getFormProps()}>
|
||||||
<div className="signup-widget__inputs">
|
<div className="signup-widget__inputs">
|
||||||
<FormField {...this.getInputProps()} label={i18n('FULL_NAME')} name="name" validation="NAME" 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()} 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('PASSWORD')} name="password" validation="PASSWORD" required />
|
||||||
<FormField {...this.getInputProps(true)} label={i18n('REPEAT_PASSWORD')} name="repeated-password" validation="REPEAT_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))}
|
{this.state.customFields.map(this.renderCustomField.bind(this))}
|
||||||
</div>
|
</div>
|
||||||
<div className="signup-widget__captcha">
|
<div className="signup-widget__captcha">
|
||||||
<Captcha ref="captcha"/>
|
<Captcha ref="captcha" />
|
||||||
</div>
|
</div>
|
||||||
<SubmitButton type="primary">{i18n('SIGN_UP')}</SubmitButton>
|
<SubmitButton type="primary">{i18n('SIGN_UP')}</SubmitButton>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -70,7 +71,7 @@ class MainSignUpWidget extends React.Component {
|
||||||
key={key}
|
key={key}
|
||||||
label={customField.name}
|
label={customField.name}
|
||||||
infoMessage={customField.description}
|
infoMessage={customField.description}
|
||||||
field="input"/>
|
field="input" />
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const items = customField.options.map(option => ({content: option.name, value: option.name}));
|
const items = customField.options.map(option => ({content: option.name, value: option.name}));
|
||||||
|
@ -82,7 +83,7 @@ class MainSignUpWidget extends React.Component {
|
||||||
label={customField.name}
|
label={customField.name}
|
||||||
infoMessage={customField.description}
|
infoMessage={customField.description}
|
||||||
field="select"
|
field="select"
|
||||||
fieldProps={{size:'medium', items}}/>
|
fieldProps={{size: 'medium', items}} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue