From 42248a7164b63a0b0a5877531442b8d9b9365d8b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 20 May 2013 15:27:58 -0400 Subject: [PATCH] Removed many unnecessary paths that included `content.x` when just `x` would do. --- .../controllers/admin_customize_controller.js | 16 ++-- .../controllers/admin_flags_controller.js | 14 ++-- .../javascripts/admin/models/flagged_post.js | 8 +- .../admin/routes/admin_api_route.js | 13 ++-- .../admin/routes/admin_customize_route.js | 10 +-- .../admin/routes/admin_flags_active_route.js | 10 +-- .../admin/routes/admin_flags_old_route.js | 8 +- .../admin/templates/api.js.handlebars | 8 +- .../admin/templates/customize.js.handlebars | 18 ++--- .../admin/templates/email_logs.js.handlebars | 12 +-- .../admin/templates/flags.js.handlebars | 4 +- .../templates/site_content_edit.js.handlebars | 8 +- .../templates/site_settings.js.handlebars | 2 +- .../admin/templates/user.js.handlebars | 74 +++++++++---------- .../admin/templates/users_list.js.handlebars | 4 +- .../discourse/controllers/topic_controller.js | 1 + .../discourse/templates/history.js.handlebars | 56 +++++++------- .../discourse/templates/post.js.handlebars | 2 +- .../discourse/templates/topic.js.handlebars | 2 +- .../templates/topic_admin_menu.js.handlebars | 10 +-- .../topic_summary/info.js.handlebars | 8 +- .../templates/user/activity.js.handlebars | 30 ++++---- .../templates/user/invited.js.handlebars | 16 ++-- .../user/private_messages.js.handlebars | 6 +- 24 files changed, 167 insertions(+), 173 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin_customize_controller.js b/app/assets/javascripts/admin/controllers/admin_customize_controller.js index bd72a1820af..fd9907dcd26 100644 --- a/app/assets/javascripts/admin/controllers/admin_customize_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_customize_controller.js @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.AdminCustomizeController = Ember.Controller.extend({ +Discourse.AdminCustomizeController = Ember.ArrayController.extend({ /** Create a new customization style @@ -15,8 +15,8 @@ Discourse.AdminCustomizeController = Ember.Controller.extend({ **/ newCustomization: function() { var item = Discourse.SiteCustomization.create({name: Em.String.i18n("admin.customize.new_style")}); - this.get('content').pushObject(item); - this.set('content.selectedItem', item); + this.pushObject(item); + this.set('selectedItem', item); }, /** @@ -26,7 +26,7 @@ Discourse.AdminCustomizeController = Ember.Controller.extend({ @param {Discourse.SiteCustomization} style The style we are selecting **/ selectStyle: function(style) { - this.set('content.selectedItem', style); + this.set('selectedItem', style); }, /** @@ -35,7 +35,7 @@ Discourse.AdminCustomizeController = Ember.Controller.extend({ @method save **/ save: function() { - this.get('content.selectedItem').save(); + this.get('selectedItem').save(); }, /** @@ -48,10 +48,10 @@ Discourse.AdminCustomizeController = Ember.Controller.extend({ return bootbox.confirm(Em.String.i18n("admin.customize.delete_confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) { var selected; if (result) { - selected = _this.get('content.selectedItem'); + selected = _this.get('selectedItem'); selected.destroy(); - _this.set('content.selectedItem', null); - return _this.get('content').removeObject(selected); + _this.set('selectedItem', null); + return _this.removeObject(selected); } }); } diff --git a/app/assets/javascripts/admin/controllers/admin_flags_controller.js b/app/assets/javascripts/admin/controllers/admin_flags_controller.js index 48d3973360d..60a88bd38b2 100644 --- a/app/assets/javascripts/admin/controllers/admin_flags_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_flags_controller.js @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.AdminFlagsController = Ember.Controller.extend({ +Discourse.AdminFlagsController = Ember.ArrayController.extend({ /** Clear all flags on a post @@ -17,10 +17,10 @@ Discourse.AdminFlagsController = Ember.Controller.extend({ clearFlags: function(item) { var _this = this; item.clearFlags().then((function() { - _this.content.removeObject(item); - }), (function() { + _this.removeObject(item); + }), function() { bootbox.alert(Em.String.i18n("admin.flags.error")); - })); + }); }, /** @@ -32,10 +32,10 @@ Discourse.AdminFlagsController = Ember.Controller.extend({ deletePost: function(item) { var _this = this; item.deletePost().then((function() { - _this.content.removeObject(item); - }), (function() { + _this.removeObject(item); + }), function() { bootbox.alert(Em.String.i18n("admin.flags.error")); - })); + }); }, /** diff --git a/app/assets/javascripts/admin/models/flagged_post.js b/app/assets/javascripts/admin/models/flagged_post.js index 4b793e9cde3..981dd287b16 100644 --- a/app/assets/javascripts/admin/models/flagged_post.js +++ b/app/assets/javascripts/admin/models/flagged_post.js @@ -8,7 +8,7 @@ **/ Discourse.FlaggedPost = Discourse.Post.extend({ - flaggers: (function() { + flaggers: function() { var r, _this = this; r = []; @@ -16,9 +16,9 @@ Discourse.FlaggedPost = Discourse.Post.extend({ return r.push(_this.userLookup[a.user_id]); }); return r; - }).property(), + }.property(), - messages: (function() { + messages: function() { var r, _this = this; r = []; @@ -32,7 +32,7 @@ Discourse.FlaggedPost = Discourse.Post.extend({ } }); return r; - }).property(), + }.property(), lastFlagged: function() { return this.post_actions[0].created_at; diff --git a/app/assets/javascripts/admin/routes/admin_api_route.js b/app/assets/javascripts/admin/routes/admin_api_route.js index 6355b7d4101..5e534ac3ef0 100644 --- a/app/assets/javascripts/admin/routes/admin_api_route.js +++ b/app/assets/javascripts/admin/routes/admin_api_route.js @@ -7,14 +7,13 @@ @module Discourse **/ Discourse.AdminApiRoute = Discourse.Route.extend({ - renderTemplate: function() { - this.render({into: 'admin/templates/admin'}); + + model: function() { + return Discourse.AdminApi.find(); }, - setupController: function(controller, model) { - // in case you are wondering, model never gets called for link_to - Discourse.AdminApi.find().then(function(result){ - controller.set('content', result); - }); + renderTemplate: function() { + this.render({into: 'admin/templates/admin'}); } + }); diff --git a/app/assets/javascripts/admin/routes/admin_customize_route.js b/app/assets/javascripts/admin/routes/admin_customize_route.js index 5c726ff8286..6e721b72e20 100644 --- a/app/assets/javascripts/admin/routes/admin_customize_route.js +++ b/app/assets/javascripts/admin/routes/admin_customize_route.js @@ -8,12 +8,12 @@ **/ Discourse.AdminCustomizeRoute = Discourse.Route.extend({ - renderTemplate: function() { - this.render({into: 'admin/templates/admin'}); + model: function() { + return Discourse.SiteCustomization.findAll(); }, - setupController: function(controller, model) { - // in case you are wondering, model never gets called for link_to - controller.set('content',Discourse.SiteCustomization.findAll()); + renderTemplate: function() { + this.render({into: 'admin/templates/admin'}); } + }); diff --git a/app/assets/javascripts/admin/routes/admin_flags_active_route.js b/app/assets/javascripts/admin/routes/admin_flags_active_route.js index 9ae171a0a3e..886de964c40 100644 --- a/app/assets/javascripts/admin/routes/admin_flags_active_route.js +++ b/app/assets/javascripts/admin/routes/admin_flags_active_route.js @@ -1,20 +1,16 @@ /** Handles routes related to viewing active flags. - @class AdminFlagsActiveRoute + @class AdminFlagsActiveRoute @extends Discourse.Route @namespace Discourse @module Discourse **/ Discourse.AdminFlagsActiveRoute = Discourse.Route.extend({ - model: function() { - return Discourse.FlaggedPost.findAll('active'); - }, - - setupController: function(controller, model) { + setupController: function() { var adminFlagsController = this.controllerFor('adminFlags'); - adminFlagsController.set('content', model); + adminFlagsController.set('content', Discourse.FlaggedPost.findAll('active')); adminFlagsController.set('query', 'active'); } diff --git a/app/assets/javascripts/admin/routes/admin_flags_old_route.js b/app/assets/javascripts/admin/routes/admin_flags_old_route.js index df967f53c83..04a815d569f 100644 --- a/app/assets/javascripts/admin/routes/admin_flags_old_route.js +++ b/app/assets/javascripts/admin/routes/admin_flags_old_route.js @@ -1,20 +1,16 @@ /** Handles routes related to viewing old flags. - @class AdminFlagsOldRoute + @class AdminFlagsOldRoute @extends Discourse.Route @namespace Discourse @module Discourse **/ Discourse.AdminFlagsOldRoute = Discourse.Route.extend({ - - model: function() { - return Discourse.FlaggedPost.findAll('old'); - }, setupController: function(controller, model) { var adminFlagsController = this.controllerFor('adminFlags'); - adminFlagsController.set('content', model); + adminFlagsController.set('content', Discourse.FlaggedPost.findAll('old')); adminFlagsController.set('query', 'old'); } diff --git a/app/assets/javascripts/admin/templates/api.js.handlebars b/app/assets/javascripts/admin/templates/api.js.handlebars index df5c724e9d5..7ef83204079 100644 --- a/app/assets/javascripts/admin/templates/api.js.handlebars +++ b/app/assets/javascripts/admin/templates/api.js.handlebars @@ -1,9 +1,9 @@

{{i18n admin.api.long_title}}

-{{#if content.keyExists}} - {{i18n admin.api.key}}: {{content.key}} - +{{#if keyExists}} + {{i18n admin.api.key}}: {{key}} +

{{{i18n admin.api.note_html}}}

{{else}}

{{{i18n admin.api.info_html}}}

- + {{/if}} diff --git a/app/assets/javascripts/admin/templates/customize.js.handlebars b/app/assets/javascripts/admin/templates/customize.js.handlebars index 44fcd90933d..9b544ecbb9a 100644 --- a/app/assets/javascripts/admin/templates/customize.js.handlebars +++ b/app/assets/javascripts/admin/templates/customize.js.handlebars @@ -2,7 +2,7 @@

{{i18n admin.customize.long_title}}

@@ -10,7 +10,7 @@
-{{#if content.selectedItem}} +{{#if selectedItem}}
- {{#with content.selectedItem}} + {{#with selectedItem}} {{textField class="style-name" value=name}} {{#if view.headerActive}} {{view Discourse.AceEditorView contentBinding="header" mode="html"}} @@ -34,18 +34,18 @@ {{/with}}
- {{i18n admin.customize.override_default}} {{view Ember.Checkbox checkedBinding="content.selectedItem.override_default_style"}} - {{i18n admin.customize.enabled}} {{view Ember.Checkbox checkedBinding="content.selectedItem.enabled"}} - {{#unless content.selectedItem.changed}} - {{i18n admin.customize.preview}} + {{i18n admin.customize.override_default}} {{view Ember.Checkbox checkedBinding="selectedItem.override_default_style"}} + {{i18n admin.customize.enabled}} {{view Ember.Checkbox checkedBinding="selectedItem.enabled"}} + {{#unless selectedItem.changed}} + {{i18n admin.customize.preview}} | {{i18n admin.customize.undo_preview}}
{{/unless}}
- - {{content.selectedItem.savingStatus}} + + {{selectedItem.savingStatus}} {{i18n admin.customize.delete}}
diff --git a/app/assets/javascripts/admin/templates/email_logs.js.handlebars b/app/assets/javascripts/admin/templates/email_logs.js.handlebars index 513db67dda3..4d5647c1105 100644 --- a/app/assets/javascripts/admin/templates/email_logs.js.handlebars +++ b/app/assets/javascripts/admin/templates/email_logs.js.handlebars @@ -19,17 +19,17 @@ {{#if model.length}} {{#group}} {{#collection contentBinding="model" tagName="tbody" itemTagName="tr"}} - {{date view.content.created_at}} + {{date created_at}} - {{#if view.content.user}} - {{#linkTo 'adminUser' view.content.user}}{{avatar view.content.user imageSize="tiny"}}{{/linkTo}} - {{#linkTo 'adminUser' view.content.user}}{{view.content.user.username}}{{/linkTo}} + {{#if user}} + {{#linkTo 'adminUser' user}}{{avatar user imageSize="tiny"}}{{/linkTo}} + {{#linkTo 'adminUser' user}}{{user.username}}{{/linkTo}} {{else}} — {{/if}} - {{view.content.to_address}} - {{view.content.email_type}} + {{to_address}} + {{email_type}} {{/collection}} {{/group}} {{/if}} diff --git a/app/assets/javascripts/admin/templates/flags.js.handlebars b/app/assets/javascripts/admin/templates/flags.js.handlebars index 9030c0e5da6..4e8f84e21ec 100644 --- a/app/assets/javascripts/admin/templates/flags.js.handlebars +++ b/app/assets/javascripts/admin/templates/flags.js.handlebars @@ -27,8 +27,8 @@ {{date lastFlagged}} {{#if adminActiveFlagsView}} - - + + {{/if}} diff --git a/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars b/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars index fa7499b9f43..1c182978cfa 100644 --- a/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars +++ b/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars @@ -3,19 +3,19 @@

{{description}}

{{#if markdown}} - {{view Discourse.PagedownEditor valueBinding="content.content"}} + {{view Discourse.PagedownEditor valueBinding="model.content"}} {{/if}} {{#if plainText}} - {{textarea value=content.content class="plain"}} + {{textarea value=model.content class="plain"}} {{/if}} {{#if html}} - {{view Discourse.AceEditorView contentBinding="content.content" mode="html"}} + {{view Discourse.AceEditorView contentBinding="model.content" mode="html"}} {{/if}} {{#if css}} - {{view Discourse.AceEditorView contentBinding="content.content" mode="css"}} + {{view Discourse.AceEditorView contentBinding="model.content" mode="css"}} {{/if}} diff --git a/app/assets/javascripts/admin/templates/site_settings.js.handlebars b/app/assets/javascripts/admin/templates/site_settings.js.handlebars index f8e2ceb3eec..14ac8847d67 100644 --- a/app/assets/javascripts/admin/templates/site_settings.js.handlebars +++ b/app/assets/javascripts/admin/templates/site_settings.js.handlebars @@ -14,4 +14,4 @@ {{collection contentBinding="filteredContent" classNames="form-horizontal settings" itemViewClass="Discourse.SiteSettingView"}} -

Diagnostics: last_message_processed {{content.diags.last_message_processed}}

+

Diagnostics: last_message_processed {{diags.last_message_processed}}

diff --git a/app/assets/javascripts/admin/templates/user.js.handlebars b/app/assets/javascripts/admin/templates/user.js.handlebars index dd016ec6237..15852282822 100644 --- a/app/assets/javascripts/admin/templates/user.js.handlebars +++ b/app/assets/javascripts/admin/templates/user.js.handlebars @@ -2,13 +2,13 @@
{{i18n user.username.title}}
-
{{content.username}}
+
{{username}}
{{#linkTo 'user.activity' content class="btn"}} {{i18n admin.user.show_public_profile}} {{/linkTo}} - {{#if content.can_impersonate}} + {{#if can_impersonate}} {{/if}} {{else}} - {{#if content.can_send_activation_email}} + {{#if can_send_activation_email}} {{/if}} - {{#if content.can_activate}} + {{#if can_activate}} {{/if}} - {{#if content.can_grant_admin}} + {{#if can_grant_admin}}
{{i18n admin.user.moderator}}
-
{{content.moderator}}
+
{{moderator}}
- {{#if content.can_revoke_moderation}} + {{#if can_revoke_moderation}} {{/if}} - {{#if content.can_grant_moderation}} + {{#if can_grant_moderation}}
{{i18n trust_level}}
-
{{content.trustLevel.name}}
+
{{trustLevel.name}}
{{i18n admin.user.banned}}
-
{{content.isBanned}}
+
{{isBanned}}
- {{#if content.isBanned}} + {{#if isBanned}} - {{content.banDuration}} + {{banDuration}} {{else}} - {{#if content.canBan}} + {{#if canBan}}
{{i18n admin.user.posts_read_count}}
-
{{content.posts_read_count}}
+
{{posts_read_count}}
{{i18n admin.user.flags_given_count}}
-
{{content.flags_given_count}}
+
{{flags_given_count}}
{{i18n admin.user.flags_received_count}}
-
{{content.flags_received_count}}
+
{{flags_received_count}}
{{i18n admin.user.private_topics_count}}
-
{{content.private_topics_count}}
+
{{private_topics_count}}
{{i18n admin.user.time_read}}
-
{{{content.time_read}}}
+
{{{time_read}}}
{{i18n user.invited.days_visited}}
-
{{{content.days_visited}}}
+
{{{days_visited}}}
diff --git a/app/assets/javascripts/admin/templates/users_list.js.handlebars b/app/assets/javascripts/admin/templates/users_list.js.handlebars index d7e25942bf1..f35285cbe7c 100644 --- a/app/assets/javascripts/admin/templates/users_list.js.handlebars +++ b/app/assets/javascripts/admin/templates/users_list.js.handlebars @@ -25,7 +25,7 @@ {{#if loading}}
{{i18n loading}}
{{else}} - {{#if content.length}} + {{#if model.length}} {{#if showApproval}} @@ -47,7 +47,7 @@ - {{#each content}} + {{#each model}} {{#if showApproval}} - {{#each content.redeemed}} + {{#each redeemed}} {{/each}} @@ -39,7 +39,7 @@ {{/if}} - {{#if content.pending}} + {{#if pending}}

{{i18n user.invited.pending}}

@@ -47,9 +47,9 @@
- + - {{#each content.pending}} + {{#each pending}} diff --git a/app/assets/javascripts/discourse/templates/user/private_messages.js.handlebars b/app/assets/javascripts/discourse/templates/user/private_messages.js.handlebars index 85038a13b88..996ce723ed4 100644 --- a/app/assets/javascripts/discourse/templates/user/private_messages.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/private_messages.js.handlebars @@ -1,10 +1,10 @@
diff --git a/app/assets/javascripts/discourse/controllers/topic_controller.js b/app/assets/javascripts/discourse/controllers/topic_controller.js index 29cf64e8e81..0f941d23832 100644 --- a/app/assets/javascripts/discourse/controllers/topic_controller.js +++ b/app/assets/javascripts/discourse/controllers/topic_controller.js @@ -462,6 +462,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected showHistory: function(post) { var modalController = this.get('controllers.modal'); + if (modalController) { modalController.show(Discourse.HistoryView.create({ originalPost: post diff --git a/app/assets/javascripts/discourse/templates/history.js.handlebars b/app/assets/javascripts/discourse/templates/history.js.handlebars index 2381383c0c0..b770e268951 100644 --- a/app/assets/javascripts/discourse/templates/history.js.handlebars +++ b/app/assets/javascripts/discourse/templates/history.js.handlebars @@ -3,40 +3,42 @@ {{#if view.loading}} {{i18n loading}} {{else}} -
+ {{#if view.versions}} +
- {{view Ember.Select - contentBinding="view.versions" - optionLabelPath="content.description" - optionValuePath="content.number" - selectionBinding="view.versionLeft"}} + {{view Ember.Select + contentBinding="view.versions" + optionLabelPath="content.description" + optionValuePath="content.number" + selectionBinding="view.versionLeft"}} + +
+ {{#if view.postLeft}} + {{{view.postLeft.cooked}}} + {{else}} +
{{i18n loading}}
+ {{/if}} +
-
- {{#if view.postLeft}} - {{{view.postLeft.cooked}}} - {{else}} -
{{i18n loading}}
- {{/if}}
-
+
+ {{view Ember.Select + contentBinding="view.versions" + optionLabelPath="content.description" + optionValuePath="content.number" + selectionBinding="view.versionRight"}} -
- {{view Ember.Select - contentBinding="view.versions" - optionLabelPath="content.description" - optionValuePath="content.number" - selectionBinding="view.versionRight"}} +
+ {{#if view.diff}} + {{{view.diff}}} + {{else}} +
{{i18n loading}}
+ {{/if}} +
-
- {{#if view.diff}} - {{{view.diff}}} - {{else}} -
{{i18n loading}}
- {{/if}}
- -
+ {{/if}} {{/if}}
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/templates/post.js.handlebars b/app/assets/javascripts/discourse/templates/post.js.handlebars index 533329ac2a8..47a823a6287 100644 --- a/app/assets/javascripts/discourse/templates/post.js.handlebars +++ b/app/assets/javascripts/discourse/templates/post.js.handlebars @@ -58,7 +58,7 @@
{{collection contentBinding="internalLinks" itemViewClass="Discourse.PostLinkView" tagName="ul" classNames="post-links"}} - {{#if controller.content.can_reply_as_new_topic}} + {{#if controller.can_reply_as_new_topic}} {{i18n post.reply_as_new_topic}} {{/if}}
diff --git a/app/assets/javascripts/discourse/templates/topic.js.handlebars b/app/assets/javascripts/discourse/templates/topic.js.handlebars index 36d0c89c6d4..ff53bf1b0d3 100644 --- a/app/assets/javascripts/discourse/templates/topic.js.handlebars +++ b/app/assets/javascripts/discourse/templates/topic.js.handlebars @@ -58,7 +58,7 @@
{{i18n loading}}
{{/if}} - {{collection itemViewClass="Discourse.PostView" contentBinding="content.posts" topicViewBinding="view"}} + {{collection itemViewClass="Discourse.PostView" contentBinding="posts" topicViewBinding="view"}} {{#if loadingBelow}}
{{i18n loading}}
diff --git a/app/assets/javascripts/discourse/templates/topic_admin_menu.js.handlebars b/app/assets/javascripts/discourse/templates/topic_admin_menu.js.handlebars index 64d5d7e07ba..45d9cdd7adb 100644 --- a/app/assets/javascripts/discourse/templates/topic_admin_menu.js.handlebars +++ b/app/assets/javascripts/discourse/templates/topic_admin_menu.js.handlebars @@ -7,14 +7,14 @@ - {{#if content.can_delete}} + {{#if can_delete}}
  • {{/if}}
  • - {{#if content.closed}} + {{#if closed}} {{else}} @@ -23,7 +23,7 @@
  • - {{#if content.pinned}} + {{#if pinned}} {{else}} @@ -31,7 +31,7 @@
  • - {{#if content.archived}} + {{#if archived}} {{else}} @@ -39,7 +39,7 @@
  • - {{#if content.visible}} + {{#if visible}} {{else}} diff --git a/app/assets/javascripts/discourse/templates/topic_summary/info.js.handlebars b/app/assets/javascripts/discourse/templates/topic_summary/info.js.handlebars index a5beb9e1f67..51b833a8ff1 100644 --- a/app/assets/javascripts/discourse/templates/topic_summary/info.js.handlebars +++ b/app/assets/javascripts/discourse/templates/topic_summary/info.js.handlebars @@ -82,10 +82,10 @@
  • {{i18n user.invited.time_read}} {{i18n user.invited.days_visited}}
    {{avatar user imageSize="tiny"}} @@ -30,7 +30,7 @@ {{number user.posts_read_count}} {{{unbound user.time_read}}} {{{unbound user.days_visited}}} - / + / {{{unbound user.days_since_created}}}
    {{i18n user.email.title}} {{i18n created}}  
    {{email}} {{date created_at}}