-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anonymous/walk-in registration #205
Changes from 18 commits
c3df883
d68a23f
1667838
f9b0461
ed73b2c
720cc2d
1fdbd60
5bdd02f
d134f70
b676ed5
92107a0
d13d6db
3963457
6462123
a0669b1
737bd47
224668c
04dc661
2ae1708
9fdce67
06699a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,5 +85,8 @@ <h1 class="center">RSVP: {{branch}}</h1> | |
</div> | ||
</form> | ||
{{/sidebar}} | ||
<script type="text/javascript"> | ||
formTypeString = "Confirmation"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Globals again |
||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,9 @@ class UserEntries { | |
userStatus = `Accepted (${user.application.type})`; | ||
} | ||
if (user.applied && user.accepted && user.attending) { | ||
userStatus = `Accepted (${user.application.type}) / Confirmed`; | ||
} | ||
if (user.applied && user.accepted && user.attending && user.confirmation) { | ||
userStatus = `Accepted (${user.application.type}) / Confirmed (${user.confirmation.type})`; | ||
} | ||
node.querySelector("td.status")!.textContent = userStatus; | ||
|
@@ -642,6 +645,61 @@ for (let i = 0; i < timeInputs.length; i++) { | |
timeInputs[i].value = moment(new Date(timeInputs[i].dataset.rawValue || "")).format("Y-MM-DDTHH:mm:00"); | ||
} | ||
|
||
// Uncheck available confirmation branches for application branch when "skip confirmation" option is selected | ||
function uncheckConfirmationBranches(applicationBranch: string) { | ||
let checkboxes = document.querySelectorAll(`.branch-role[data-name="${applicationBranch}"] .availableConfirmationBranches input[type="checkbox"]`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Types will work better here if it's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typescript won't allow me to cast |
||
for (let input of Array.from(checkboxes)) { | ||
(input as HTMLInputElement).checked = false; | ||
} | ||
} | ||
let skipConfirmationToggles = document.querySelectorAll(".branch-role input[type=\"checkbox\"].noConfirmation"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing with types There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing with how its not possible. |
||
for (let input of Array.from(skipConfirmationToggles)) { | ||
let checkbox = input as HTMLInputElement; | ||
checkbox.addEventListener("click", () => { | ||
if (checkbox.dataset.branchName !== undefined) { | ||
let branchName = checkbox.dataset.branchName as string; | ||
if (checkbox.checked) { | ||
uncheckConfirmationBranches(branchName); | ||
} else { | ||
(document.querySelector(`.branch-role[data-name="${branchName}"] input[type="checkbox"].allowAnonymous`) as HTMLInputElement).checked = false; | ||
} | ||
} | ||
}); | ||
} | ||
|
||
// Uncheck "skip confirmation" option when a confirmation branch is selected | ||
function setClickSkipConfirmation(applicationBranch: string, checked: boolean) { | ||
let checkbox = (document.querySelector(`.branch-role[data-name="${applicationBranch}"] input[type="checkbox"].noConfirmation`) as HTMLInputElement); | ||
if (checkbox.checked !== checked) { | ||
checkbox.click(); | ||
} | ||
} | ||
let availableConfirmationBranchCheckboxes = document.querySelectorAll(".branch-role fieldset.availableConfirmationBranches input[type=\"checkbox\"]"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better typing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing with how its not possible. |
||
for (let input of Array.from(availableConfirmationBranchCheckboxes)) { | ||
let checkbox = input as HTMLInputElement; | ||
checkbox.addEventListener("click", () => { | ||
if (checkbox.checked && checkbox.dataset.branchName !== undefined) { | ||
setClickSkipConfirmation((checkbox.dataset.branchName as string), false); | ||
} | ||
}); | ||
} | ||
|
||
// Select "skip confirmation" option when "allow anonymous" option is selected | ||
// Hide/show public link when "allow anonymous" is clicked | ||
let allowAnonymousCheckboxes = document.querySelectorAll(".branch-role input[type=\"checkbox\"].allowAnonymous"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better typing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing with how its not possible. |
||
for (let input of Array.from(allowAnonymousCheckboxes)) { | ||
let checkbox = input as HTMLInputElement; | ||
checkbox.onclick = () => { | ||
if (checkbox.dataset.branchName !== undefined) { | ||
let branchName = checkbox.dataset.branchName as string; | ||
if (checkbox.checked) { | ||
setClickSkipConfirmation(branchName, true); | ||
} | ||
(document.querySelector(`.branch-role[data-name="${branchName}"] .public-link`) as HTMLDivElement).hidden = !checkbox.checked; | ||
} | ||
}; | ||
} | ||
|
||
// Settings update | ||
function parseDateTime(dateTime: string) { | ||
let digits = dateTime.split(/\D+/).map(num => parseInt(num, 10)); | ||
|
@@ -680,11 +738,14 @@ function settingsUpdate(e: MouseEvent) { | |
let branchName = branchRoles[i].dataset.name!; | ||
let branchRole = branchRoles[i].querySelector("select")!.value; | ||
let branchData: { | ||
role: string; | ||
open?: Date; | ||
close?: Date; | ||
usesRollingDeadline?: boolean; | ||
confirmationBranches?: string[]; | ||
role: string; | ||
open?: Date; | ||
close?: Date; | ||
usesRollingDeadline?: boolean; | ||
confirmationBranches?: string[]; | ||
noConfirmation?: boolean; | ||
autoAccept?: boolean; | ||
allowAnonymous?: boolean; | ||
} = {role: branchRole}; | ||
// TODO this should probably be typed (not just strings) | ||
if (branchRole !== "Noop") { | ||
|
@@ -702,6 +763,17 @@ function settingsUpdate(e: MouseEvent) { | |
} | ||
} | ||
branchData.confirmationBranches = allowedConfirmationBranches; | ||
|
||
// This operation is all or nothing because it will only error if a branch was just made into an Application branch | ||
try { | ||
branchData.allowAnonymous = (branchRoles[i].querySelector("fieldset.applicationBranchOptions input[type=\"checkbox\"].allowAnonymous") as HTMLInputElement).checked; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make |
||
branchData.autoAccept = (branchRoles[i].querySelector("fieldset.applicationBranchOptions input[type=\"checkbox\"].autoAccept") as HTMLInputElement).checked; | ||
branchData.noConfirmation = (branchRoles[i].querySelector("fieldset.applicationBranchOptions input[type=\"checkbox\"].noConfirmation") as HTMLInputElement).checked; | ||
} catch { | ||
branchData.allowAnonymous = false; | ||
branchData.autoAccept = false; | ||
branchData.noConfirmation = false; | ||
} | ||
} | ||
if (branchRole === "Confirmation") { | ||
let usesRollingDeadlineCheckbox = (branchRoles[i].querySelectorAll("input.usesRollingDeadline") as NodeListOf<HTMLInputElement>); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,10 @@ enum FormType { | |
Application, | ||
Confirmation | ||
} | ||
let formType = window.location.pathname.match(/^\/apply/) ? FormType.Application : FormType.Confirmation; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whyyyyyyyyy globals. There has to be a better way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this crime. I literally removed this global. |
||
declare let formTypeString: keyof typeof FormType; | ||
let formType = FormType[formTypeString]; | ||
|
||
declare let unauthenticated: (boolean | undefined); | ||
|
||
let form = document.querySelector("form") as HTMLFormElement | null; | ||
let submitButton = document.querySelector("form input[type=submit]") as HTMLInputElement; | ||
|
@@ -19,11 +22,16 @@ submitButton.addEventListener("click", e => { | |
body: new FormData(form) | ||
}).then(checkStatus).then(parseJSON).then(async () => { | ||
let successMessage: string = formType === FormType.Application ? | ||
"Your application has been saved. Feel free to come back here and edit it at any time." : | ||
"Your application has been saved." + (!unauthenticated ? "Feel free to come back here and edit it at any time." : "") : | ||
"Your RSVP has been saved. Feel free to come back here and edit it at any time. We look forward to seeing you!"; | ||
|
||
await sweetAlert("Awesome!", successMessage, "success"); | ||
window.location.assign("/"); | ||
|
||
if (unauthenticated) { | ||
(document.querySelector("form") as HTMLFormElement).reset(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cast not needed here. Typescript can tell that searching for "form" will always return a form element There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue is that the type returned is |
||
} else { | ||
window.location.assign("/"); | ||
} | ||
}).catch(async (err: Error) => { | ||
await sweetAlert("Oh no!", err.message, "error"); | ||
submitButton.disabled = false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WTF is this a global variable?? Remove the type attribute from the
<script>
tag. If you need a global variable, dowindow.myVariable = x
instead so that it will work in strict mode.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding it to
window
won't work because typescript doesn't recognize additional properties onwindow