Replaced many global Discourse.SiteSetting calls in templates with

computed properties due to deprecations.
This commit is contained in:
Robin Ward 2014-09-11 16:46:34 -04:00
parent 8559bbe508
commit f322b500a7
9 changed files with 15 additions and 35 deletions

View File

@ -19,6 +19,7 @@ export default DiscourseController.extend(ModalFunctionality, {
hasAuthOptions: Em.computed.notEmpty('authOptions'), hasAuthOptions: Em.computed.notEmpty('authOptions'),
canCreateLocal: Discourse.computed.setting('enable_local_logins'), canCreateLocal: Discourse.computed.setting('enable_local_logins'),
showCreateForm: Em.computed.or('hasAuthOptions', 'canCreateLocal'), showCreateForm: Em.computed.or('hasAuthOptions', 'canCreateLocal'),
maxUsernameLength: Discourse.computed.setting('max_username_length'),
resetForm: function() { resetForm: function() {
this.setProperties({ this.setProperties({
@ -200,7 +201,7 @@ export default DiscourseController.extend(ModalFunctionality, {
} }
// If too long // If too long
if (this.get('accountUsername').length > Discourse.SiteSettings.max_username_length) { if (this.get('accountUsername').length > this.get('maxUsernameLength')) {
return Discourse.InputValidation.create({ return Discourse.InputValidation.create({
failed: true, failed: true,
reason: I18n.t('user.username.too_long') reason: I18n.t('user.username.too_long')

View File

@ -1,5 +1,4 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality'; import ModalFunctionality from 'discourse/mixins/modal-functionality';
import DiscourseController from 'discourse/controllers/controller'; import DiscourseController from 'discourse/controllers/controller';
export default DiscourseController.extend(ModalFunctionality, { export default DiscourseController.extend(ModalFunctionality, {

View File

@ -1,18 +1,12 @@
import ObjectController from 'discourse/controllers/object'; import ObjectController from 'discourse/controllers/object';
/**
This controller supports actions related to updating one's preferences
@class PreferencesController
@extends ObjectController
@namespace Discourse
@module Discourse
**/
export default ObjectController.extend({ export default ObjectController.extend({
allowAvatarUpload: Discourse.computed.setting('allow_uploaded_avatars'), allowAvatarUpload: Discourse.computed.setting('allow_uploaded_avatars'),
allowUserLocale: Discourse.computed.setting('allow_user_locale'), allowUserLocale: Discourse.computed.setting('allow_user_locale'),
ssoOverridesAvatar: Discourse.computed.setting('sso_overrides_avatar'), ssoOverridesAvatar: Discourse.computed.setting('sso_overrides_avatar'),
allowBackgrounds: Discourse.computed.setting('allow_profile_backgrounds'),
editHistoryVisible: Discourse.computed.setting('edit_history_visible_to_public'),
selectedCategories: function(){ selectedCategories: function(){
return [].concat(this.get("watchedCategories"), this.get("trackedCategories"), this.get("mutedCategories")); return [].concat(this.get("watchedCategories"), this.get("trackedCategories"), this.get("mutedCategories"));

View File

@ -1,13 +1,5 @@
import ObjectController from 'discourse/controllers/object'; import ObjectController from 'discourse/controllers/object';
/**
This controller supports actions related to updating one's username
@class PreferencesUsernameController
@extends ObjectController
@namespace Discourse
@module Discourse
**/
export default ObjectController.extend({ export default ObjectController.extend({
taken: false, taken: false,
saving: false, saving: false,
@ -15,6 +7,7 @@ export default ObjectController.extend({
errorMessage: null, errorMessage: null,
newUsername: null, newUsername: null,
maxLength: Discourse.computed.setting('max_username_length'),
newUsernameEmpty: Em.computed.empty('newUsername'), newUsernameEmpty: Em.computed.empty('newUsername'),
saveDisabled: Em.computed.or('saving', 'newUsernameEmpty', 'taken', 'unchanged', 'errorMessage'), saveDisabled: Em.computed.or('saving', 'newUsernameEmpty', 'taken', 'unchanged', 'errorMessage'),
unchanged: Discourse.computed.propertyEqual('newUsername', 'username'), unchanged: Discourse.computed.propertyEqual('newUsername', 'username'),

View File

@ -1,13 +1,6 @@
<div class="modal-body"> <div class="modal-body">
{{#if hasAtLeastOneLoginButton}} {{login-buttons action="externalLogin"}}
<div id="login-buttons"> {{#if canLoginLocal}}
{{#each Discourse.LoginMethod.all}}
<button class="btn btn-social {{unbound name}}" {{action externalLogin this}}>{{unbound title}}</button>
{{/each}}
</div>
<div class="clearfix"></div>
{{/if}}
{{#if Discourse.SiteSettings.enable_local_logins}}
{{#if hasAtLeastOneLoginButton}} {{#if hasAtLeastOneLoginButton}}
<h3 style="text-align:center;">{{i18n login.or}}</h3> <h3 style="text-align:center;">{{i18n login.or}}</h3>
{{/if}} {{/if}}
@ -47,17 +40,17 @@
{{#if authenticate}} {{#if authenticate}}
{{i18n login.authenticating}} {{i18n login.authenticating}}
{{/if}} {{/if}}
{{#if Discourse.SiteSettings.enable_local_logins}} {{#if canLoginLocal}}
<button class='btn btn-large btn-primary' <button class='btn btn-large btn-primary'
{{bind-attr disabled="loginDisabled"}} {{bind-attr disabled="loginDisabled"}}
{{action login}}> {{action login}}>
<i class="fa fa-unlock"></i>&nbsp;{{loginButtonText}} <i class="fa fa-unlock"></i>&nbsp;{{loginButtonText}}
</button> </button>
{{#unless Discourse.SiteSettings.invite_only}} {{#if showSignupLink}}
<button class="btn btn-large" id="new-account-link" {{action showCreateAccount}}> <button class="btn btn-large" id="new-account-link" {{action showCreateAccount}}>
{{i18n create_account.title}} {{i18n create_account.title}}
</button> </button>
{{/unless}} {{/if}}
{{/if}} {{/if}}
</div> </div>

View File

@ -1,6 +1,6 @@
<div class="modal-body"> <div class="modal-body">
<form> <form>
{{view Discourse.ArchetypeOptionsView archetypeBinding="view.archetype"}} {{view "archetype-options" archetype=view.archetype}}
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -35,7 +35,7 @@
<tr class="input"> <tr class="input">
<td class="label"><label for='new-account-username'>{{i18n user.username.title}}</label></td> <td class="label"><label for='new-account-username'>{{i18n user.username.title}}</label></td>
<td> <td>
{{input value=accountUsername id="new-account-username" maxlength=Discourse.SiteSettings.max_username_length}} {{input value=accountUsername id="new-account-username" maxlength=maxUsernameLength}}
&nbsp;{{input-tip validation=usernameValidation id="username-validation"}} &nbsp;{{input-tip validation=usernameValidation id="username-validation"}}
</td> </td>
</tr> </tr>

View File

@ -88,7 +88,7 @@
</div> </div>
</div> </div>
{{#if Discourse.SiteSettings.allow_profile_backgrounds}} {{#if allowBackgrounds}}
<div class="control-group pref-profile-bg"> <div class="control-group pref-profile-bg">
<label class="control-label">{{i18n user.change_profile_background.title}}</label> <label class="control-label">{{i18n user.change_profile_background.title}}</label>
<div class="controls"> <div class="controls">
@ -167,7 +167,7 @@
{{preference-checkbox labelKey="user.enable_quoting" checked=enable_quoting}} {{preference-checkbox labelKey="user.enable_quoting" checked=enable_quoting}}
{{preference-checkbox labelKey="user.dynamic_favicon" checked=dynamic_favicon}} {{preference-checkbox labelKey="user.dynamic_favicon" checked=dynamic_favicon}}
{{preference-checkbox labelKey="user.disable_jump_reply" checked=disable_jump_reply}} {{preference-checkbox labelKey="user.disable_jump_reply" checked=disable_jump_reply}}
{{#unless Discourse.SiteSettings.edit_history_visible_to_public}} {{#unless editHistoryVisible}}
{{preference-checkbox labelKey="user.edit_history_public" checked=edit_history_public}} {{preference-checkbox labelKey="user.edit_history_public" checked=edit_history_public}}
{{/unless}} {{/unless}}
{{plugin-outlet "user_custom_preferences"}} {{plugin-outlet "user_custom_preferences"}}

View File

@ -18,7 +18,7 @@
<div class="control-group"> <div class="control-group">
<label class="control-label">{{i18n user.username.title}}</label> <label class="control-label">{{i18n user.username.title}}</label>
<div class="controls"> <div class="controls">
{{text-field value=newUsername id="change_username" classNames="input-xxlarge" maxlengthBinding="Discourse.SiteSettings.max_username_length"}} {{text-field value=newUsername id="change_username" classNames="input-xxlarge" maxlength=maxLength}}
</div> </div>
<div class='instructions'> <div class='instructions'>
{{#if taken}} {{#if taken}}