Merge pull request !2932 from rhodecode-enterprise-ce fix/hide_show_upload_section_on_comment

fix: toggle file upload section for comments preview
This commit is contained in:
Andrii Verbytskyi 2025-12-24 18:21:39 +00:00
commit b937ba1cf0
2 changed files with 16 additions and 4 deletions

View file

@ -112,6 +112,8 @@ var _submitAjaxPOST = function(url, postData, successHandler, failHandler) {
this.cancelButton = this.withLineNo('#cancel-btn');
this.commentType = this.withLineNo('#comment_type');
this.fileUploadSection = this.withLineNo("#file-upload-section");
this.resolvesId = null;
this.resolvesActionId = null;
@ -407,6 +409,14 @@ var _submitAjaxPOST = function(url, postData, successHandler, failHandler) {
self.setActionButtonsDisabled(false);
};
this.showUploadSection = function(show) {
if (show) {
$(this.fileUploadSection).show();
} else {
$(this.fileUploadSection).hide();
}
}
this.setActionButtonsDisabled = function(state, excludeCancelBtn, submitEvent) {
excludeCancelBtn = excludeCancelBtn || false;
submitEvent = submitEvent || false;
@ -468,16 +478,20 @@ var _submitAjaxPOST = function(url, postData, successHandler, failHandler) {
$(self.editButton).parent().addClass('active');
$(self.editContainer).show();
self.showUploadSection(true);
});
$(this.previewButton).on('click', function(e) {
e.preventDefault();
var text = self.cm.getValue();
if (text === "") {
return;
}
self.showUploadSection(false);
var postData = {
'text': text,
'renderer': templateContext.visual.default_renderer,
@ -501,9 +515,7 @@ var _submitAjaxPOST = function(url, postData, successHandler, failHandler) {
self.resetCommentFormState(text)
};
self.submitAjaxPOST(
self.previewUrl, postData, self.previewSuccessCallback,
previewFailCallback);
self.submitAjaxPOST(self.previewUrl, postData, self.previewSuccessCallback, previewFailCallback);
$(self.previewButton).parent().addClass('active');
$(self.editButton).parent().removeClass('active');

View file

@ -466,7 +466,7 @@
</div>
<div class="comment-area-footer comment-attachment-uploader">
<div class="toolbar">
<div class="toolbar" id="file-upload-section_${lineno_id}">
<div style="display: none" class="comment-attachment-uploader-template"></div>