Skip to content

Commit

Permalink
fix for gallery upload
Browse files Browse the repository at this point in the history
  • Loading branch information
anamba committed Dec 7, 2021
1 parent 621a4c4 commit 87fecc7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store

Gemfile.lock
pkg/
rdoc/
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/manage/cms_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,8 @@ def receive_gallery
end
end
end
finish_upload_status "'#{File.basename(localdir)}'"

render json: { filename: File.basename(localdir) }.to_json
end

def gallery_setup
Expand Down
2 changes: 1 addition & 1 deletion app/views/manage/cms_pages/_gallery_setup.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
Resize to be at most <%= text_field_tag :max_width, GalleryMaxWidth, :style => 'width: 40px' %> pixels wide and <%= text_field_tag :max_height, GalleryMaxHeight, :style => 'width: 40px' %> pixels high<br/>
<%= text_field_tag 'dirname', params[:dirname], :style => 'display: none' %>
<%= submit_tag 'Finish', :class => 'form_button', :style => 'width: 70px;', :onclick => "this.disabled = true; this.value = 'Please wait...';" %>
<%= submit_tag 'Finish', :class => 'form_button', :style => 'width: 70px;', 'data-disable-with' => 'Please wait...' %>
<%- end -%>
9 changes: 5 additions & 4 deletions app/views/manage/cms_pages/_upload_image.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
const nextButton = document.getElementById("upload-image-next-button");
const finishButton = document.getElementById("upload-image-finish-button");
const uploadFileField = document.getElementById("file_data");
const galleryFileField = document.getElementById("gallery_file_data");
const galleryNextButton = document.getElementById("upload-gallery-next-button");

nextButton.addEventListener("click", (e) => {
Expand Down Expand Up @@ -121,7 +122,7 @@
uploadGalleryForm.addEventListener("submit", async (e) => {
e.preventDefault();

if (uploadFileField.value == "") {
if (galleryFileField.value == "") {
setTimeout(() => {
galleryNextButton.value = "Next";
galleryNextButton.dataset.disableWith = null;
Expand All @@ -130,10 +131,10 @@
return;
}

let file = uploadFileField.files[0];
let formData = new FormData(uploadImageForm);
let file = galleryFileField.files[0];
let formData = new FormData(uploadGalleryForm);

let resp = await fetch(uploadImageForm.action, {
let resp = await fetch(uploadGalleryForm.action, {
method: 'POST',
body: formData
});
Expand Down

0 comments on commit 87fecc7

Please sign in to comment.