1
0

app-test-verify-form.js 912 B

1234567891011121314151617181920212223242526272829303132
  1. class TestVerifyForm {
  2. constructor() {
  3. this.$invoiceAmountField = $("#invoice-amount");
  4. this.$newTestIsRetestField = $("#new-test-is-retest");
  5. this.$newTestIsRetestField.on("change", event => this.updateInvoiceAmount());
  6. this.$newTestProjectField = $("#new-test-project-id");
  7. this.$newTestProjectField.on("change", event => this.updateInvoiceAmount());
  8. this.$paymentRequiredField = $("#payment-required");
  9. this.$paymentRequiredField.on("change", event => {
  10. $("#invoice-amount").closest(".row").prop("hidden", !event.currentTarget.checked);
  11. });
  12. }
  13. updateInvoiceAmount() {
  14. const $option = this.$newTestProjectField.find("option:selected");
  15. let customerFee = $option.attr("data-customer-fee");
  16. if(this.$newTestIsRetestField.prop("checked")) {
  17. customerFee = $option.attr("data-retest-fee");
  18. }
  19. this.$invoiceAmountField.val(customerFee);
  20. }
  21. }
  22. $(() => new TestVerifyForm());