Skip to content

Commit

Permalink
Update BulkDataEntryCard.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
datajohnson committed May 18, 2023
1 parent 46737f8 commit 225c0af
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/web/src/modules/centre/components/BulkDataEntryCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,30 @@ export default {
return "";
},
categorizedLocations() {
return this.selectedDate.origins.filter((location) => location.name !== UNKNOWN_CATEGORY_LOCATION_NAME);
return this.selectedDate.origins.filter((location: any) => location.name !== UNKNOWN_CATEGORY_LOCATION_NAME);
},
uncategorizedLocation() {
return this.selectedDate.origins.find((location) => location.name === UNKNOWN_CATEGORY_LOCATION_NAME);
return this.selectedDate.origins.find((location: any) => location.name === UNKNOWN_CATEGORY_LOCATION_NAME);
},
uncategorizedVisitors() {
return this.uncategorizedLocation.daily_total + this.uncategorizedLocation.delta;
},
categorizedVistors() {
return this.categorizedLocations.reduce((total, location) => total + location.daily_total + location.delta, 0);
return this.categorizedLocations.reduce(
(total: number, location: any) => total + location.daily_total + location.delta,
0
);
},
},
methods: {
...mapActions(useCentreStore, ["save", "loadDailyStats", "selectFirstToManage"]),
selectTodaysDate() {
this.selectedDate = this.selectedSite.days[0];
if (this.selectedSite && this.selectedSite.days) this.selectedDate = this.selectedSite.days[0];
},
categorizedVistorsExceptThoseIn(excludedLocation) {
categorizedVistorsExceptThoseIn(excludedLocation: any) {
return this.categorizedVistors - excludedLocation.daily_total - excludedLocation.delta;
},
parseAndNaturalizeNumber(value) {
parseAndNaturalizeNumber(value: any) {
return Math.max(0, parseInt(value) || 0);
},
saveAndExit() {
Expand All @@ -165,7 +168,7 @@ export default {
this.uncategorizedLocation.delta =
this.totalVistorsForDay - this.categorizedVistors - this.uncategorizedLocation.daily_total;
},
updateLocationCategoryTotal(location, value) {
updateLocationCategoryTotal(location: any, value: any) {
const normalizedValue = this.parseAndNaturalizeNumber(value);
const maxAvailableVisitors = this.totalVistorsForDay - this.categorizedVistorsExceptThoseIn(location);
Expand All @@ -174,10 +177,10 @@ export default {
location.delta = maxLimitedValule - location.daily_total;
this.updateUncategorizedVisitors();
},
updateTotalVistors(value) {
updateTotalVistors(value: any) {
const normalizedValue = this.parseAndNaturalizeNumber(value);
if (normalizedValue < this.totalVistorsForDay) {
this.categorizedLocations.forEach((location) => {
this.categorizedLocations.forEach((location: any) => {
location.delta = -location.daily_total;
});
}
Expand Down

0 comments on commit 225c0af

Please sign in to comment.