Skip to content

Commit

Permalink
Simplify the code related to questionnaire templates previews (#11743)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahukkanen committed Oct 11, 2023
1 parent dfbd558 commit 57a4b46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Expand Up @@ -8,8 +8,6 @@ module Admin
class QuestionnaireTemplatesController < Decidim::Templates::Admin::ApplicationController
include Decidim::TranslatableAttributes

skip_before_action :verify_authenticity_token, only: :preview

helper_method :template

def index
Expand Down
Expand Up @@ -13,16 +13,10 @@ $(() => {
return;
}
const params = new URLSearchParams({ id: id });
fetch(`${previewURL}?${params.toString()}`, {
method: "GET",
headers: { "Content-Type": "application/json" }
}).then((response) => response.text()).then((data) => {
const script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML = data;
document.getElementsByTagName("head")[0].appendChild(script);
}).catch((error) => {
console.error(error); // eslint-disable-line no-console
Rails.ajax({
url: `${previewURL}?${params.toString()}`,
type: "GET",
error: (data) => (console.error(data))
});
}

Expand Down

0 comments on commit 57a4b46

Please sign in to comment.