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 ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||||
import { categoryBadgeHTML } from 'discourse/helpers/category-link';
|
import { categoryBadgeHTML } from 'discourse/helpers/category-link';
|
||||||
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
// This controller handles displaying of history
|
// This controller handles displaying of history
|
||||||
export default Ember.Controller.extend(ModalFunctionality, {
|
export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
|
@ -11,7 +12,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
if (Discourse.Mobile.mobileView) { this.set("viewMode", "inline"); }
|
if (Discourse.Mobile.mobileView) { this.set("viewMode", "inline"); }
|
||||||
}.on("init"),
|
}.on("init"),
|
||||||
|
|
||||||
refresh: function(postId, postVersion) {
|
refresh(postId, postVersion) {
|
||||||
this.set("loading", true);
|
this.set("loading", true);
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -20,14 +21,14 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
hide: function(postId, postVersion) {
|
hide(postId, postVersion) {
|
||||||
var self = this;
|
var self = this;
|
||||||
Discourse.Post.hideRevision(postId, postVersion).then(function () {
|
Discourse.Post.hideRevision(postId, postVersion).then(function () {
|
||||||
self.refresh(postId, postVersion);
|
self.refresh(postId, postVersion);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(postId, postVersion) {
|
show(postId, postVersion) {
|
||||||
var self = this;
|
var self = this;
|
||||||
Discourse.Post.showRevision(postId, postVersion).then(function () {
|
Discourse.Post.showRevision(postId, postVersion).then(function () {
|
||||||
self.refresh(postId, postVersion);
|
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"),
|
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"),
|
@computed('model.current_revision', 'model.previous_revision')
|
||||||
displayGoToPrevious: function() { return this.get("previous_revision") && this.get("current_revision") > this.get("previous_revision"); }.property("current_revision", "previous_revision"),
|
displayGoToPrevious(current, prev) {
|
||||||
displayRevisions: Em.computed.gt("version_count", 2),
|
return prev && current > prev;
|
||||||
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"),
|
|
||||||
|
|
||||||
displayShow: 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),
|
||||||
displayHide: function() { return !this.get("previous_hidden") && Discourse.User.currentProp('staff') && !this.get("loading"); }.property("previous_hidden", "loading"),
|
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() {
|
@computed('model.previous_hidden', 'loading')
|
||||||
if (this.get("displayingInline")) {
|
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;
|
return this.get("isEitherRevisionHidden") ? "hidden-revision-either" : null;
|
||||||
} else {
|
} else {
|
||||||
var result = [];
|
var result = [];
|
||||||
if (this.get("previous_hidden")) { result.push("hidden-revision-previous"); }
|
if (prevHidden) { result.push("hidden-revision-previous"); }
|
||||||
if (this.get("current_hidden")) { result.push("hidden-revision-current"); }
|
if (currentHidden) { result.push("hidden-revision-current"); }
|
||||||
return result.join(" ");
|
return result.join(" ");
|
||||||
}
|
}
|
||||||
}.property("previous_hidden", "current_hidden", "displayingInline"),
|
},
|
||||||
|
|
||||||
displayingInline: Em.computed.equal("viewMode", "inline"),
|
displayingInline: Em.computed.equal("viewMode", "inline"),
|
||||||
displayingSideBySide: Em.computed.equal("viewMode", "side_by_side"),
|
displayingSideBySide: Em.computed.equal("viewMode", "side_by_side"),
|
||||||
displayingSideBySideMarkdown: Em.computed.equal("viewMode", "side_by_side_markdown"),
|
displayingSideBySideMarkdown: Em.computed.equal("viewMode", "side_by_side_markdown"),
|
||||||
|
|
||||||
previousCategory: function() {
|
@computed('model.category_id_changes')
|
||||||
var changes = this.get("category_id_changes");
|
previousCategory(changes) {
|
||||||
if (changes) {
|
if (changes) {
|
||||||
var category = Discourse.Category.findById(changes["previous"]);
|
var category = Discourse.Category.findById(changes["previous"]);
|
||||||
return categoryBadgeHTML(category, { allowUncategorized: true });
|
return categoryBadgeHTML(category, { allowUncategorized: true });
|
||||||
}
|
}
|
||||||
}.property("category_id_changes"),
|
},
|
||||||
|
|
||||||
currentCategory: function() {
|
@computed('model.category_id_changes')
|
||||||
var changes = this.get("category_id_changes");
|
currentCategory(changes) {
|
||||||
if (changes) {
|
if (changes) {
|
||||||
var category = Discourse.Category.findById(changes["current"]);
|
var category = Discourse.Category.findById(changes["current"]);
|
||||||
return categoryBadgeHTML(category, { allowUncategorized: true });
|
return categoryBadgeHTML(category, { allowUncategorized: true });
|
||||||
}
|
}
|
||||||
}.property("category_id_changes"),
|
},
|
||||||
|
|
||||||
wikiDisabled: function() {
|
@computed('model.wiki_changes')
|
||||||
var changes = this.get("wiki_changes");
|
wikiDisabled(changes) {
|
||||||
return changes && !changes['current'];
|
return changes && !changes['current'];
|
||||||
}.property('wiki_changes'),
|
},
|
||||||
|
|
||||||
postTypeDisabled: function () {
|
@computed('model.post_type_changes')
|
||||||
var changes = this.get("post_type_changes");
|
postTypeDisabled(changes) {
|
||||||
return (changes && changes['current'] !== this.site.get('post_types.moderator_action'));
|
return (changes && changes['current'] !== this.site.get('post_types.moderator_action'));
|
||||||
}.property("post_type_changes"),
|
},
|
||||||
|
|
||||||
titleDiff: function() {
|
@computed('viewMode', 'model.title_changes')
|
||||||
var viewMode = this.get("viewMode");
|
titleDiff(viewMode) {
|
||||||
if (viewMode === "side_by_side_markdown") { viewMode = "side_by_side"; }
|
if (viewMode === "side_by_side_markdown") { viewMode = "side_by_side"; }
|
||||||
return this.get("title_changes." + viewMode);
|
return this.get("model.title_changes." + viewMode);
|
||||||
}.property("viewMode", "title_changes"),
|
},
|
||||||
|
|
||||||
bodyDiff: function() {
|
@computed('viewMode', 'model.body_changes')
|
||||||
return this.get("body_changes." + this.get("viewMode"));
|
bodyDiff(viewMode) {
|
||||||
}.property("viewMode", "body_changes"),
|
return this.get("model.body_changes." + viewMode);
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
loadFirstVersion: function() { this.refresh(this.get("post_id"), this.get("first_revision")); },
|
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>
|
<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"}}>
|
<div id="revision-numbers" {{bind-attr class="displayRevisions::invisible"}}>
|
||||||
{{#conditional-loading-spinner condition=loading size="small"}}
|
{{#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}}
|
{{/conditional-loading-spinner}}
|
||||||
</div>
|
</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>
|
<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>
|
</div>
|
||||||
<div id="revision-details">
|
<div id="revision-details">
|
||||||
<i class="fa fa-pencil"></i>
|
{{fa-icon "pencil"}}
|
||||||
{{#link-to 'user' username}}
|
{{#link-to 'user' model.username}}
|
||||||
{{bound-avatar-template content.avatar_template "small"}} {{username}}
|
{{bound-avatar-template model.avatar_template "small"}} {{model.username}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
<span class="date">{{bound-date created_at}}</span>
|
<span class="date">{{bound-date model.created_at}}</span>
|
||||||
{{#if edit_reason}}
|
{{#if model.edit_reason}}
|
||||||
— <span class="edit-reason">{{edit_reason}}</span>
|
— <span class="edit-reason">{{model.edit_reason}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#unless site.mobileView}}
|
{{#unless site.mobileView}}
|
||||||
{{#if user_changes}}
|
{{#if model.user_changes}}
|
||||||
— {{bound-avatar-template user_changes.previous.avatar_template "small"}} {{user_changes.previous.username}}
|
— {{bound-avatar-template model.user_changes.previous.avatar_template "small"}} {{model.user_changes.previous.username}}
|
||||||
→ {{bound-avatar-template user_changes.current.avatar_template "small"}} {{user_changes.current.username}}
|
→ {{bound-avatar-template model.user_changes.current.avatar_template "small"}} {{model.user_changes.current.username}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if wiki_changes}}
|
{{#if model.wiki_changes}}
|
||||||
— {{disabled-icon icon="pencil-square-o" secondary=wikiDisabled}}
|
— {{disabled-icon icon="pencil-square-o" secondary=wikiDisabled}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if post_type_changes}}
|
{{#if model.post_type_changes}}
|
||||||
— {{disabled-icon icon="shield" disabled=postTypeDisabled}}
|
— {{disabled-icon icon="shield" disabled=postTypeDisabled}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if category_id_changes}}
|
{{#if model.category_id_changes}}
|
||||||
— {{{previousCategory}}} → {{{currentCategory}}}
|
— {{{previousCategory}}} → {{{currentCategory}}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
<div id="revisions" {{bind-attr class="hiddenClasses"}}>
|
<div id="revisions" {{bind-attr class="hiddenClasses"}}>
|
||||||
{{#if title_changes}}
|
{{#if model.title_changes}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h2>{{{titleDiff}}}</h2>
|
<h2>{{{titleDiff}}}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
@ -59,21 +59,21 @@
|
||||||
{{#if site.mobileView}}
|
{{#if site.mobileView}}
|
||||||
{{#if user_changes}}
|
{{#if user_changes}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{bound-avatar-template user_changes.previous.avatar_template "small"}} {{user_changes.previous.username}}
|
{{bound-avatar-template model.user_changes.previous.avatar_template "small"}} {{model.user_changes.previous.username}}
|
||||||
→ {{bound-avatar-template user_changes.current.avatar_template "small"}} {{user_changes.current.username}}
|
→ {{bound-avatar-template model.user_changes.current.avatar_template "small"}} {{model.user_changes.current.username}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if wiki_changes}}
|
{{#if model.wiki_changes}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{disabled-icon icon="pencil-square-o" secondary=wikiDisabled}}
|
{{disabled-icon icon="pencil-square-o" secondary=wikiDisabled}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if post_type_changes}}
|
{{#if model.post_type_changes}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{disabled-icon icon="shield" disabled=postTypeDisabled}}
|
{{disabled-icon icon="shield" disabled=postTypeDisabled}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if category_id_changes}}
|
{{#if model.category_id_changes}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{{previousCategory}}} → {{{currentCategory}}}
|
{{{previousCategory}}} → {{{currentCategory}}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue