FEATURE: Add an option to show custom user fields on profiles. Default is to not show them.
This commit is contained in:
parent
22adb682d8
commit
644c7a4675
|
@ -17,15 +17,18 @@ export default Ember.ObjectController.extend(BufferedContent, {
|
|||
if (this.get('required')) {
|
||||
ret.push(I18n.t('admin.user_fields.required.enabled'));
|
||||
}
|
||||
if (this.get('show_on_profile')) {
|
||||
ret.push(I18n.t('admin.user_fields.show_on_profile.enabled'));
|
||||
}
|
||||
|
||||
return ret.join(', ');
|
||||
}.property('editable', 'required'),
|
||||
}.property('editable', 'required', 'show_on_profile'),
|
||||
|
||||
actions: {
|
||||
save: function() {
|
||||
var self = this;
|
||||
|
||||
var attrs = this.get('buffered').getProperties('name', 'description', 'field_type', 'editable', 'required');
|
||||
var attrs = this.get('buffered').getProperties('name', 'description', 'field_type', 'editable', 'required', 'show_on_profile');
|
||||
|
||||
this.get('model').save(attrs).then(function(res) {
|
||||
self.set('model.id', res.user_field.id);
|
||||
|
|
|
@ -32,6 +32,11 @@
|
|||
{{input type="checkbox" checked=f.buffered.required}} {{i18n 'admin.user_fields.required.title'}}
|
||||
</label>
|
||||
</div>
|
||||
<div class='form-element'>
|
||||
<label>
|
||||
{{input type="checkbox" checked=f.buffered.show_on_profile}} {{i18n 'admin.user_fields.show_on_profile.title'}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="row">
|
||||
|
|
|
@ -42,6 +42,21 @@ export default ObjectController.extend(CanCheckEmails, {
|
|||
return this.get('can_be_deleted') && this.get('can_delete_all_posts');
|
||||
}.property('can_be_deleted', 'can_delete_all_posts'),
|
||||
|
||||
publicUserFields: function() {
|
||||
var siteUserFields = this.site.get('user_fields');
|
||||
if (!Ember.isEmpty(siteUserFields)) {
|
||||
var userFields = this.get('user_fields');
|
||||
return siteUserFields.filterProperty('show_on_profile', true).sortBy('id').map(function(uf) {
|
||||
var val = userFields ? userFields[uf.get('id').toString()] : null;
|
||||
if (Ember.isEmpty(val)) {
|
||||
return null;
|
||||
} else {
|
||||
return Ember.Object.create({value: val, field: uf});
|
||||
}
|
||||
}).compact();
|
||||
}
|
||||
}.property('user_fields.@each.value'),
|
||||
|
||||
privateMessagesActive: Em.computed.equal('pmView', 'index'),
|
||||
privateMessagesMineActive: Em.computed.equal('pmView', 'mine'),
|
||||
privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread'),
|
||||
|
|
|
@ -89,6 +89,19 @@
|
|||
{{{bio_cooked}}}
|
||||
</div>
|
||||
|
||||
{{#if publicUserFields}}
|
||||
<div class="public-user-fields">
|
||||
{{#each uf in publicUserFields}}
|
||||
{{#if uf.value}}
|
||||
<div class="public-user-field">
|
||||
<span class="user-field-name">{{uf.field.name}}</span>:
|
||||
<span class="user-field-value">{{uf.value}}</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{plugin-outlet "user-profile-primary"}}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -24,6 +24,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
.public-user-fields {
|
||||
.user-field-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.collapsed-info .public-user-fields {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.notification-buttons {
|
||||
margin: 10px 0;
|
||||
text-align: right;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Admin::UserFieldsController < Admin::AdminController
|
||||
|
||||
def self.columns
|
||||
[:name, :field_type, :editable, :description, :required]
|
||||
[:name, :field_type, :editable, :description, :required, :show_on_profile]
|
||||
end
|
||||
|
||||
def create
|
||||
|
|
|
@ -4,5 +4,6 @@ class UserFieldSerializer < ApplicationSerializer
|
|||
:description,
|
||||
:field_type,
|
||||
:editable,
|
||||
:required
|
||||
:required,
|
||||
:show_on_profile
|
||||
end
|
||||
|
|
|
@ -2108,6 +2108,10 @@ en:
|
|||
title: "Editable after signup?"
|
||||
enabled: "editable"
|
||||
disabled: "not editable"
|
||||
show_on_profile:
|
||||
title: "Show on public profile?"
|
||||
enabled: "shown on profile"
|
||||
disabled: "not shown on profile"
|
||||
|
||||
field_types:
|
||||
text: 'Text Field'
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddShowOnProfileToUserFields < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :user_fields, :show_on_profile, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue