document-page.js 908 B

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