1
0
mirror of https://github.com/flarum/core.git synced 2025-07-31 13:40:20 +02:00

Don't show username/email fields when editing own account. fixes #903

This commit is contained in:
Toby Zerner
2016-04-08 13:40:37 +09:30
parent 66a39bbbf5
commit 0f975da403
2 changed files with 45 additions and 46 deletions

26
js/forum/dist/app.js vendored
View File

@@ -21756,10 +21756,9 @@ System.register('flarum/components/EditUserModal', ['flarum/components/Modal', '
'Username' 'Username'
), ),
m('input', { className: 'FormControl', placeholder: extractText(app.translator.trans('core.forum.edit_user.username_label')), m('input', { className: 'FormControl', placeholder: extractText(app.translator.trans('core.forum.edit_user.username_label')),
value: this.username(), bidi: this.username })
onchange: m.withAttr('value', this.username) })
), ),
m( app.session.user !== this.props.user ? [m(
'div', 'div',
{ className: 'Form-group' }, { className: 'Form-group' },
m( m(
@@ -21771,11 +21770,9 @@ System.register('flarum/components/EditUserModal', ['flarum/components/Modal', '
'div', 'div',
null, null,
m('input', { className: 'FormControl', placeholder: extractText(app.translator.trans('core.forum.edit_user.email_label')), m('input', { className: 'FormControl', placeholder: extractText(app.translator.trans('core.forum.edit_user.email_label')),
value: this.email(), bidi: this.email })
onchange: m.withAttr('value', this.email) })
) )
), ), m(
m(
'div', 'div',
{ className: 'Form-group' }, { className: 'Form-group' },
m( m(
@@ -21798,10 +21795,9 @@ System.register('flarum/components/EditUserModal', ['flarum/components/Modal', '
'Set new password' 'Set new password'
), ),
this.setPassword() ? m('input', { className: 'FormControl', type: 'password', name: 'password', placeholder: extractText(app.translator.trans('core.forum.edit_user.password_label')), this.setPassword() ? m('input', { className: 'FormControl', type: 'password', name: 'password', placeholder: extractText(app.translator.trans('core.forum.edit_user.password_label')),
value: this.password(), bidi: this.password }) : ''
onchange: m.withAttr('value', this.password) }) : ''
) )
), )] : '',
m( m(
'div', 'div',
{ className: 'Form-group EditUserModal-groups' }, { className: 'Form-group EditUserModal-groups' },
@@ -21820,9 +21816,8 @@ System.register('flarum/components/EditUserModal', ['flarum/components/Modal', '
'label', 'label',
{ className: 'checkbox' }, { className: 'checkbox' },
m('input', { type: 'checkbox', m('input', { type: 'checkbox',
checked: _this3.groups[group.id()](), bidi: _this3.groups[group.id()],
disabled: _this3.props.user.id() === '1' && group.id() === Group.ADMINISTRATOR_ID, disabled: _this3.props.user.id() === '1' && group.id() === Group.ADMINISTRATOR_ID }),
onchange: m.withAttr('checked', _this3.groups[group.id()]) }),
GroupBadge.component({ group: group, label: '' }), GroupBadge.component({ group: group, label: '' }),
' ', ' ',
group.nameSingular() group.nameSingular()
@@ -21856,10 +21851,13 @@ System.register('flarum/components/EditUserModal', ['flarum/components/Modal', '
var data = { var data = {
username: this.username(), username: this.username(),
email: this.email(),
relationships: { groups: groups } relationships: { groups: groups }
}; };
if (app.session.user !== this.props.user) {
data.email = this.email();
}
if (this.setPassword()) { if (this.setPassword()) {
data.password = this.password(); data.password = this.password();
} }

View File

@@ -39,38 +39,37 @@ export default class EditUserModal extends Modal {
<div className="Form-group"> <div className="Form-group">
<label>Username</label> <label>Username</label>
<input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.username_label'))} <input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.username_label'))}
value={this.username()} bidi={this.username} />
onchange={m.withAttr('value', this.username)} />
</div> </div>
<div className="Form-group"> {app.session.user !== this.props.user ? [
<label>Email</label> <div className="Form-group">
<div> <label>Email</label>
<input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.email_label'))} <div>
value={this.email()} <input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.email_label'))}
onchange={m.withAttr('value', this.email)} /> bidi={this.email} />
</div> </div>
</div> </div>,
<div className="Form-group"> <div className="Form-group">
<label>Password</label> <label>Password</label>
<div> <div>
<label className="checkbox"> <label className="checkbox">
<input type="checkbox" checked={this.setPassword()} onchange={e => { <input type="checkbox" checked={this.setPassword()} onchange={e => {
this.setPassword(e.target.checked); this.setPassword(e.target.checked);
m.redraw(true); m.redraw(true);
if (e.target.checked) this.$('[name=password]').select(); if (e.target.checked) this.$('[name=password]').select();
m.redraw.strategy('none'); m.redraw.strategy('none');
}}/> }}/>
Set new password Set new password
</label> </label>
{this.setPassword() ? ( {this.setPassword() ? (
<input className="FormControl" type="password" name="password" placeholder={extractText(app.translator.trans('core.forum.edit_user.password_label'))} <input className="FormControl" type="password" name="password" placeholder={extractText(app.translator.trans('core.forum.edit_user.password_label'))}
value={this.password()} bidi={this.password} />
onchange={m.withAttr('value', this.password)} /> ) : ''}
) : ''} </div>
</div> </div>
</div> ] : ''}
<div className="Form-group EditUserModal-groups"> <div className="Form-group EditUserModal-groups">
<label>Groups</label> <label>Groups</label>
@@ -80,9 +79,8 @@ export default class EditUserModal extends Modal {
.map(group => ( .map(group => (
<label className="checkbox"> <label className="checkbox">
<input type="checkbox" <input type="checkbox"
checked={this.groups[group.id()]()} bidi={this.groups[group.id()]}
disabled={this.props.user.id() === '1' && group.id() === Group.ADMINISTRATOR_ID} disabled={this.props.user.id() === '1' && group.id() === Group.ADMINISTRATOR_ID} />
onchange={m.withAttr('checked', this.groups[group.id()])}/>
{GroupBadge.component({group, label: ''})} {group.nameSingular()} {GroupBadge.component({group, label: ''})} {group.nameSingular()}
</label> </label>
))} ))}
@@ -109,10 +107,13 @@ export default class EditUserModal extends Modal {
const data = { const data = {
username: this.username(), username: this.username(),
email: this.email(),
relationships: {groups} relationships: {groups}
}; };
if (app.session.user !== this.props.user) {
data.email = this.email();
}
if (this.setPassword()) { if (this.setPassword()) {
data.password = this.password(); data.password = this.password();
} }