sale-page.js 892 B

1234567891011121314151617181920212223242526272829
  1. class SalePage {
  2. static InitSaleItemSection() {
  3. const $table = $("#sale-items-section table");
  4. const $checkboxes = $table.find("input[type=checkbox]");
  5. const $allCheckbox = $("#sale-items-all-checkbox");
  6. $allCheckbox.on("change", () => {
  7. const checked = $allCheckbox.prop("checked");
  8. $checkboxes.prop("checked", checked);
  9. });
  10. $table.find(".btn-delete-sale-item").on("click", event => {
  11. const saleItemId = $(event.currentTarget).data("sale-item-id");
  12. const confirmed = confirm("Are you sure you want to delete this sale item?");
  13. if(confirmed) {
  14. $.post(window.location + "/delete-item", {
  15. sale_item_id: saleItemId
  16. }).then(response => {
  17. toastr.success("Sale item deleted successfully.");
  18. $("#sale-items-section").html(response.html);
  19. SalePage.InitSaleItemSection();
  20. });
  21. }
  22. });
  23. }
  24. }
  25. $(() => {
  26. SalePage.InitSaleItemSection();
  27. });