FIX: Regression with post history
This commit is contained in:
parent
22844b9e46
commit
9d3b05fa35
|
@ -1,5 +1,6 @@
|
|||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
import { categoryBadgeHTML } from 'discourse/helpers/category-link';
|
||||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
// This controller handles displaying of history
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
|
@ -11,7 +12,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
if (Discourse.Mobile.mobileView) { this.set("viewMode", "inline"); }
|
||||
}.on("init"),
|
||||
|
||||
refresh: function(postId, postVersion) {
|
||||
refresh(postId, postVersion) {
|
||||
this.set("loading", true);
|
||||
|
||||
var self = this;
|
||||
|
@ -20,14 +21,14 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
});
|
||||
},
|
||||
|
||||
hide: function(postId, postVersion) {
|
||||
hide(postId, postVersion) {
|
||||
var self = this;
|
||||
Discourse.Post.hideRevision(postId, postVersion).then(function () {
|
||||
self.refresh(postId, postVersion);
|
||||
});
|
||||
},
|
||||
|
||||
show: function(postId, postVersion) {
|
||||
show(postId, postVersion) {
|
||||
var self = this;
|
||||
Discourse.Post.showRevision(postId, postVersion).then(function () {
|
||||
self.refresh(postId, postVersion);
|
||||
|
@ -36,69 +37,83 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
|
||||
createdAtDate: function() { return moment(this.get("created_at")).format("LLLL"); }.property("created_at"),
|
||||
|
||||
previousVersion: function() { return this.get("current_version") - 1; }.property("current_version"),
|
||||
@computed('model.current_version')
|
||||
previousVersion(current) { return current - 1; },
|
||||
|
||||
displayGoToFirst: function() { return this.get("current_revision") > this.get("first_revision"); }.property("current_revision", "first_revision"),
|
||||
displayGoToPrevious: function() { return this.get("previous_revision") && this.get("current_revision") > this.get("previous_revision"); }.property("current_revision", "previous_revision"),
|
||||
displayRevisions: Em.computed.gt("version_count", 2),
|
||||
displayGoToNext: function() { return this.get("next_revision") && this.get("current_revision") < this.get("next_revision"); }.property("current_revision", "next_revision"),
|
||||
displayGoToLast: function() { return this.get("current_revision") < this.get("last_revision"); }.property("current_revision", "last_revision"),
|
||||
@computed('model.current_revision', 'model.previous_revision')
|
||||
displayGoToPrevious(current, prev) {
|
||||
return prev && current > prev;
|
||||
},
|
||||
|
||||
displayShow: function() { return this.get("previous_hidden") && Discourse.User.currentProp('staff') && !this.get("loading"); }.property("previous_hidden", "loading"),
|
||||
displayHide: function() { return !this.get("previous_hidden") && Discourse.User.currentProp('staff') && !this.get("loading"); }.property("previous_hidden", "loading"),
|
||||
displayRevisions: Ember.computed.gt("model.version_count", 2),
|
||||
displayGoToFirst: Ember.computed.gt('model.current_revision', 'model.first_revision'),
|
||||
displayGoToNext: Ember.computed.lt("model.current_revision", "model.next_revision"),
|
||||
displayGoToLast: Ember.computed.lt("model.current_revision", "model.next_revision"),
|
||||
|
||||
isEitherRevisionHidden: Em.computed.or("previous_hidden", "current_hidden"),
|
||||
@computed('model.previous_hidden', 'loading')
|
||||
displayShow: function(prevHidden, loading) {
|
||||
return prevHidden && this.currentUser.get('staff') && !loading;
|
||||
},
|
||||
|
||||
hiddenClasses: function() {
|
||||
if (this.get("displayingInline")) {
|
||||
@computed('model.previous_hidden', 'loading')
|
||||
displayHide: function(prevHidden, loading) {
|
||||
return !prevHidden && this.currentUser.get('staff') && !loading;
|
||||
},
|
||||
|
||||
isEitherRevisionHidden: Ember.computed.or("model.previous_hidden", "model.current_hidden"),
|
||||
|
||||
@computed('model.previous_hidden', 'model.current_hidden', 'displayingInline')
|
||||
hiddenClasses(prevHidden, currentHidden, displayingInline) {
|
||||
if (displayingInline) {
|
||||
return this.get("isEitherRevisionHidden") ? "hidden-revision-either" : null;
|
||||
} else {
|
||||
var result = [];
|
||||
if (this.get("previous_hidden")) { result.push("hidden-revision-previous"); }
|
||||
if (this.get("current_hidden")) { result.push("hidden-revision-current"); }
|
||||
if (prevHidden) { result.push("hidden-revision-previous"); }
|
||||
if (currentHidden) { result.push("hidden-revision-current"); }
|
||||
return result.join(" ");
|
||||
}
|
||||
}.property("previous_hidden", "current_hidden", "displayingInline"),
|
||||
},
|
||||
|
||||
displayingInline: Em.computed.equal("viewMode", "inline"),
|
||||
displayingSideBySide: Em.computed.equal("viewMode", "side_by_side"),
|
||||
displayingSideBySideMarkdown: Em.computed.equal("viewMode", "side_by_side_markdown"),
|
||||
|
||||
previousCategory: function() {
|
||||
var changes = this.get("category_id_changes");
|
||||
@computed('model.category_id_changes')
|
||||
previousCategory(changes) {
|
||||
if (changes) {
|
||||
var category = Discourse.Category.findById(changes["previous"]);
|
||||
return categoryBadgeHTML(category, { allowUncategorized: true });
|
||||
}
|
||||
}.property("category_id_changes"),
|
||||
},
|
||||
|
||||
currentCategory: function() {
|
||||
var changes = this.get("category_id_changes");
|
||||
@computed('model.category_id_changes')
|
||||
currentCategory(changes) {
|
||||
if (changes) {
|
||||
var category = Discourse.Category.findById(changes["current"]);
|
||||
return categoryBadgeHTML(category, { allowUncategorized: true });
|
||||
}
|
||||
}.property("category_id_changes"),
|
||||
},
|
||||
|
||||
wikiDisabled: function() {
|
||||
var changes = this.get("wiki_changes");
|
||||
@computed('model.wiki_changes')
|
||||
wikiDisabled(changes) {
|
||||
return changes && !changes['current'];
|
||||
}.property('wiki_changes'),
|
||||
},
|
||||
|
||||
postTypeDisabled: function () {
|
||||
var changes = this.get("post_type_changes");
|
||||
@computed('model.post_type_changes')
|
||||
postTypeDisabled(changes) {
|
||||
return (changes && changes['current'] !== this.site.get('post_types.moderator_action'));
|
||||
}.property("post_type_changes"),
|
||||
},
|
||||
|
||||
titleDiff: function() {
|
||||
var viewMode = this.get("viewMode");
|
||||
@computed('viewMode', 'model.title_changes')
|
||||
titleDiff(viewMode) {
|
||||
if (viewMode === "side_by_side_markdown") { viewMode = "side_by_side"; }
|
||||
return this.get("title_changes." + viewMode);
|
||||
}.property("viewMode", "title_changes"),
|
||||
return this.get("model.title_changes." + viewMode);
|
||||
},
|
||||
|
||||
bodyDiff: function() {
|
||||
return this.get("body_changes." + this.get("viewMode"));
|
||||
}.property("viewMode", "body_changes"),
|
||||
@computed('viewMode', 'model.body_changes')
|
||||
bodyDiff(viewMode) {
|
||||
return this.get("model.body_changes." + viewMode);
|
||||
},
|
||||
|
||||
actions: {
|
||||
loadFirstVersion: function() { this.refresh(this.get("post_id"), this.get("first_revision")); },
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<button title="{{i18n 'post.revisions.controls.previous'}}" {{bind-attr class=":btn :standard :no-text displayGoToPrevious::invisible" disabled=loading}} {{action "loadPreviousVersion"}}><i class="fa fa-backward"></i></button>
|
||||
<div id="revision-numbers" {{bind-attr class="displayRevisions::invisible"}}>
|
||||
{{#conditional-loading-spinner condition=loading size="small"}}
|
||||
{{boundI18n revisionsTextKey previousBinding="previousVersion" currentBinding="current_version" totalBinding="version_count"}}
|
||||
{{boundI18n revisionsTextKey previousBinding="previousVersion" currentBinding="model.current_version" totalBinding="model.version_count"}}
|
||||
{{/conditional-loading-spinner}}
|
||||
</div>
|
||||
<button title="{{i18n 'post.revisions.controls.next'}}" {{bind-attr class=":btn :standard :no-text displayGoToNext::invisible" disabled=loading}} {{action "loadNextVersion"}}><i class="fa fa-forward"></i></button>
|
||||
|
@ -26,32 +26,32 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="revision-details">
|
||||
<i class="fa fa-pencil"></i>
|
||||
{{#link-to 'user' username}}
|
||||
{{bound-avatar-template content.avatar_template "small"}} {{username}}
|
||||
{{fa-icon "pencil"}}
|
||||
{{#link-to 'user' model.username}}
|
||||
{{bound-avatar-template model.avatar_template "small"}} {{model.username}}
|
||||
{{/link-to}}
|
||||
<span class="date">{{bound-date created_at}}</span>
|
||||
{{#if edit_reason}}
|
||||
— <span class="edit-reason">{{edit_reason}}</span>
|
||||
<span class="date">{{bound-date model.created_at}}</span>
|
||||
{{#if model.edit_reason}}
|
||||
— <span class="edit-reason">{{model.edit_reason}}</span>
|
||||
{{/if}}
|
||||
{{#unless site.mobileView}}
|
||||
{{#if user_changes}}
|
||||
— {{bound-avatar-template user_changes.previous.avatar_template "small"}} {{user_changes.previous.username}}
|
||||
→ {{bound-avatar-template user_changes.current.avatar_template "small"}} {{user_changes.current.username}}
|
||||
{{#if model.user_changes}}
|
||||
— {{bound-avatar-template model.user_changes.previous.avatar_template "small"}} {{model.user_changes.previous.username}}
|
||||
→ {{bound-avatar-template model.user_changes.current.avatar_template "small"}} {{model.user_changes.current.username}}
|
||||
{{/if}}
|
||||
{{#if wiki_changes}}
|
||||
{{#if model.wiki_changes}}
|
||||
— {{disabled-icon icon="pencil-square-o" secondary=wikiDisabled}}
|
||||
{{/if}}
|
||||
{{#if post_type_changes}}
|
||||
{{#if model.post_type_changes}}
|
||||
— {{disabled-icon icon="shield" disabled=postTypeDisabled}}
|
||||
{{/if}}
|
||||
{{#if category_id_changes}}
|
||||
{{#if model.category_id_changes}}
|
||||
— {{{previousCategory}}} → {{{currentCategory}}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
</div>
|
||||
<div id="revisions" {{bind-attr class="hiddenClasses"}}>
|
||||
{{#if title_changes}}
|
||||
{{#if model.title_changes}}
|
||||
<div class="row">
|
||||
<h2>{{{titleDiff}}}</h2>
|
||||
</div>
|
||||
|
@ -59,21 +59,21 @@
|
|||
{{#if site.mobileView}}
|
||||
{{#if user_changes}}
|
||||
<div class="row">
|
||||
{{bound-avatar-template user_changes.previous.avatar_template "small"}} {{user_changes.previous.username}}
|
||||
→ {{bound-avatar-template user_changes.current.avatar_template "small"}} {{user_changes.current.username}}
|
||||
{{bound-avatar-template model.user_changes.previous.avatar_template "small"}} {{model.user_changes.previous.username}}
|
||||
→ {{bound-avatar-template model.user_changes.current.avatar_template "small"}} {{model.user_changes.current.username}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if wiki_changes}}
|
||||
{{#if model.wiki_changes}}
|
||||
<div class="row">
|
||||
{{disabled-icon icon="pencil-square-o" secondary=wikiDisabled}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if post_type_changes}}
|
||||
{{#if model.post_type_changes}}
|
||||
<div class="row">
|
||||
{{disabled-icon icon="shield" disabled=postTypeDisabled}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if category_id_changes}}
|
||||
{{#if model.category_id_changes}}
|
||||
<div class="row">
|
||||
{{{previousCategory}}} → {{{currentCategory}}}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue