Skip to content

Commit

Permalink
Merge pull request #556 from zvonimirr/fix/coverage
Browse files Browse the repository at this point in the history
fix(test): fix coverage
  • Loading branch information
zvonimirr authored Apr 22, 2024
2 parents dec3d96 + 094f961 commit e86f494
Show file tree
Hide file tree
Showing 21 changed files with 630 additions and 254 deletions.
24 changes: 24 additions & 0 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { LiveSocket } from "phoenix_live_view";
import topbar from "../vendor/topbar";
// Include Tippy.js for tooltips
import tippy, { animateFill, roundArrow } from "tippy.js";
// Include jsPDF for PDF generation
import jsPDF from "jspdf";
// Import hooks
import { FormHook } from "./hooks/form";
import { ModalHook } from "./hooks/modal";
Expand Down Expand Up @@ -50,6 +52,9 @@ window.addEventListener("phx:page-loading-stop", () => {
});
});

// Custom PHX events
window.addEventListener("tenantee:print-pdf", printPdf);

// connect if there are any LiveViews on the page
liveSocket.connect();

Expand All @@ -58,3 +63,22 @@ liveSocket.connect();
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
// >> liveSocket.disableLatencySim()
window.liveSocket = liveSocket;

// Custom JS
// JavaScript function to generate and download PDF
function printPdf() {
if (confirm("Are you sure you want to download the PDF?")) {
const content = document.getElementById("pdf-content").outerHTML;
const pdf = new jsPDF({
orientation: "landscape",
unit: "in",
format: [4, 2],
});

pdf.html(content, {
callback: function (pdf) {
pdf.save("Lease Agreement.pdf");
},
});
}
}
200 changes: 200 additions & 0 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "Tenantee assets",
"dependencies": {
"jspdf": "^2.5.1",
"tippy.js": "^6.3.7"
}
}
2 changes: 1 addition & 1 deletion lib/tenantee_web/components/layouts/app.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Tenantee
</.link>
<p class="bg-green-500 text-white rounded-full px-2 font-medium leading-6">
v4.0.0
v4.0.1
</p>
</div>
<div class="flex items-center gap-4 font-semibold leading-6 text-zinc-900">
Expand Down
68 changes: 41 additions & 27 deletions lib/tenantee_web/components/property.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ defmodule TenanteeWeb.Components.Property do
<.icon name="hero-home" class="w-8 h-8" />
<%= @property.name %>
</h1>
<.button
class="bg-red-500 text-white hover:bg-red-600"
phx-click={open_confirm_modal(@property.id)}
>
<.icon name="hero-trash" class="w-4 h-4" /> Delete
</.button>
<abbr title="Delete Property">
<.button
class="bg-red-500 text-white hover:bg-red-600"
phx-click={open_confirm_modal(@property.id)}
>
<.icon name="hero-trash" class="w-4 h-4" />
</.button>
</abbr>
</div>
<hr class="border border-gray-200 w-full" />
<p class="text-gray-600">
Expand All @@ -47,33 +49,45 @@ defmodule TenanteeWeb.Components.Property do
<% end %>
</p>
<div class="flex gap-4">
<.button phx-click={open_manage_tenants_modal(@property.id)} disabled={@tenant_count == 0}>
<.icon name="hero-user" class="w-4 h-4" /> Manage tenants
</.button>
<%= if @property.has_agreement == false do %>
<.link navigate={"/properties/#{@property.id}/agreement"}>
<.button>
<.icon name="hero-clipboard" class="w-4 h-4" /> Generate Agreement
</.button>
</.link>
<abbr title="Manage Tenants">
<.button phx-click={open_manage_tenants_modal(@property.id)} disabled={@tenant_count == 0}>
<.icon name="hero-user" class="w-4 h-4" />
</.button>
</abbr>
<%= if @property.has_agreement do %>
<abbr title="View Agreement">
<.link navigate={"/properties/#{@property.id}/view_agreement"}>
<.button>
<.icon name="hero-clipboard" class="w-4 h-4" />
</.button>
</.link>
</abbr>
<% else %>
<.link navigate={"/properties/#{@property.id}/view_agreement"}>
<.button>
<.icon name="hero-clipboard" class="w-4 h-4" /> View/Edit Agreement
</.button>
</.link>
<abbr title="Generate Agreement">
<.link navigate={"/properties/#{@property.id}/agreement"}>
<.button>
<.icon name="hero-clipboard" class="w-4 h-4" />
</.button>
</.link>
</abbr>
<% end %>
<.link navigate={"/properties/#{@property.id}/expenses"}>
<.button>
<.icon name="hero-banknotes" class="w-4 h-4" /> Manage Expenses
</.button>
<abbr title="Manage Expenses">
<.button>
<.icon name="hero-banknotes" class="w-4 h-4" />
</.button>
</abbr>
</.link>
<.link navigate={"/properties/#{@property.id}"}>
<.button style="width: 70px; height: 75px; display: flex; flex-direction: column; align-items: center;">
<.icon name="hero-pencil" class="w-4 h-4" /> Edit Property
</.button>
<abbr title="Edit Property">
<.button>
<.icon name="hero-pencil" class="w-4 h-4" />
</.button>
</abbr>
</.link>
</div>
<div class="flex gap-4"></div>
</div>
"""
end
Expand All @@ -87,4 +101,4 @@ defmodule TenanteeWeb.Components.Property do
Cldr.format_price(taxed_price)
end
end
end
end
Loading

0 comments on commit e86f494

Please sign in to comment.