|
@@ -1,4 +1,11 @@
|
|
|
class DocumentPage {
|
|
class DocumentPage {
|
|
|
|
|
+ static InitForm() {
|
|
|
|
|
+ const $form = $("#document-form");
|
|
|
|
|
+ $form.on("submit", event => {
|
|
|
|
|
+ event.preventDefault();
|
|
|
|
|
+ DocumentPage.SaveForm();
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
static InitItemsSection() {
|
|
static InitItemsSection() {
|
|
|
const $table = $("#document-items-section table");
|
|
const $table = $("#document-items-section table");
|
|
|
const $checkboxes = $table.find("input[type=checkbox]");
|
|
const $checkboxes = $table.find("input[type=checkbox]");
|
|
@@ -31,25 +38,34 @@ class DocumentPage {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static InitPdfActions() {
|
|
static InitPdfActions() {
|
|
|
- const $form = $("#document-form");
|
|
|
|
|
- const action = $form.get(0).action;
|
|
|
|
|
-
|
|
|
|
|
const $elements = $(".pdf-action");
|
|
const $elements = $(".pdf-action");
|
|
|
$elements.on("click", event => {
|
|
$elements.on("click", event => {
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
-
|
|
|
|
|
const $element = $(event.currentTarget);
|
|
const $element = $(event.currentTarget);
|
|
|
- const data = $form.serialize();
|
|
|
|
|
|
|
|
|
|
- $.post(action, data).then(() => {
|
|
|
|
|
- toastr.success("Invoice saved successfully.");
|
|
|
|
|
|
|
+ DocumentPage.SaveForm().then(() => {
|
|
|
window.open($element.attr("href"));
|
|
window.open($element.attr("href"));
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ static SaveForm() {
|
|
|
|
|
+ const $form = $("#document-form");
|
|
|
|
|
+ const action = $form.get(0).action;
|
|
|
|
|
+ const data = $form.serialize();
|
|
|
|
|
+ const $submitElements = $form.find("[type=submit]");
|
|
|
|
|
+ $submitElements.prop("disabled", true);
|
|
|
|
|
+
|
|
|
|
|
+ return $.post(action, data).always(() => {
|
|
|
|
|
+ $submitElements.prop("disabled", false);
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ toastr.success("Invoice saved successfully.");
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$(() => {
|
|
$(() => {
|
|
|
|
|
+ DocumentPage.InitForm();
|
|
|
DocumentPage.InitItemsSection();
|
|
DocumentPage.InitItemsSection();
|
|
|
DocumentPage.InitPdfActions();
|
|
DocumentPage.InitPdfActions();
|
|
|
});
|
|
});
|