Removed many unnecessary controller. uses in templates.

This commit is contained in:
Robin Ward 2013-05-20 13:42:26 -04:00
parent c7aebbf4d6
commit a79d53c628
21 changed files with 125 additions and 110 deletions

View File

@ -4,7 +4,7 @@
</div>
<div class='span10 controls'>
<button class='btn' {{action sendTestEmail}} {{bindAttr disabled="sendTestEmailDisabled"}}>{{i18n admin.email_logs.send_test}}</button>
{{#if controller.sentTestEmail}}<span class='result-message'>{{i18n admin.email_logs.sent_test}}</span>{{/if}}
{{#if sentTestEmail}}<span class='result-message'>{{i18n admin.email_logs.sent_test}}</span>{{/if}}
</div>
</div>

View File

@ -7,7 +7,6 @@
</div>
</div>
<table class='admin-flags'>
<thead>
<tr>
@ -27,7 +26,7 @@
<td class='flaggers'>{{#each flaggers}}{{#linkTo 'adminUser' this}}{{avatar this imageSize="small"}} {{/linkTo}}{{/each}}</td>
<td class='last-flagged'>{{date lastFlagged}}</td>
<td class='action'>
{{#if controller.adminActiveFlagsView}}
{{#if adminActiveFlagsView}}
<button title='{{i18n admin.flags.clear_title}}' class='btn' {{action clearFlags this}}>{{i18n admin.flags.clear}}</button>
<button title='{{i18n admin.flags.delete_title}}' class='btn' {{action deletePost this}}>{{i18n admin.flags.delete}}</button>
{{/if}}

View File

@ -15,16 +15,16 @@
<th>{{yaxis}}</th>
</tr>
{{#each data}}
{{#each row in data}}
<tr>
<td>{{x}}</td>
<td>{{row.x}}</td>
<td>
{{#if controller.viewingTable}}
{{y}}
{{#if viewingTable}}
{{row.y}}
{{/if}}
{{#if controller.viewingBarChart}}
{{#if viewingBarChart}}
<div class='bar-container'>
<div class='bar' style="width: {{unbound percentage}}%">{{y}}</div>
<div class='bar' style="width: {{unbound row.percentage}}%">{{row.y}}</div>
</div>
{{/if}}
</td>

View File

@ -8,6 +8,10 @@
**/
Discourse.PreferencesEmailRoute = Discourse.RestrictedUserRoute.extend({
model: function() {
return this.modelFor('user');
},
renderTemplate: function() {
this.render({ into: 'user', outlet: 'userOutlet' });
},
@ -20,10 +24,6 @@ Discourse.PreferencesEmailRoute = Discourse.RestrictedUserRoute.extend({
outlet: 'userOutlet',
controller: 'preferences'
});
},
setupController: function(controller) {
controller.set('content', this.controllerFor('user').get('content'));
}
});

View File

@ -8,16 +8,16 @@
**/
Discourse.PreferencesRoute = Discourse.RestrictedUserRoute.extend({
model: function() {
return this.modelFor('user');
},
renderTemplate: function() {
this.render('preferences', {
into: 'user',
outlet: 'userOutlet',
controller: 'preferences'
});
},
setupController: function(controller) {
controller.set('content', this.controllerFor('user').get('content'));
}
});

View File

@ -8,6 +8,10 @@
**/
Discourse.PreferencesUsernameRoute = Discourse.RestrictedUserRoute.extend({
model: function() {
return this.modelFor('user');
},
renderTemplate: function() {
return this.render({ into: 'user', outlet: 'userOutlet' });
},
@ -22,10 +26,8 @@ Discourse.PreferencesUsernameRoute = Discourse.RestrictedUserRoute.extend({
});
},
setupController: function(controller) {
var user = this.controllerFor('user').get('content');
controller.set('content', user);
return controller.set('newUsername', user.get('username'));
setupController: function(controller, user) {
controller.set('newUsername', user.get('username'));
}
});

View File

@ -5,7 +5,7 @@
<div class='composer-popup-container'>
<div id='new-user-education' class='composer-popup' style='display: none'>
<a href='#' {{action closeEducation}} class='close'><i class='icon icon-remove-sign'></i></a>
{{{controller.educationContents}}}
{{{educationContents}}}
</div>
<div id='similar-topics' class='composer-popup' style='display: none'>
@ -13,7 +13,7 @@
<h3>{{i18n composer.similar_topics}}<h3>
<ul class='topics'>
{{#each controller.similarTopics}}
{{#each similarTopics}}
<li>{{{topicLink this}}} <span class='posts-count'>({{{i18n topic.filters.n_posts count="posts_count"}}})</span></li>
{{/each}}
</ul>
@ -55,7 +55,7 @@
{{view Discourse.NotifyingTextArea parentBinding="view" tabindex="3" valueBinding="content.reply" id="wmd-input" placeholderKey="composer.reply_placeholder"}}
</div>
<div class='preview-wrapper'>
<div id='wmd-preview' {{bindAttr class="controller.hidePreview:hidden"}}></div>
<div id='wmd-preview' {{bindAttr class="hidePreview:hidden"}}></div>
</div>
{{#if Discourse.currentUser}}
<a href="#" {{action togglePreview target="controller"}} class='toggle-preview'>{{{content.toggleText}}}</a>

View File

@ -5,7 +5,7 @@
{{view Discourse.TopicExtraInfoView}}
<div class='panel clearfix'>
{{#unless controller.showExtraInfo}}
{{#unless showExtraInfo}}
<div class='current-username'>
{{#if view.currentUser}}
<span class='username'><a {{bindAttr href="view.currentUser.path"}}>{{view.currentUser.name}}</a></span>

View File

@ -1,20 +1,20 @@
<div id='list-controls'>
<div class="container">
<ul class="nav nav-pills" id='category-filter'>
{{#each controller.availableNavItems}}
{{#each availableNavItems}}
{{view Discourse.NavItemView contentBinding="this"}}
{{/each}}
</ul>
{{#if controller.canCreateTopic}}
{{#if canCreateTopic}}
<button class='btn btn-default' {{action createTopic target="controller"}}><i class='icon icon-plus'></i>{{view.createTopicText}}</button>
{{/if}}
{{#if controller.canEditCategory}}
{{#if canEditCategory}}
<button class='btn btn-default' {{action editCategory target="controller"}}>{{i18n category.edit_long}}</button>
{{/if}}
{{#if controller.canCreateCategory}}
{{#if canCreateCategory}}
<button class='btn btn-default' {{action createCategory target="controller"}}><i class='icon icon-plus'></i>{{i18n category.create}}</button>
{{/if}}
@ -26,7 +26,7 @@
<div class="full-width">
<div id='list-area'>
{{#if controller.loading}}
{{#if loading}}
<div class='contents loading'>
<table id='topic-list'>
<tr>

View File

@ -1,7 +1,7 @@
{{#if Discourse.currentUser.id}}
<td class='star'>
<a {{bindAttr class=":star :icon-star starred:starred"}} {{action toggleStar this target="controller"}} href='#' {{bindAttr title="favoriteTooltip"}}></a>
<a {{bindAttr class=":star :icon-star starred:starred"}} {{action toggleStar this}} href='#' {{bindAttr title="favoriteTooltip"}}></a>
</td>
{{/if}}
@ -18,7 +18,7 @@
{{/if}}
{{view Discourse.TopicStatusView topicBinding="this"}}
{{{topicLink this showTagIfPresent="controller.category"}}}
{{{topicLink this}}}
{{#if unread}}
<a href="{{lastReadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts unread="unread"}}'>{{unread}}</a>
{{/if}}

View File

@ -1,4 +1,4 @@
{{#unless controller.loading}}
{{#unless loading}}
{{#if loaded}}
<div class='contents'>
{{#if topics.length}}
@ -10,7 +10,7 @@
</button>
{{/if}}
<table id='topic-list' {{bindAttr class="controller.category:filter-category"}}>
<table id='topic-list'>
<thead>
<tr>
{{#if Discourse.currentUser}}
@ -62,7 +62,8 @@
<h3>
{{view.footerMessage}}
{{#if view.allLoaded}}
{{#if controller.latest}}
{{#if latest}}
{{#if view.canCreateTopic}}
<a href='#' {{action createTopic}}>{{i18n topic.suggest_create_topic}}</a>
{{/if}}

View File

@ -1,4 +1,4 @@
<p>{{countI18n topic.multi_select.description countBinding="controller.selectedPostsCount"}}</p>
<p>{{countI18n topic.multi_select.description countBinding="selectedPostsCount"}}</p>
{{#if canSelectAll}}
<p><a href='#' {{action selectAll}}>select all</a></p>

View File

@ -1,10 +1,10 @@
<h3>{{view.title}}</h3>
<div><input type='text' /></div>
{{#each controller.shareLinks}}
{{#each shareLinks}}
{{view Discourse.ShareLinkView contentBinding="this"}}
{{/each}}
<div class='link'>
<a href='#' {{action close target="controller"}} title='{{i18n share.close}}'><i class="icon icon-remove-sign"></i></a>
<a href='#' {{action close}} title='{{i18n share.close}}'><i class="icon icon-remove-sign"></i></a>
</div>

View File

@ -73,11 +73,11 @@
{{else}}
{{#if view.fullyLoaded}}
{{view Discourse.TopicClosingView topicBinding="controller.content"}}
{{view Discourse.TopicClosingView topicBinding="model"}}
{{view Discourse.TopicFooterButtonsView topicBinding="controller.content"}}
{{view Discourse.TopicFooterButtonsView topicBinding="model"}}
{{#if controller.content.suggested_topics.length}}
{{#if suggested_topics.length}}
<div id='suggested-topics'>
<h3>{{i18n suggested_topics.title}}</h3>
@ -95,7 +95,7 @@
<th class='num activity' colspan='2'>{{i18n activity}}</th>
</tr>
{{each controller.content.suggested_topics itemTagName="tr" itemViewClass="Discourse.SuggestedTopicView"}}
{{each suggested_topics itemTagName="tr" itemViewClass="Discourse.SuggestedTopicView"}}
</table>
</div>
<br/>

View File

@ -1,8 +1,8 @@
<h3><i class='icon icon-bullhorn'></i> {{i18n best_of.title}}</h3>
{{#if controller.bestOf}}
{{#if bestOf}}
<p>{{{i18n best_of.enabled_description}}}</p>
<button class='btn' {{action cancelFilter}}>{{i18n best_of.disable}}</button>
{{else}}
<p>{{{i18n best_of.description count="controller.content.posts_count"}}}</p>
<p>{{{i18n best_of.description count="posts_count"}}}</p>
<button class='btn' {{action enableBestOf}}>{{i18n best_of.enable}}</button>
{{/if}}

View File

@ -1,5 +1,5 @@
<nav class='buttons'>
{{#if controller.summaryCollapsed}}
{{#if summaryCollapsed}}
<button class='btn collapsed' {{action toggleSummary}} title="{{i18n topic.toggle_information}}">
<i class='icon icon-chevron-down'></i>
</button>
@ -11,7 +11,7 @@
</nav>
{{#if controller.summaryCollapsed}}
{{#if summaryCollapsed}}
<section class='summary collapsed'>
<ul class="clearfix">
<li>

View File

@ -1,11 +1,11 @@
<h3><i class='icon icon-envelope-alt'></i> {{i18n private_message_info.title}}</h3>
<div class='participants clearfix'>
{{#each content.allowed_groups}}
{{#each allowed_groups}}
<div class='user group'>
#{{unbound name}}
</div>
{{/each}}
{{#each content.allowed_users}}
{{#each allowed_users}}
<div class='user'>
<a href='/users/{{lower username}}'>
{{avatar this imageSize="small"}}
@ -16,8 +16,8 @@
</div>
{{/each}}
</div>
{{#if controller.content.can_invite_to}}
{{#if can_invite_to}}
<div class='controls'>
<button class='btn' {{action showPrivateInviteModal target="controller"}}>{{i18n private_message_info.invite}}</button>
<button class='btn' {{action showPrivateInviteModal}}>{{i18n private_message_info.invite}}</button>
</div>
{{/if}}

View File

@ -27,7 +27,7 @@
{{textField value=newEmail elementId="change_email" classNames="input-xxlarge"}}
</div>
<div class='instructions'>
{{#if controller.taken}}
{{#if taken}}
{{i18n user.change_email.taken}}
{{else}}
{{i18n user.email.instructions}}
@ -38,7 +38,7 @@
<div class="control-group">
<div class="controls">
<button {{action changeEmail target="controller"}} {{bindAttr disabled="controller.saveDisabled"}} class="btn btn-primary">{{controller.saveButtonText}}</button>
<button {{action changeEmail}} {{bindAttr disabled="saveDisabled"}} class="btn btn-primary">{{saveButtonText}}</button>
</div>
</div>
{{/if}}

View File

@ -3,11 +3,11 @@
<div class="control-group">
<label class="control-label">{{i18n user.username.title}}</label>
<div class="controls">
<span class='static'>{{content.username}}</span>
<span class='static'>{{username}}</span>
{{#linkTo "preferences.username" class="btn pad-left"}}{{i18n user.change_username.action}}{{/linkTo}}
</div>
<div class='instructions'>
{{{i18n user.username.short_instructions username="content.username"}}}
{{{i18n user.username.short_instructions username="username"}}}
</div>
</div>
@ -24,7 +24,7 @@
<div class="control-group">
<label class="control-label">{{i18n user.email.title}}</label>
<div class="controls">
<span class='static'>{{content.email}}</span>
<span class='static'>{{email}}</span>
{{#linkTo "preferences.email" class="btn pad-left"}}{{i18n user.change_email.action}}{{/linkTo}}
</div>
<div class='instructions'>
@ -35,24 +35,24 @@
<div class="control-group">
<label class="control-label">{{i18n user.password.title}}</label>
<div class="controls">
<a href="#" {{action changePassword target="controller"}} class='btn'>{{i18n user.change_password.action}}</a> {{controller.passwordProgress}}
<a href="#" {{action changePassword target="controller"}} class='btn'>{{i18n user.change_password.action}}</a> {{passwordProgress}}
</div>
</div>
<div class="control-group">
<label class="control-label">{{i18n user.avatar.title}}</label>
<div class="controls">
{{avatar content imageSize="large"}}
{{avatar model imageSize="large"}}
</div>
<div class='instructions'>
{{{i18n user.avatar.instructions}}} {{content.email}}
{{{i18n user.avatar.instructions}}} {{email}}
</div>
</div>
<div class="control-group">
<label class="control-label">{{i18n user.bio}}</label>
<div class="controls">
{{view Discourse.PagedownEditor valueBinding="content.bio_raw"}}
{{view Discourse.PagedownEditor valueBinding="bio_raw"}}
</div>
</div>
@ -66,17 +66,17 @@
<div class="control-group">
<label class="control-label">{{i18n user.email_settings}}</label>
<div class="controls">
<label>{{view Ember.Checkbox checkedBinding="content.email_digests"}}
<label>{{view Ember.Checkbox checkedBinding="email_digests"}}
{{i18n user.email_digests.title}}</label>
{{#if content.email_digests}}
{{#if email_digests}}
<div class='control-indent'>
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="controller.digestFrequencies" valueBinding="content.digest_after_days"}}
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="digestFrequencies" valueBinding="digest_after_days"}}
</div>
{{/if}}
<label>{{view Ember.Checkbox checkedBinding="content.email_private_messages"}}
<label>{{view Ember.Checkbox checkedBinding="email_private_messages"}}
{{i18n user.email_private_messages}}</label>
<label>{{view Ember.Checkbox checkedBinding="content.email_direct"}}
<label>{{view Ember.Checkbox checkedBinding="email_direct"}}
{{i18n user.email_direct}}</label>
</div>
<div class='instructions'>
@ -88,25 +88,25 @@
<label class="control-label">{{i18n user.other_settings}}</label>
<div class="controls">
<label>{{i18n user.auto_track_topics}}</label>
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="controller.autoTrackDurations" valueBinding="content.auto_track_topics_after_msecs"}}
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="autoTrackDurations" valueBinding="auto_track_topics_after_msecs"}}
</div>
<div class="controls">
<label>{{i18n user.new_topic_duration.label}}</label>
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="controller.considerNewTopicOptions" valueBinding="content.new_topic_duration_minutes"}}
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="considerNewTopicOptions" valueBinding="new_topic_duration_minutes"}}
</div>
<div class="controls">
<label>{{view Ember.Checkbox checkedBinding="content.external_links_in_new_tab"}}
<label>{{view Ember.Checkbox checkedBinding="external_links_in_new_tab"}}
{{i18n user.external_links_in_new_tab}}</label>
<label>{{view Ember.Checkbox checkedBinding="content.enable_quoting"}}
<label>{{view Ember.Checkbox checkedBinding="enable_quoting"}}
{{i18n user.enable_quoting}}</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<button {{action save target="controller"}} {{bindAttr disabled="controller.saveDisabled"}} class="btn btn-primary">{{controller.saveButtonText}}</button>
<button {{action save target="controller"}} {{bindAttr disabled="saveDisabled"}} class="btn btn-primary">{{saveButtonText}}</button>
{{#if saved}}{{i18n saved}}{{/if}}
</div>
</div>

View File

@ -1,47 +1,47 @@
{{#unless model.loading}}
<div class="user-heading">
<div class="container">
<div class="full-width" id='user-menu'>
<h1>{{model.name}}<span>{{unbound model.username}}{{{unbound model.statusIcon}}}</span></h1>
{{#unless loading}}
<div class="user-heading">
<div class="container">
<div class="full-width" id='user-menu'>
<h1>{{name}}<span>{{unbound username}}{{{unbound statusIcon}}}</span></h1>
{{#if viewingSelf}}
<button {{action "logout" target="Discourse"}} class='btn'>{{i18n user.log_out}}</button>
{{/if}}
{{#if Discourse.currentUser.staff}}
<a href="{{unbound model.adminPath}}" class='btn'><i class="icon-wrench"></i>&nbsp;{{i18n admin.user.show_admin_profile}}</a>
{{/if}}
<ul class="nav nav-pills">
<li>
{{#linkTo 'user.activity'}}{{i18n user.activity_stream}}{{/linkTo}}
</li>
{{#if controller.canSeePrivateMessages}}
<li>
{{#linkTo "user.privateMessages"}}{{i18n user.private_messages}}{{/linkTo}}
</li>
{{#if viewingSelf}}
<button {{action "logout" target="Discourse"}} class='btn'>{{i18n user.log_out}}</button>
{{/if}}
<li>
{{#linkTo 'user.invited'}}{{i18n user.invited.title}}{{/linkTo}}
</li>
{{#if model.can_edit}}
<li>
{{#linkTo 'preferences'}}{{i18n user.preferences}}{{/linkTo}}
</li>
{{#if Discourse.currentUser.staff}}
<a href="{{unbound adminPath}}" class='btn'><i class="icon-wrench"></i>&nbsp;{{i18n admin.user.show_admin_profile}}</a>
{{/if}}
</ul>
<div class='avatar-wrapper'>
{{avatar content imageSize="120"}}
<ul class="nav nav-pills">
<li>
{{#linkTo 'user.activity'}}{{i18n user.activity_stream}}{{/linkTo}}
</li>
{{#if canSeePrivateMessages}}
<li>
{{#linkTo "user.privateMessages"}}{{i18n user.private_messages}}{{/linkTo}}
</li>
{{/if}}
<li>
{{#linkTo 'user.invited'}}{{i18n user.invited.title}}{{/linkTo}}
</li>
{{#if can_edit}}
<li>
{{#linkTo 'preferences'}}{{i18n user.preferences}}{{/linkTo}}
</li>
{{/if}}
</ul>
<div class='avatar-wrapper'>
{{avatar model imageSize="120"}}
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class='user-info clearfix'>
<div class='about-me'>
{{{model.bio_excerpt}}}
</div>
<div class="container">
<div class='user-info clearfix'>
<div class='about-me'>
{{{bio_excerpt}}}
</div>
</div>
</div>
<div class="container">
{{outlet userOutlet}}
</div>
</div>
<div class="container">
{{outlet userOutlet}}
</div>
{{/unless}}

View File

@ -12,7 +12,7 @@ Discourse.ComboboxView = Discourse.View.extend({
valueAttribute: 'id',
render: function(buffer) {
var selected, _ref,
var _ref,
_this = this;
// Add none option if required
@ -20,7 +20,8 @@ Discourse.ComboboxView = Discourse.View.extend({
buffer.push("<option value=\"\">" + (Ember.String.i18n(this.get('none'))) + "</option>");
}
selected = (_ref = this.get('value')) ? _ref.toString() : void 0;
var selected = (_ref = this.get('value')) ? _ref.toString() : void 0;
if (this.get('content')) {
return this.get('content').each(function(o) {
var data, selectedText, val, _ref1;
@ -37,6 +38,17 @@ Discourse.ComboboxView = Discourse.View.extend({
}
},
valueChanged: function() {
var $combo = this.$();
var val = this.get('value');
if (val) {
$combo.val(this.get('value').toString());
} else {
$combo.val(null);
}
$combo.trigger("liszt:updated")
}.observes('value'),
didInsertElement: function() {
var $elem,
_this = this;
@ -55,6 +67,7 @@ Discourse.ComboboxView = Discourse.View.extend({
$elem.chosen().next().addClass(c);
});
}
$elem.change(function(e) {
_this.set('value', $(e.target).val());
});