forked from rubyforgood/casa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcase_contact.js
More file actions
51 lines (38 loc) · 1.31 KB
/
case_contact.js
File metadata and controls
51 lines (38 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import Swal from "sweetalert2";
function convertDateToSystemTimeZone(date) {
return new Date(typeof date === "string" ? new Date(date) : date);
}
async function displayFollowupAlert() {
const { value: text, isConfirmed } = await fireSwalFollowupAlert();
if (!isConfirmed) return;
const params = text ? { note: text } : {};
const caseContactId = this.id.replace("followup-button-", "");
$.post(`/case_contacts/${caseContactId}/followups`, params, () => window.location.reload());
}
async function fireSwalFollowupAlert() {
const inputLabel = "Optional: Add a note about what followup is needed.";
return await Swal.fire({
input: "textarea",
title: inputLabel,
inputPlaceholder: "Type your note here...",
inputAttributes: { "aria-label": "Type your note here" },
showCancelButton: true,
showCloseButton: true,
confirmButtonText: "Confirm",
confirmButtonColor: "#dc3545",
customClass: {
inputLabel: "mx-5",
},
});
}
$(document).on("turbo:load", function () {
$(".filter-form").on("change", ".filter-input", function () {
$(this).closest("form").submit();
});
});
$(() => {
// JQuery's callback for the DOM loading
$('[data-toggle="tooltip"]').tooltip();
$(".followup-button").on("click", displayFollowupAlert);
});
export { convertDateToSystemTimeZone };