mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-28 01:56:01 -05:00
fix edit reason when editing a reply
This commit is contained in:
parent
a2466d182f
commit
6e3de67977
5 changed files with 76 additions and 38 deletions
|
@ -12,6 +12,9 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
replyAsNewTopicDraft: Em.computed.equal('model.draftKey', Discourse.Composer.REPLY_AS_NEW_TOPIC_KEY),
|
replyAsNewTopicDraft: Em.computed.equal('model.draftKey', Discourse.Composer.REPLY_AS_NEW_TOPIC_KEY),
|
||||||
checkedMessages: false,
|
checkedMessages: false,
|
||||||
|
|
||||||
|
showEditReason: false,
|
||||||
|
editReason: null,
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super();
|
this._super();
|
||||||
this.set('similarTopics', Em.A());
|
this.set('similarTopics', Em.A());
|
||||||
|
@ -38,6 +41,10 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
|
|
||||||
save: function() {
|
save: function() {
|
||||||
this.save();
|
this.save();
|
||||||
|
},
|
||||||
|
|
||||||
|
displayEditReason: function() {
|
||||||
|
this.set("showEditReason", true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -76,12 +83,15 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
|
|
||||||
save: function(force) {
|
save: function(force) {
|
||||||
var composer = this.get('model'),
|
var composer = this.get('model'),
|
||||||
composerController = this;
|
self = this;
|
||||||
|
|
||||||
if( composer.get('cantSubmitPost') ) {
|
if(composer.get('cantSubmitPost')) {
|
||||||
this.set('view.showTitleTip', Date.now());
|
var now = Date.now();
|
||||||
this.set('view.showCategoryTip', Date.now());
|
this.setProperties({
|
||||||
this.set('view.showReplyTip', Date.now());
|
"view.showTitleTip": now,
|
||||||
|
"view.showCategoryTip": now,
|
||||||
|
"view.showReplyTip": now
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +118,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
"callback": function(){
|
"callback": function(){
|
||||||
composer.set('topic', topic);
|
composer.set('topic', topic);
|
||||||
composer.set('post', null);
|
composer.set('post', null);
|
||||||
composerController.save(true);
|
self.save(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -117,7 +127,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
"label": I18n.t("composer.reply_original") + "<br/><div class='topic-title overflow-ellipsis'>" + this.get('model.topic.title') + "</div>",
|
"label": I18n.t("composer.reply_original") + "<br/><div class='topic-title overflow-ellipsis'>" + this.get('model.topic.title') + "</div>",
|
||||||
"class": "btn-primary btn-reply-on-original",
|
"class": "btn-primary btn-reply-on-original",
|
||||||
"callback": function(){
|
"callback": function(){
|
||||||
composerController.save(true);
|
self.save(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -127,16 +137,17 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return composer.save({
|
return composer.save({
|
||||||
imageSizes: this.get('view').imageSizes()
|
imageSizes: this.get('view').imageSizes(),
|
||||||
|
editReason: this.get("editReason")
|
||||||
}).then(function(opts) {
|
}).then(function(opts) {
|
||||||
|
|
||||||
// If we replied as a new topic successfully, remove the draft.
|
// If we replied as a new topic successfully, remove the draft.
|
||||||
if (composerController.get('replyAsNewTopicDraft')) {
|
if (self.get('replyAsNewTopicDraft')) {
|
||||||
composerController.destroyDraft();
|
self.destroyDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
composerController.close();
|
self.close();
|
||||||
|
|
||||||
var currentUser = Discourse.User.current();
|
var currentUser = Discourse.User.current();
|
||||||
if (composer.get('creatingTopic')) {
|
if (composer.get('creatingTopic')) {
|
||||||
|
@ -220,6 +231,11 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
open: function(opts) {
|
open: function(opts) {
|
||||||
if (!opts) opts = {};
|
if (!opts) opts = {};
|
||||||
|
|
||||||
|
this.setProperties({
|
||||||
|
showEditReason: false,
|
||||||
|
editReason: null
|
||||||
|
});
|
||||||
|
|
||||||
var composerMessages = this.get('controllers.composerMessages');
|
var composerMessages = this.get('controllers.composerMessages');
|
||||||
composerMessages.reset();
|
composerMessages.reset();
|
||||||
|
|
||||||
|
@ -233,7 +249,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
|
|
||||||
// ensure we have a view now, without it transitions are going to be messed
|
// ensure we have a view now, without it transitions are going to be messed
|
||||||
var view = this.get('view');
|
var view = this.get('view');
|
||||||
var composerController = this;
|
var self = this;
|
||||||
if (!view) {
|
if (!view) {
|
||||||
|
|
||||||
// TODO: We should refactor how composer is inserted. It should probably use a
|
// TODO: We should refactor how composer is inserted. It should probably use a
|
||||||
|
@ -247,7 +263,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
// we need to change stuff, otherwise css animations don't kick in
|
// we need to change stuff, otherwise css animations don't kick in
|
||||||
Em.run.next(function() {
|
Em.run.next(function() {
|
||||||
Em.run.next(function() {
|
Em.run.next(function() {
|
||||||
composerController.open(opts);
|
self.open(opts);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return promise;
|
return promise;
|
||||||
|
@ -267,7 +283,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
} else {
|
} else {
|
||||||
opts.tested = true;
|
opts.tested = true;
|
||||||
if (!opts.ignoreIfChanged) {
|
if (!opts.ignoreIfChanged) {
|
||||||
this.cancelComposer().then(function() { composerController.open(opts); },
|
this.cancelComposer().then(function() { self.open(opts); },
|
||||||
function() { return promise.reject(); });
|
function() { return promise.reject(); });
|
||||||
}
|
}
|
||||||
return promise;
|
return promise;
|
||||||
|
@ -279,7 +295,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
Discourse.Draft.get(opts.draftKey).then(function(data) {
|
Discourse.Draft.get(opts.draftKey).then(function(data) {
|
||||||
opts.draftSequence = data.draft_sequence;
|
opts.draftSequence = data.draft_sequence;
|
||||||
opts.draft = data.draft;
|
opts.draft = data.draft;
|
||||||
return composerController.open(opts);
|
return self.open(opts);
|
||||||
});
|
});
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -316,15 +332,15 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
cancelComposer: function() {
|
cancelComposer: function() {
|
||||||
var composerController = this;
|
var self = this;
|
||||||
|
|
||||||
return Ember.Deferred.promise(function (promise) {
|
return Ember.Deferred.promise(function (promise) {
|
||||||
if (composerController.get('model.hasMetaData') || composerController.get('model.replyDirty')) {
|
if (self.get('model.hasMetaData') || self.get('model.replyDirty')) {
|
||||||
bootbox.confirm(I18n.t("post.abandon"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
bootbox.confirm(I18n.t("post.abandon"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
composerController.destroyDraft();
|
self.destroyDraft();
|
||||||
composerController.get('model').clearState();
|
self.get('model').clearState();
|
||||||
composerController.close();
|
self.close();
|
||||||
promise.resolve();
|
promise.resolve();
|
||||||
} else {
|
} else {
|
||||||
promise.reject();
|
promise.reject();
|
||||||
|
@ -332,8 +348,9 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// it is possible there is some sort of crazy draft with no body ... just give up on it
|
// it is possible there is some sort of crazy draft with no body ... just give up on it
|
||||||
composerController.destroyDraft();
|
self.destroyDraft();
|
||||||
composerController.close();
|
self.get('model').clearState();
|
||||||
|
self.close();
|
||||||
promise.resolve();
|
promise.resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -359,10 +376,12 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
close: function() {
|
close: function() {
|
||||||
this.set('model', null);
|
this.setProperties({
|
||||||
this.set('view.showTitleTip', false);
|
model: null,
|
||||||
this.set('view.showCategoryTip', false);
|
'view.showTitleTip': false,
|
||||||
this.set('view.showReplyTip', false);
|
'view.showCategoryTip': false,
|
||||||
|
'view.showReplyTip': false
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
closeAutocomplete: function() {
|
closeAutocomplete: function() {
|
||||||
|
|
|
@ -389,7 +389,8 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
originalText: null,
|
originalText: null,
|
||||||
reply: null,
|
reply: null,
|
||||||
post: null,
|
post: null,
|
||||||
title: null
|
title: null,
|
||||||
|
editReason: null
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -412,7 +413,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
|
|
||||||
post.setProperties({
|
post.setProperties({
|
||||||
raw: this.get('reply'),
|
raw: this.get('reply'),
|
||||||
editReason: this.get('editReason'),
|
editReason: opts.editReason,
|
||||||
imageSizes: opts.imageSizes,
|
imageSizes: opts.imageSizes,
|
||||||
cooked: $('#wmd-preview').html()
|
cooked: $('#wmd-preview').html()
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,18 @@
|
||||||
|
|
||||||
{{#if model.viewOpen}}
|
{{#if model.viewOpen}}
|
||||||
<div class='control-row reply-area'>
|
<div class='control-row reply-area'>
|
||||||
<div class='reply-to'>{{{model.actionTitle}}}:</div>
|
<div class='reply-to'>
|
||||||
|
{{{model.actionTitle}}}:
|
||||||
|
{{#if canEdit}}
|
||||||
|
{{#if showEditReason}}
|
||||||
|
<div class="edit-reason-input">
|
||||||
|
{{textField value=editReason tabindex="5" id="edit-reason" maxlength="255" placeholderKey="composer.edit_reason_placeholder"}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<a {{action displayEditReason}}>{{i18n composer.show_edit_reason}}</a>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
|
||||||
{{#if model.canEditTitle}}
|
{{#if model.canEditTitle}}
|
||||||
<div class='form-element clearfix'>
|
<div class='form-element clearfix'>
|
||||||
|
@ -39,11 +50,6 @@
|
||||||
{{#if model.showAdminOptions}}
|
{{#if model.showAdminOptions}}
|
||||||
<button {{action toggleAdminOptions target="view"}} class="btn no-text" title='{{i18n composer.admin_options_title}}'><i class="icon icon-wrench"></i></button>
|
<button {{action toggleAdminOptions target="view"}} class="btn no-text" title='{{i18n composer.admin_options_title}}'><i class="icon icon-wrench"></i></button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if canEdit}}
|
|
||||||
<div class="edit-reason-input">
|
|
||||||
{{textField value=model.editReason tabindex="5" id="edit-reason" maxlength="255" placeholderKey="composer.edit_reason_placeholder"}}
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -238,12 +238,11 @@
|
||||||
height: 400px;
|
height: 400px;
|
||||||
}
|
}
|
||||||
.contents {
|
.contents {
|
||||||
input#reply-title, input#edit-reason {
|
input#reply-title {
|
||||||
padding: 7px 10px;
|
padding: 7px 10px;
|
||||||
margin: 6px 10px 3px 0;
|
margin: 6px 10px 3px 0;
|
||||||
}
|
}
|
||||||
input#reply-title { width: 400px; }
|
input#reply-title { width: 400px; }
|
||||||
input#edit-reason { width: 200px; }
|
|
||||||
.wmd-controls {
|
.wmd-controls {
|
||||||
@include transition(top 0.3s ease);
|
@include transition(top 0.3s ease);
|
||||||
top: 100px;
|
top: 100px;
|
||||||
|
@ -254,6 +253,7 @@
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
min-width: 1280px;
|
min-width: 1280px;
|
||||||
.form-element {
|
.form-element {
|
||||||
|
display: inline-block;
|
||||||
.chzn-container {
|
.chzn-container {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
|
@ -283,7 +283,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#reply-title, #edit-reason {
|
.edit-reason-input {
|
||||||
|
display: inline-block;
|
||||||
|
position: absolute;
|
||||||
|
margin-left: 10px;
|
||||||
|
top: 18px;
|
||||||
|
#edit-reason {
|
||||||
|
margin: 0;
|
||||||
|
padding: 5px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#reply-title {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
float: left;
|
float: left;
|
||||||
&:disabled {
|
&:disabled {
|
||||||
|
@ -324,7 +335,7 @@
|
||||||
bottom: 8px;
|
bottom: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.title-input, .category-input, .edit-reason-input {
|
.title-input, .category-input {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,6 +479,7 @@ en:
|
||||||
users_placeholder: "Add a user"
|
users_placeholder: "Add a user"
|
||||||
title_placeholder: "Type your title here. What is this discussion about in one brief sentence?"
|
title_placeholder: "Type your title here. What is this discussion about in one brief sentence?"
|
||||||
edit_reason_placeholder: "Short reason of your edit"
|
edit_reason_placeholder: "Short reason of your edit"
|
||||||
|
show_edit_reason: "(Add a reason)"
|
||||||
reply_placeholder: "Type here. Use Markdown or BBCode to format. Drag or paste an image to upload it."
|
reply_placeholder: "Type here. Use Markdown or BBCode to format. Drag or paste an image to upload it."
|
||||||
view_new_post: "View your new post."
|
view_new_post: "View your new post."
|
||||||
saving: "Saving..."
|
saving: "Saving..."
|
||||||
|
|
Loading…
Reference in a new issue