Ember Deprecations for Topics

This commit is contained in:
Robin Ward 2015-04-30 12:25:38 -04:00
parent 690b579a96
commit aee12fd6ef
33 changed files with 170 additions and 192 deletions

View File

@ -20,7 +20,7 @@ export default Ember.Component.extend({
}.observes("autoCloseTime", "limited"),
_isAutoCloseValid: function(autoCloseTime, limited) {
var t = (autoCloseTime || "").trim();
var t = (autoCloseTime || "").toString().trim();
if (t.length === 0) {
// "empty" is always valid
return true;

View File

@ -1,11 +1,3 @@
/**
The controls for toggling the supression of deleted posts
@class ToggleDeletedComponent
@extends Ember.Component
@namespace Discourse
@module Discourse
**/
export default Ember.Component.extend({
layoutName: 'components/toggle-deleted',
tagName: 'section',

View File

@ -9,20 +9,20 @@ export default ObjectController.extend(ModalFunctionality, {
setAutoCloseTime: function() {
var autoCloseTime = null;
if (this.get("details.auto_close_based_on_last_post")) {
autoCloseTime = this.get("details.auto_close_hours");
} else if (this.get("details.auto_close_at")) {
var closeTime = new Date(this.get("details.auto_close_at"));
if (this.get("model.details.auto_close_based_on_last_post")) {
autoCloseTime = this.get("model.details.auto_close_hours");
} else if (this.get("model.details.auto_close_at")) {
var closeTime = new Date(this.get("model.details.auto_close_at"));
if (closeTime > new Date()) {
autoCloseTime = moment(closeTime).format("YYYY-MM-DD HH:mm");
}
}
this.set("auto_close_time", autoCloseTime);
}.observes("details.{auto_close_at,auto_close_hours}"),
this.set("model.auto_close_time", autoCloseTime);
}.observes("model.details.{auto_close_at,auto_close_hours}"),
actions: {
saveAutoClose: function() { this.setAutoClose(this.get("auto_close_time")); },
saveAutoClose: function() { this.setAutoClose(this.get("model.auto_close_time")); },
removeAutoClose: function() { this.setAutoClose(null); }
},
@ -30,18 +30,18 @@ export default ObjectController.extend(ModalFunctionality, {
var self = this;
this.send('hideModal');
Discourse.ajax({
url: '/t/' + this.get('id') + '/autoclose',
url: '/t/' + this.get('model.id') + '/autoclose',
type: 'PUT',
dataType: 'json',
data: {
auto_close_time: time,
auto_close_based_on_last_post: this.get("details.auto_close_based_on_last_post"),
auto_close_based_on_last_post: this.get("model.details.auto_close_based_on_last_post"),
}
}).then(function(result){
if (result.success) {
self.send('closeModal');
self.set('details.auto_close_at', result.auto_close_at);
self.set('details.auto_close_hours', result.auto_close_hours);
self.set('model.details.auto_close_at', result.auto_close_at);
self.set('model.details.auto_close_hours', result.auto_close_hours);
} else {
bootbox.alert(I18n.t('composer.auto_close.error'), function() { self.send('reopenModal'); } );
}

View File

@ -11,14 +11,14 @@ export default ObjectController.extend(ModalFunctionality, {
bannerCount: 0,
categoryLink: function() {
return categoryLinkHTML(this.get("category"), { allowUncategorized: true });
}.property("category"),
return categoryLinkHTML(this.get("model.category"), { allowUncategorized: true });
}.property("model.category"),
unPinMessage: function() {
return this.get("pinned_globally") ?
return this.get("model.pinned_globally") ?
I18n.t("topic.feature_topic.unpin_globally") :
I18n.t("topic.feature_topic.unpin", { categoryLink: this.get("categoryLink") });
}.property("categoryLink", "pinned_globally"),
}.property("categoryLink", "model.pinned_globally"),
pinMessage: function() {
return I18n.t("topic.feature_topic.pin", { categoryLink: this.get("categoryLink") });
@ -32,7 +32,7 @@ export default ObjectController.extend(ModalFunctionality, {
this.set("loading", true);
return Discourse.ajax("/topics/feature_stats.json", {
data: { category_id: this.get("category.id") }
data: { category_id: this.get("model.category.id") }
}).then(result => {
if (result) {
this.setProperties({

View File

@ -3,8 +3,8 @@ import ObjectController from 'discourse/controllers/object';
// This controller supports the admin menu on topics
export default ObjectController.extend({
menuVisible: false,
showRecover: Em.computed.and('deleted', 'details.can_recover'),
isFeatured: Em.computed.or("pinned_at", "isBanner"),
showRecover: Em.computed.and('model.deleted', 'model.details.can_recover'),
isFeatured: Em.computed.or("model.pinned_at", "model.isBanner"),
actions: {
show: function() { this.set('menuVisible', true); },

View File

@ -24,11 +24,11 @@ export default Ember.ObjectController.extend({
if (isNaN(postIndex) || postIndex < 1) {
postIndex = 1;
}
if (postIndex > this.get('postStream.filteredPostsCount')) {
postIndex = this.get('postStream.filteredPostsCount');
if (postIndex > this.get('model.postStream.filteredPostsCount')) {
postIndex = this.get('model.postStream.filteredPostsCount');
}
this.set('toPostIndex', postIndex);
var stream = this.get('postStream'),
var stream = this.get('model.postStream'),
postId = stream.findPostIdForPostNumber(postIndex);
if (!postId) {
@ -65,36 +65,36 @@ export default Ember.ObjectController.extend({
},
streamPercentage: function() {
if (!this.get('postStream.loaded')) { return 0; }
if (this.get('postStream.highest_post_number') === 0) { return 0; }
var perc = this.get('progressPosition') / this.get('postStream.filteredPostsCount');
if (!this.get('model.postStream.loaded')) { return 0; }
if (this.get('model.postStream.highest_post_number') === 0) { return 0; }
var perc = this.get('progressPosition') / this.get('model.postStream.filteredPostsCount');
return (perc > 1.0) ? 1.0 : perc;
}.property('postStream.loaded', 'progressPosition', 'postStream.filteredPostsCount'),
}.property('model.postStream.loaded', 'progressPosition', 'model.postStream.filteredPostsCount'),
jumpTopDisabled: function() {
return this.get('progressPosition') <= 3;
}.property('progressPosition'),
filteredPostCountChanged: function(){
if(this.get('postStream.filteredPostsCount') < this.get('progressPosition')){
this.set('progressPosition', this.get('postStream.filteredPostsCount'));
if(this.get('model.postStream.filteredPostsCount') < this.get('progressPosition')){
this.set('progressPosition', this.get('model.postStream.filteredPostsCount'));
}
}.observes('postStream.filteredPostsCount'),
}.observes('model.postStream.filteredPostsCount'),
jumpBottomDisabled: function() {
return this.get('progressPosition') >= this.get('postStream.filteredPostsCount') ||
return this.get('progressPosition') >= this.get('model.postStream.filteredPostsCount') ||
this.get('progressPosition') >= this.get('highest_post_number');
}.property('postStream.filteredPostsCount', 'highest_post_number', 'progressPosition'),
}.property('model.postStream.filteredPostsCount', 'highest_post_number', 'progressPosition'),
hideProgress: function() {
if (!this.get('postStream.loaded')) return true;
if (!this.get('currentPost')) return true;
if (this.get('postStream.filteredPostsCount') < 2) return true;
if (!this.get('model.postStream.loaded')) return true;
if (!this.get('model.currentPost')) return true;
if (this.get('model.postStream.filteredPostsCount') < 2) return true;
return false;
}.property('postStream.loaded', 'currentPost', 'postStream.filteredPostsCount'),
}.property('model.postStream.loaded', 'model.currentPost', 'model.postStream.filteredPostsCount'),
hugeNumberOfPosts: function() {
return (this.get('postStream.filteredPostsCount') >= Discourse.SiteSettings.short_progress_text_threshold);
return (this.get('model.postStream.filteredPostsCount') >= Discourse.SiteSettings.short_progress_text_threshold);
}.property('highest_post_number'),
jumpToBottomTitle: function() {

View File

@ -12,6 +12,9 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
selectedReplies: null,
queryParams: ['filter', 'username_filters', 'show_deleted'],
searchHighlight: null,
loadedAllPosts: false,
enteredAt: null,
firstPostExpanded: false,
maxTitleLength: Discourse.computed.setting('max_topic_title_length'),
@ -20,14 +23,14 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}.observes('topic'),
_titleChanged: function() {
const title = this.get('title');
const title = this.get('model.title');
if (!Ember.isEmpty(title)) {
// Note normally you don't have to trigger this, but topic titles can be updated
// and are sometimes lazily loaded.
this.send('refreshTitle');
}
}.observes('title', 'category'),
}.observes('model.title', 'category'),
termChanged: function() {
const dropdown = this.get('controllers.header.visibleDropdown');
@ -47,47 +50,47 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
// semantics of loaded all posts are slightly diff at topic level,
// it just means that we "once" loaded all posts, this means we don't
// keep re-rendering the suggested topics when new posts zoom in
let loaded = this.get('postStream.loadedAllPosts');
let loaded = this.get('model.postStream.loadedAllPosts');
if (loaded) {
this.set('loadedTopicId', this.get('model.id'));
this.set('model.loadedTopicId', this.get('model.id'));
} else {
loaded = this.get('loadedTopicId') === this.get('model.id');
loaded = this.get('model.loadedTopicId') === this.get('model.id');
}
this.set('loadedAllPosts', loaded);
}.observes('postStream', 'postStream.loadedAllPosts'),
}.observes('model.postStream', 'model.postStream.loadedAllPosts'),
show_deleted: function(key, value) {
const postStream = this.get('postStream');
const postStream = this.get('model.postStream');
if (!postStream) { return; }
if (arguments.length > 1) {
postStream.set('show_deleted', value);
}
return postStream.get('show_deleted') ? true : undefined;
}.property('postStream.summary'),
}.property('model.postStream.summary'),
filter: function(key, value) {
const postStream = this.get('postStream');
const postStream = this.get('model.postStream');
if (!postStream) { return; }
if (arguments.length > 1) {
postStream.set('summary', value === "summary");
}
return postStream.get('summary') ? "summary" : undefined;
}.property('postStream.summary'),
}.property('model.postStream.summary'),
username_filters: function(key, value) {
const postStream = this.get('postStream');
const postStream = this.get('model.postStream');
if (!postStream) { return; }
if (arguments.length > 1) {
postStream.set('streamFilters.username_filters', value);
}
return postStream.get('streamFilters.username_filters');
}.property('postStream.streamFilters.username_filters'),
}.property('model.postStream.streamFilters.username_filters'),
_clearSelected: function() {
this.set('selectedPosts', []);
@ -95,7 +98,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}.on('init'),
_togglePinnedStates(property) {
const value = this.get('pinned_at') ? false : true,
const value = this.get('model.pinned_at') ? false : true,
topic = this.get('content');
// optimistic update
@ -189,7 +192,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
'class': 'btn-primary',
callback() {
Discourse.Post.deleteMany([post], [post]);
self.get('postStream.posts').forEach(function (p) {
self.get('model.postStream.posts').forEach(function (p) {
if (p === post || p.get('reply_to_post_number') === post.get('post_number')) {
p.setDeletedState(user);
}
@ -246,7 +249,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
},
selectAll() {
const posts = this.get('postStream.posts'),
const posts = this.get('model.postStream.posts'),
selectedPosts = this.get('selectedPosts');
if (posts) {
selectedPosts.addObjects(posts);
@ -261,11 +264,11 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
},
toggleParticipant(user) {
this.get('postStream').toggleParticipant(Em.get(user, 'username'));
this.get('model.postStream').toggleParticipant(Em.get(user, 'username'));
},
editTopic() {
if (!this.get('details.can_edit')) return false;
if (!this.get('model.details.can_edit')) return false;
this.set('editingTopic', true);
return false;
@ -326,7 +329,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
const selectedPosts = self.get('selectedPosts'),
selectedReplies = self.get('selectedReplies'),
postStream = self.get('postStream'),
postStream = self.get('model.postStream'),
toRemove = [];
Discourse.Post.deleteMany(selectedPosts, selectedReplies);
@ -365,7 +368,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
},
togglePinned() {
const value = this.get('pinned_at') ? false : true,
const value = this.get('model.pinned_at') ? false : true,
topic = this.get('content');
// optimistic update
@ -403,7 +406,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
},
togglePinnedForUser() {
if (this.get('pinned_at')) {
if (this.get('model.pinned_at')) {
if (this.get('pinned')) {
this.get('content').clearPin();
} else {
@ -428,7 +431,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
return Em.isEmpty(quotedText) ? Discourse.Post.loadQuote(post.get('id')) : quotedText;
}).then(function(q) {
const postUrl = "" + location.protocol + "//" + location.host + post.get('url'),
postLink = "[" + Handlebars.escapeExpression(self.get('title')) + "](" + postUrl + ")";
postLink = "[" + Handlebars.escapeExpression(self.get('model.title')) + "](" + postUrl + ")";
composerController.appendText(I18n.t("post.continue_discussion", { postLink: postLink }) + "\n\n" + q);
});
},
@ -448,7 +451,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
retryLoading() {
const self = this;
self.set('retrying', true);
this.get('postStream').refresh().then(function() {
this.get('model.postStream').refresh().then(function() {
self.set('retrying', false);
}, function() {
self.set('retrying', false);
@ -491,12 +494,12 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}.property(),
canMergeTopic: function() {
if (!this.get('details.can_move_posts')) return false;
if (!this.get('model.details.can_move_posts')) return false;
return (this.get('selectedPostsCount') > 0);
}.property('selectedPostsCount'),
canSplitTopic: function() {
if (!this.get('details.can_move_posts')) return false;
if (!this.get('model.details.can_move_posts')) return false;
if (this.get('allPostsSelected')) return false;
return (this.get('selectedPostsCount') > 0);
}.property('selectedPostsCount'),
@ -586,16 +589,16 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
this.unsubscribe();
const self = this;
this.messageBus.subscribe("/topic/" + this.get('id'), function(data) {
this.messageBus.subscribe("/topic/" + this.get('model.id'), function(data) {
const topic = self.get('model');
if (data.notification_level_change) {
topic.set('details.notification_level', data.notification_level_change);
topic.set('details.notifications_reason_id', data.notifications_reason_id);
topic.set('model.details.notification_level', data.notification_level_change);
topic.set('model.details.notifications_reason_id', data.notifications_reason_id);
return;
}
const postStream = self.get('postStream');
const postStream = self.get('model.postStream');
switch (data.type) {
case "revised":
case "acted":
@ -654,16 +657,16 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
// If our current post is changed, notify the router
_currentPostChanged: function() {
const currentPost = this.get('currentPost');
const currentPost = this.get('model.currentPost');
if (currentPost) {
this.send('postChangedRoute', currentPost);
}
}.observes('currentPost'),
}.observes('model.currentPost'),
readPosts(topicId, postNumbers) {
const postStream = this.get('postStream');
const postStream = this.get('model.postStream');
if(this.get('postStream.topic.id') === topicId){
if(this.get('model.postStream.topic.id') === topicId){
_.each(postStream.get('posts'), function(post){
// optimise heavy loop
// TODO identity map for postNumber
@ -673,8 +676,8 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
});
const max = _.max(postNumbers);
if(max > this.get('last_read_post_number')){
this.set('last_read_post_number', max);
if(max > this.get('model.last_read_post_number')){
this.set('model.sast_read_post_number', max);
}
}
},
@ -683,10 +686,10 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
topVisibleChanged(post) {
if (!post) { return; }
const postStream = this.get('postStream'),
const postStream = this.get('model.postStream'),
firstLoadedPost = postStream.get('firstLoadedPost');
this.set('currentPost', post.get('post_number'));
this.set('model.currentPost', post.get('post_number'));
if (post.get('post_number') === 1) { return; }
@ -721,7 +724,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
bottomVisibleChanged(post) {
if (!post) { return; }
const postStream = this.get('postStream'),
const postStream = this.get('model.postStream'),
lastLoadedPost = postStream.get('lastLoadedPost');
this.set('controllers.topic-progress.progressPosition', postStream.progressIndexOfPost(post));
@ -732,7 +735,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
},
_showFooter: function() {
this.set("controllers.application.showFooter", this.get("postStream.loadedAllPosts"));
}.observes("postStream.loadedAllPosts")
this.set("controllers.application.showFooter", this.get("model.postStream.loadedAllPosts"));
}.observes("model.postStream.loadedAllPosts")
});

View File

@ -11,7 +11,7 @@ export default Ember.Controller.extend({
// If inside a topic
topicPostCount: null,
postStream: Em.computed.alias('controllers.topic.postStream'),
postStream: Em.computed.alias('controllers.topic.model.postStream'),
enoughPostsForFiltering: Em.computed.gte('topicPostCount', 2),
viewingTopic: Em.computed.match('controllers.application.currentPath', /^topic\./),
viewingAdmin: Em.computed.match('controllers.application.currentPath', /^admin\./),
@ -45,7 +45,7 @@ export default Ember.Controller.extend({
const currentUsername = this.get('username'),
wasVisible = this.get('visible'),
post = this.get('viewingTopic') && postId ? this.get('controllers.topic.postStream').findLoadedPost(postId) : null;
post = this.get('viewingTopic') && postId ? this.get('postStream').findLoadedPost(postId) : null;
this.setProperties({ avatar: null, post: post, username: username });

View File

@ -196,7 +196,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
var selectedPostId = parseInt($('.topic-post.selected article.boxed').data('post-id'), 10);
if (selectedPostId) {
var topicController = container.lookup('controller:topic'),
post = topicController.get('postStream.posts').findBy('id', selectedPostId);
post = topicController.get('model.postStream.posts').findBy('id', selectedPostId);
if (post) {
topicController.send(action, post);
}

View File

@ -221,7 +221,7 @@ Discourse.URL = Ember.Object.createWithMixins({
var container = Discourse.__container__,
topicController = container.lookup('controller:topic'),
opts = {},
postStream = topicController.get('postStream');
postStream = topicController.get('model.postStream');
if (newMatches[3]) opts.nearPost = newMatches[3];
if (path.match(/last$/)) { opts.nearPost = topicController.get('highest_post_number'); }

View File

@ -1,4 +1,6 @@
export default Em.Mixin.create({
flashMessage: null,
needs: ['modal'],
flash: function(message, messageClass) {

View File

@ -20,10 +20,11 @@ export default Ember.Mixin.create({
_rerenderString() {
const $sel = this.$();
if ($sel) { return; }
if (!$sel) { return; }
const buffer = [];
this.renderString(buffer);
$sel.html(buffer.join(''));
},

View File

@ -241,7 +241,7 @@ Ember.CloakedCollectionView.reopen({
// topic_route deactivate
$('.posts,#topic-title').hide();
self.cleanUp();
self.set('controller.postStream.loaded', false);
self.set('controller.model.postStream.loaded', false);
};
this.set('_callback', cb);
popstateCallbacks.addObject(cb);

View File

@ -30,7 +30,7 @@ export default Discourse.Route.extend({
progress = postStream.progressIndexOfPost(closestPost);
topicController.setProperties({
currentPost: closest,
'model.currentPost': closest,
enteredAt: new Date().getTime().toString(),
});

View File

@ -182,7 +182,7 @@ const TopicRoute = Discourse.Route.extend(ShowFooter, {
this.controllerFor('user-card').set('visible', false);
const topicController = this.controllerFor('topic'),
postStream = topicController.get('postStream');
postStream = topicController.get('model.postStream');
postStream.cancelFilter();
topicController.set('multiSelect', false);

View File

@ -1,9 +1,9 @@
<form {{action "saveAutoClose" on="submit"}}>
<div class="modal-body">
{{auto-close-form autoCloseTime=auto_close_time
{{auto-close-form autoCloseTime=model.auto_close_time
autoCloseValid=auto_close_valid
autoCloseBasedOnLastPost=details.auto_close_based_on_last_post
limited=details.auto_close_based_on_last_post }}
autoCloseBasedOnLastPost=model.details.auto_close_based_on_last_post
limited=model.details.auto_close_based_on_last_post }}
</div>
<div class="modal-footer">
<button class='btn btn-primary' type='submit' {{bind-attr disabled="auto_close_invalid"}}>{{i18n 'topic.auto_close_save'}}</button>

View File

@ -1,12 +1,12 @@
<div class="modal-body feature-topic">
{{#if pinned_at}}
{{#if model.pinned_at}}
<div class="feature-section">
<div class="button">
{{d-button action="unpin" icon="thumb-tack" label="topic.feature.unpin" class="btn-primary"}}
</div>
<div class="desc">
<p>{{{unPinMessage}}}</p>
{{#if pinned_globally}}
{{#if model.pinned_globally}}
<p>{{i18n "topic.feature_topic.global_pin_note"}}</p>
<p>
{{#conditional-loading-spinner size="small" condition=loading}}
@ -57,14 +57,14 @@
<hr>
<div class="feature-section">
<div class="button">
{{#if isBanner}}
{{#if model.isBanner}}
{{d-button action="removeBanner" icon="thumb-tack" label="topic.feature.remove_banner" class="btn-primary"}}
{{else}}
{{d-button action="makeBanner" icon="thumb-tack" label="topic.feature.make_banner" class="btn-primary"}}
{{/if}}
</div>
<div class="desc">
{{#if isBanner}}
{{#if model.isBanner}}
<p>{{i18n "topic.feature_topic.remove_banner"}}</p>
{{else}}
<p>{{i18n "topic.feature_topic.make_banner"}}</p>

View File

@ -1,4 +1,4 @@
{{post-gap post=this postStream=controller.postStream before="true"}}
{{post-gap post=this postStream=controller.model.postStream before="true"}}
<div class='row'>
{{view 'reply-history' content=replyHistory}}
@ -9,11 +9,11 @@
<div class='topic-avatar'>
<div class="contents">
{{#unboundIf userDeleted}}
{{#if userDeleted}}
<i class="fa fa-trash-o deleted-user-avatar"></i>
{{else}}
{{raw "post/poster-avatar" post=this classNames="main-avatar"}}
{{/unboundIf}}
{{/if}}
{{plugin-outlet "poster-avatar-bottom"}}
</div>
</div>
@ -42,14 +42,14 @@
{{#if wiki}}
<div class="post-info wiki" title="{{i18n 'post.wiki.about'}}" {{action "editPost" this}}>{{fa-icon "pencil-square-o"}}</div>
{{/if}}
{{#unboundIf via_email}}
{{#if via_email}}
{{#if canViewRawEmail}}
<div class="post-info via-email raw-email" title="{{i18n 'post.via_email'}}" {{action "showRawEmail" this}}>{{fa-icon "envelope-o"}}</div>
{{else}}
<div class="post-info via-email" title="{{i18n 'post.via_email'}}">{{fa-icon "envelope-o"}}</div>
{{/if}}
{{/unboundIf}}
{{#unboundIf showUserReplyTab}}
{{/if}}
{{#if showUserReplyTab}}
<a href {{action "toggleReplyHistory" this target="view"}} class='reply-to-tab'>
{{#if loadingReplyHistory}}
{{i18n 'loading'}}
@ -59,7 +59,7 @@
<span>{{reply_to_user.username}}</span>
{{/if}}
</a>
{{/unboundIf}}
{{/if}}
<div {{bind-attr class=":read-state read"}} title="{{i18n 'post.unread'}}">{{fa-icon "circle"}}</div>
</div>
@ -106,4 +106,4 @@
</article>
{{post-gap post=this postStream=controller.postStream before="false"}}
{{post-gap post=this postStream=controller.model.postStream before="false"}}

View File

@ -1,11 +1,11 @@
<p>{{count-i18n key=topic.multi_select.description countBinding="selectedPostsCount"}}</p>
<p>{{count-i18n key=topic.multi_select.description count=selectedPostsCount}}</p>
{{#if canSelectAll}}
<p><a href='#' {{action "selectAll"}}>{{i18n 'topic.multi_select.select_all'}}</a></p>
<p><a href {{action "selectAll"}}>{{i18n 'topic.multi_select.select_all'}}</a></p>
{{/if}}
{{#if canDeselectAll}}
<p><a href='#' {{action "deselectAll"}}>{{i18n 'topic.multi_select.deselect_all'}}</a></p>
<p><a href {{action "deselectAll"}}>{{i18n 'topic.multi_select.deselect_all'}}</a></p>
{{/if}}
{{#if canDeleteSelected}}
@ -22,4 +22,4 @@
<button class='btn' {{action "changeOwner"}}><i class='fa fa-user'></i> {{i18n 'topic.change_owner.action'}}</button>
{{/if}}
<p class='cancel'><a href='#' {{action "toggleMultiSelect"}}>{{i18n 'topic.multi_select.cancel'}}</a></p>
<p class='cancel'><a href {{action "toggleMultiSelect"}}>{{i18n 'topic.multi_select.cancel'}}</a></p>

View File

@ -11,7 +11,7 @@
</div>
{{#each s in sources}}
{{share-source source=s title=title action="share"}}
{{share-source source=s title=view.title action="share"}}
{{/each}}
<div class='link'>

View File

@ -5,7 +5,7 @@
{{d-button action="toggleMultiSelect" icon="tasks" label="topic.actions.multi_select" class="btn-admin"}}
</li>
{{#if details.can_delete}}
{{#if model.details.can_delete}}
<li>
{{d-button action="deleteTopic" icon="trash-o" label="topic.actions.delete" class="btn-admin btn-danger"}}
</li>
@ -18,7 +18,7 @@
{{/if}}
<li>
{{#if closed}}
{{#if model.closed}}
{{d-button action="toggleClosed" icon="unlock" label="topic.actions.open" class="btn-admin"}}
{{else}}
{{d-button action="toggleClosed" icon="lock" label="topic.actions.close" class="btn-admin"}}
@ -26,8 +26,8 @@
{{/if}}
</li>
{{#unless isPrivateMessage}}
{{#if visible}}
{{#unless model.isPrivateMessage}}
{{#if model.visible}}
<li>
{{#if isFeatured}}
{{d-button action="showFeatureTopic" icon="thumb-tack" label="topic.actions.unpin" class="btn-admin"}}
@ -39,7 +39,7 @@
{{/unless}}
<li>
{{#if archived}}
{{#if model.archived}}
{{d-button action="toggleArchived" icon="folder" label="topic.actions.unarchive" class="btn-admin"}}
{{else}}
{{d-button action="toggleArchived" icon="folder" label="topic.actions.archive" class="btn-admin"}}
@ -47,7 +47,7 @@
</li>
<li>
{{#if visible}}
{{#if model.visible}}
{{d-button action="toggleVisibility" icon="eye-slash" label="topic.actions.invisible" class="btn-admin"}}
{{else}}
{{d-button action="toggleVisibility" icon="eye" label="topic.actions.visible" class="btn-admin"}}

View File

@ -18,7 +18,7 @@
{{/if}}
<nav id='topic-progress' title="{{i18n 'topic.progress.title'}}" {{bind-attr class="hideProgress:hidden"}}>
<div class='nums'>
<h4>{{progressPosition}}</h4><span {{bind-attr class="hugeNumberOfPosts:hidden"}}> <span>/</span> <h4>{{postStream.filteredPostsCount}}</h4></span>
<h4>{{progressPosition}}</h4><span {{bind-attr class="hugeNumberOfPosts:hidden"}}> <span>/</span> <h4>{{model.postStream.filteredPostsCount}}</h4></span>
</div>
<i {{bind-attr class=":fa expanded::fa-sort"}}></i>
<div class='bg'>&nbsp;</div>

View File

@ -1,19 +1,19 @@
<div class='container'>
{{custom-html "top"}}
{{global-notice}}
{{discourse-banner user=currentUser banner=site.banner overlay=view.hasScrolled hide=errorLoading}}
{{discourse-banner user=currentUser banner=site.banner overlay=view.hasScrolled hide=model.errorLoading}}
</div>
{{plugin-outlet "topic-above-post-stream"}}
{{#if postStream.loaded}}
{{#if postStream.firstPostPresent}}
{{#if model.postStream.loaded}}
{{#if model.postStream.firstPostPresent}}
<div id='topic-title'>
<div class='container'>
<div class="title-wrapper">
{{#if editingTopic}}
{{#if isPrivateMessage}}
{{#if model.isPrivateMessage}}
<span class="private-message-glyph">{{fa-icon "envelope"}}</span>
{{autofocus-text-field id='edit-title' value=buffered.title maxLength=maxTitleLength}}
{{else}}
@ -28,23 +28,23 @@
{{d-button action="cancelEditingTopic" class="btn-small no-text cancel-edit" icon="times"}}
{{else}}
<h1>
{{#unless is_warning}}
{{#unless model.is_warning}}
<span class="private-message-glyph">{{fa-icon "envelope"}}</span>
{{/unless}}
{{#if details.loaded}}
{{#if model.details.loaded}}
{{topic-status topic=model}}
<a href='{{unbound url}}' {{action "jumpTop"}} class='fancy-title'>
{{{fancy_title}}}
<a href='{{unbound model.url}}' {{action "jumpTop"}} class='fancy-title'>
{{{model.fancy_title}}}
</a>
{{/if}}
{{#if details.can_edit}}
{{#if model.details.can_edit}}
<a href {{action "editTopic"}} class='edit-topic' title='{{i18n 'edit'}}'>{{fa-icon "pencil"}}</a>
{{/if}}
</h1>
{{#unless isPrivateMessage}}
{{#unless model.isPrivateMessage}}
{{topic-category topic=model}}
{{/unless}}
{{/if}}
@ -59,39 +59,29 @@
{{view "selected-posts"}}
<div class="row">
<section class="topic-area" id='topic' data-topic-id='{{unbound id}}'>
<section class="topic-area" id='topic' data-topic-id='{{unbound model.id}}'>
<div class='posts-wrapper'>
{{render 'topic-progress'}}
{{conditional-loading-spinner condition=postStream.loadingAbove}}
{{conditional-loading-spinner condition=model.postStream.loadingAbove}}
{{#unless postStream.loadingFilter}}
{{cloaked-collection itemViewClass="post"
idProperty="post_number"
defaultHeight="200"
content=postStream.posts
slackRatio="15"
loadingHTML=""
preservesContext="true"
uncloakDefault="true"
offsetFixedTop="header"
offsetFixedBottom="#reply-control"}}
{{#unless model.postStream.loadingFilter}}
{{/unless}}
{{conditional-loading-spinner condition=postStream.loadingBelow}}
{{conditional-loading-spinner condition=model.postStream.loadingBelow}}
</div>
<div id='topic-bottom'></div>
{{#conditional-loading-spinner condition=postStream.loadingFilter}}
{{#conditional-loading-spinner condition=model.postStream.loadingFilter}}
{{#if loadedAllPosts}}
{{view 'topic-closing' topic=model}}
{{view 'topic-footer-buttons' topic=model}}
{{#if pending_posts_count}}
{{#if model.pending_posts_count}}
<div class='has-pending-posts'>
{{{i18n "queue.has_pending_posts" count=pending_posts_count}}}
{{{i18n "queue.has_pending_posts" count=model.pending_posts_count}}}
{{#link-to 'queued-posts'}}
{{fa-icon 'check'}}
@ -102,11 +92,11 @@
{{plugin-outlet "topic-above-suggested"}}
{{#if details.suggested_topics.length}}
{{#if model.details.suggested_topics.length}}
<div id='suggested-topics'>
<h3>{{i18n 'suggested_topics.title'}}</h3>
<div class='topics'>
{{basic-topic-list topics=details.suggested_topics postsAction="showTopicEntrance"}}
{{basic-topic-list topics=model.details.suggested_topics postsAction="showTopicEntrance"}}
</div>
<h3>{{{view.browseMoreMessage}}}</h3>
</div>

View File

@ -4,22 +4,24 @@ export default ButtonView.extend({
classNames: ['bookmark'],
attributeBindings: ['disabled'],
textKey: function() {
return this.get('controller.bookmarked') ? 'bookmarked.clear_bookmarks' : 'bookmarked.title';
}.property('controller.bookmarked'),
bookmarked: Ember.computed.alias('controller.model.bookmarked'),
rerenderTriggers: ['controller.bookmarked'],
textKey: function() {
return this.get('bookmarked') ? 'bookmarked.clear_bookmarks' : 'bookmarked.title';
}.property('bookmarked'),
rerenderTriggers: ['bookmarked'],
helpKey: function() {
return this.get("controller.bookmarked") ? "bookmarked.help.unbookmark" : "bookmarked.help.bookmark";
}.property("controller.bookmarked"),
return this.get("bookmarked") ? "bookmarked.help.unbookmark" : "bookmarked.help.bookmark";
}.property("bookmarked"),
click: function() {
this.get('controller').send('toggleBookmark');
},
renderIcon: function(buffer) {
var className = this.get("controller.bookmarked") ? "bookmarked" : "";
var className = this.get("bookmarked") ? "bookmarked" : "";
buffer.push("<i class='fa fa-bookmark " + className + "'></i>");
}
});

View File

@ -160,7 +160,7 @@ const ComposerView = Discourse.View.extend(Ember.Evented, {
// If we are editing a post, we'll refresh its contents once. This is a feature that
// allows a user to refresh its contents once.
if (post && post.blank('refreshedPost')) {
if (post && !post.get('refreshedPost')) {
refresh = true;
post.set('refreshedPost', true);
}

View File

@ -4,7 +4,7 @@ export default ButtonView.extend({
textKey: 'topic.invite_reply.title',
helpKey: 'topic.invite_reply.help',
attributeBindings: ['disabled'],
disabled: Em.computed.or('controller.archived', 'controller.closed', 'controller.deleted'),
disabled: Em.computed.or('controller.model.archived', 'controller.model.closed', 'controller.model.deleted'),
renderIcon(buffer) {
buffer.push("<i class='fa fa-users'></i>");

View File

@ -0,0 +1,9 @@
export default Discourse.View.extend({
elementId: 'selected-posts',
topic: Ember.computed.alias('controller.model'),
classNameBindings: ['customVisibility'],
customVisibility: function() {
if (!this.get('controller.multiSelect')) return 'hidden';
}.property('controller.multiSelect')
});

View File

@ -1,21 +0,0 @@
/**
This view is used to handle the interface for multi selecting of posts.
@class SelectedPostsView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.SelectedPostsView = Discourse.View.extend({
elementId: 'selected-posts',
templateName: 'selected_posts',
topicBinding: 'controller.content',
classNameBindings: ['customVisibility'],
customVisibility: (function() {
if (!this.get('controller.multiSelect')) return 'hidden';
}).property('controller.multiSelect')
});

View File

@ -40,15 +40,15 @@ export default Discourse.View.extend({
}.observes('controller.link'),
didInsertElement: function() {
var shareView = this,
var self = this,
$html = $('html');
$html.on('mousedown.outside-share-link', function(e) {
// Use mousedown instead of click so this event is handled before routing occurs when a
// link is clicked (which is a click event) while the share dialog is showing.
if (shareView.$().has(e.target).length !== 0) { return; }
if (self.$().has(e.target).length !== 0) { return; }
shareView.get('controller').send('close');
self.get('controller').send('close');
return true;
});
@ -91,16 +91,16 @@ export default Discourse.View.extend({
$shareLink.css({left: "" + x + "px"});
}
shareView.set('controller.link', url);
shareView.set('controller.postNumber', postNumber);
shareView.set('controller.date', date);
self.set('controller.link', url);
self.set('controller.postNumber', postNumber);
self.set('controller.date', date);
return false;
});
$html.on('keydown.share-view', function(e){
if (e.keyCode === 27) {
shareView.get('controller').send('close');
self.get('controller').send('close');
}
});
},

View File

@ -29,7 +29,7 @@ export default Ember.View.extend({
_updateBar: function() {
Em.run.scheduleOnce('afterRender', this, '_updateProgressBar');
}.observes('controller.streamPercentage', 'postStream.stream.@each'),
}.observes('controller.streamPercentage', 'controller.model.postStream.stream.@each'),
_updateProgressBar: function() {
// speeds up stuff, bypass jquery slowness and extra checks

View File

@ -7,7 +7,8 @@ import { categoryBadgeHTML } from 'discourse/helpers/category-link';
const TopicView = Discourse.View.extend(AddCategoryClass, AddArchetypeClass, Discourse.Scrolling, {
templateName: 'topic',
topicBinding: 'controller.model',
userFiltersBinding: 'controller.userFilters',
userFilters: Ember.computed.alias('controller.model.userFilters'),
classNameBindings: ['controller.multiSelect:multi-select',
'topic.archetype',
'topic.is_warning',
@ -19,7 +20,7 @@ const TopicView = Discourse.View.extend(AddCategoryClass, AddArchetypeClass, Dis
categoryFullSlug: Em.computed.alias('topic.category.fullSlug'),
postStream: Em.computed.alias('controller.postStream'),
postStream: Em.computed.alias('controller.model.postStream'),
archetype: Em.computed.alias('topic.archetype'),

View File

@ -136,7 +136,7 @@ module Tilt
def generate_source(scope)
js_source = ::JSON.generate(data, quirks_mode: true)
js_source = "babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping']})['code']"
js_source = "babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping', 'es6.destructuring']})['code']"
"new module.exports.Compiler(#{js_source}, '#{module_name(scope.root_path, scope.logical_path)}', #{compiler_options}).#{compiler_method}()"
end

View File

@ -25,7 +25,7 @@ export default {
// listen for back-end to tell us when a post has a poll
messageBus.subscribe("/polls", data => {
const post = container.lookup("controller:topic").get("postStream").findLoadedPost(data.post_id);
const post = container.lookup("controller:topic").get('modee.postStream').findLoadedPost(data.post_id);
// HACK to trigger the "postViewUpdated" event
Em.run.next(_ => post.set("cooked", post.get("cooked") + " "));
});
@ -33,8 +33,7 @@ export default {
// overwrite polls
PostView.reopen({
_createPollViews: function($post) {
const self = this,
post = this.get("post"),
const post = this.get("post"),
polls = post.get("polls"),
votes = post.get("polls_votes") || {};
@ -80,4 +79,4 @@ export default {
}.on("willClearRender")
});
}
}
};