This repository has been archived by the owner on Aug 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add minimal volunteer tracking (resolves #29)
- Loading branch information
1 parent
d7eca06
commit b4f0b1b
Showing
10 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const debouncedUpdaters = {}; | ||
|
||
function increaseVolunteersControl(formIdentifier, updateUrl) { | ||
volunteersControl(formIdentifier, updateUrl, function(value) { | ||
return value + 1; | ||
}); | ||
} | ||
|
||
function decreaseVolunteersControl(formIdentifier, updateUrl) { | ||
volunteersControl(formIdentifier, updateUrl, function(value) { | ||
return value - 1; | ||
}); | ||
} | ||
|
||
function volunteersControl(formIdentifier, updateUrl, updateCallback) { | ||
const valueElement = elementFor(formIdentifier, 'value'); | ||
const newValue = updateCallback(+valueElement.innerHTML); | ||
|
||
if (newValue >= 0) { | ||
valueElement.innerHTML = newValue; | ||
|
||
let updateServer = debouncedUpdaters[formIdentifier]; | ||
if (!updateServer) { | ||
updateServer = _.debounce(function() { | ||
const savingElement = elementFor(formIdentifier, 'saving'); | ||
savingElement.classList.remove('is-invisible'); | ||
|
||
const data = {count: valueElement.innerHTML}; | ||
function onSuccess() { | ||
savingElement.classList.add('is-invisible') | ||
} | ||
|
||
// XXX Add better error handling | ||
$.post(updateUrl, data, onSuccess); | ||
}, 500); | ||
|
||
debouncedUpdaters[formIdentifier] = updateServer; | ||
} | ||
|
||
updateServer(); | ||
} | ||
} | ||
|
||
function elementFor(formIdentifier, type) { | ||
const controlValueId = `${formIdentifier}-${type}`; | ||
return document.getElementById(controlValueId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
# Null object for CommitteeRoomObservations. | ||
class UnobservedCommitteeRoomObservation | ||
def count | ||
0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters