Skip to content

Commit

Permalink
fix tag inclusion in pdf viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Mar 26, 2024
1 parent c4438eb commit ac16d79
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 29 deletions.
1 change: 1 addition & 0 deletions .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if ENV["SIMPLECOV"]
add_filter "/db/"
add_filter "lib/decidim/participatory_documents/version.rb"
add_filter "lib/decidim/participatory_documents/component.rb"
add_filter "lib/decidim/participatory_documents/test"
add_filter "/spec"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class PdfModalManager {
uiTitle.innerHTML = this.i18n.modalTitle.replace("%{box}", box.div.dataset.position).replace("%{section}", box.sectionNumber);

this.modalLayout.classList.add("show");
$(this.modalLayout).foundation();
// $(this.modalLayout).foundation();

modal.addEventListener("click", (evt) => evt.stopPropagation(), { once: true });
uiClose.addEventListener("click", this._closeHandler.bind(this), { once: true });
Expand Down Expand Up @@ -79,17 +79,18 @@ export default class PdfModalManager {

_saveHandler(box, evt) {
evt.stopPropagation();
let $form = $(this.modalLayout).find("form");
let form = this.modalLayout.querySelector("form");
console.log("saving", form)

Check failure on line 83 in app/packs/src/decidim/participatory_documents/pdf/pdf_modal_manager.js

View workflow job for this annotation

GitHub Actions / lint-report

Expected indentation of 4 spaces but found 0

$.ajax({
type: $form.attr("method"),
url: $form.attr("action"),
data: $form.serialize()
}).done(() => {
this.modalLayout.classList.remove("show");
this.createBox(box, this.pdfViewer.currentPageNumber);
}).
fail((data) => this.populateModal(data.responseText, box));
// $.ajax({
// type: $form.attr("method"),
// url: $form.attr("action"),
// data: $form.serialize()
// }).done(() => {
// this.modalLayout.classList.remove("show");
// this.createBox(box, this.pdfViewer.currentPageNumber);
// }).
// fail((data) => this.populateModal(data.responseText, box));
}

_removeHandler(box, evt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
<title>PDF.js viewer</title>

<link rel="stylesheet" href="/pdfjs/web/viewer.css">

<script src="/pdfjs/build/pdf.js"></script>

<script src="/pdfjs/web/viewer.js"></script>
<!-- This snippet is used in production (included from viewer.html) -->
<link rel="resource" type="application/l10n" href="/pdfjs/web/locale/locale.properties">
<script src="/pdfjs/web/viewer.js"></script>
<%= append_stylesheet_pack_tag "decidim_core", "decidim_admin", "decidim_admin_participatory_documents",
"decidim_participatory_documents_editor" %>
<%= append_javascript_pack_tag "decidim_core", "decidim_admin", "decidim_admin_participatory_documents",
"decidim_participatory_documents_editor" %>

<% append_stylesheet_pack_tag "decidim_core", "decidim_admin", media: :all %>
<%= stylesheet_pack_tag "decidim_participatory_documents_editor", media: "all" %>
<% append_javascript_pack_tag "decidim_core", "decidim_admin", defer: false %>
<%= javascript_pack_tag "decidim_participatory_documents_editor", defer: false %>
<%= organization_colors %>
<%= pdf_custom_style %>
<%= csrf_meta_tags %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ Adobe CMap resources are covered by their own copyright but the same license:
See https://github.com/adobe-type-tools/cmap-resources
-->
<%= stylesheet_pack_tag "decidim_participatory_documents_viewer", media: "all" %>
<%= javascript_pack_tag "decidim_participatory_documents_viewer", "decidim_core", defer: false %>
<%= pdf_custom_style %>
<div id="outerContainer">

<div id="sidebarContainer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<!-- This snippet is used in production (included from viewer.html) -->
<link rel="resource" type="application/l10n" href="/pdfjs/web/locale/locale.properties">
<script src="/pdfjs/web/viewer.js"></script>
<% packs = ["decidim_core"] %>
<% packs << "decidim_participatory_documents_viewer" if current_user %>
<%= append_stylesheet_pack_tag *packs, media: "all" %>
<% js_packs = ["decidim_participatory_documents"] %>
<% js_packs << "decidim_participatory_documents_viewer" if current_user %>
<% js_packs << "decidim_participatory_documents_viewer_off" unless current_user %>
<%= append_javascript_pack_tag *js_packs, defer: true %>

<%= stylesheet_pack_tag "decidim_participatory_documents_viewer", media: :all %>
<% append_javascript_pack_tag "decidim_core", defer: false %>
<%= javascript_pack_tag "decidim_participatory_documents_viewer", defer: false if current_user %>
<%= javascript_pack_tag "decidim_participatory_documents_viewer_off", defer: false unless current_user %>
<%= organization_colors %>
<%= pdf_custom_style %>
<%= csrf_meta_tags %>
Expand Down
26 changes: 26 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

load File.expand_path("bundle", __dir__)

require "rubygems"
require "bundler/setup"

if ARGV[0]
cleaned_file_path = ARGV[0].split("./").last
argument_parts = cleaned_file_path.split("/")

first_part = argument_parts[0]

if first_part =~ /decidim-/ && File.directory?(first_part)
Dir.chdir(first_part)

other_parts = argument_parts[1..-1]

new_args = [other_parts.empty? ? nil : other_parts.join("/"), *ARGV[1..-1]].compact

ARGV.replace(new_args)
end
end

load Gem.bin_path("rspec-core", "rspec")
2 changes: 1 addition & 1 deletion bin/webpack-dev-server → bin/shakapacker
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

Dir.chdir("development_app")

load "bin/webpack-dev-server"
load "bin/shakapacker"
6 changes: 6 additions & 0 deletions bin/shakapacker-dev-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

Dir.chdir("development_app")

load "bin/shakapacker-dev-server"

0 comments on commit ac16d79

Please sign in to comment.