Skip to content

Commit

Permalink
Merge pull request #286 from ncosd/dev-1.13.0
Browse files Browse the repository at this point in the history
Release 1.13.0
  • Loading branch information
dherbst authored Jan 20, 2024
2 parents d7b4c51 + 450a558 commit bf4307f
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"files.trimTrailingWhitespace": true,
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.wordWrap": "on"
"editor.wordWrap": "on",
"prettier.semi": false,
"singleQuote": true
}
7 changes: 6 additions & 1 deletion web/admin/src/components/VolunteerList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,23 @@ const updateInactive = async id => {
<SortableTableHeader heading="First Name" sortKey="firstname" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sort" />
<SortableTableHeader heading="Last Name" sortKey="lastname" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sort" />
<SortableTableHeader heading="Email" sortKey="email" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sort" />
<th scope="col">Driver</th>
<th scope="col">Status</th>
<th scope="col">Action</th>
<SortableTableHeader heading="Updated" sortKey="updated" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sort" />
</tr>
</thead>
<tbody>
<tr v-for="v in volunteers">
<tr v-for="v in volunteers" :key="v.email">
<td>{{ v.firstname }}</td>
<td>{{ v.lastname }}</td>
<td>
<router-link :to="{ name: 'Profile', params: { uid: v.userid } }">{{ v.email }}</router-link>
</td>
<td>
<i v-if="v.isDriver" class="bi bi-car-front" title="Driver"></i>
<i v-if="v.isApprovedDriver" class="ms-2 bi bi-check-circle text-success" title="Approved Driver"></i>
</td>
<td>{{ v.status }}</td>
<td>
<button class="btn btn-sm btn-primary me-1" @click="updateApprove(v.userid)">Approve</button>
Expand Down
2 changes: 1 addition & 1 deletion web/admin/src/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export let config = {
version: "1.12.0",
version: "1.13.0",
adminAppNavName: import.meta.env.VITE_ADMIN_APP_NAV_NAME || 'ADMIN_APP_NAV_NAME',
adminAppNavImg: import.meta.env.VITE_ADMIN_APP_NAV_IMG || null,
appNavName: import.meta.env.VITE_APP_NAV_NAME || 'APP_NAV_NAME',
Expand Down
29 changes: 21 additions & 8 deletions web/admin/src/views/LocationsListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,33 @@
import { ref, onBeforeMount } from 'vue'
import { useAuthUserStore } from '@/stores/authUser'
import { collection, getFirestore, query, where, doc, getDocs, addDoc, updateDoc, orderBy } from 'firebase/firestore'
import SortableTableHeader from '@/components/SortableTableHeader.vue'
const user = useAuthUserStore()
const locations = ref()
const sortBy = ref("name")
const sortAsc = ref(true)
onBeforeMount( async () => {
const refreshList = async () => {
const db = getFirestore()
const q = query(collection(db, "location"), orderBy('name'))
const q = query(collection(db, "location"), orderBy(sortBy.value, sortAsc.value ? "asc" : "desc"))
const locRef = await getDocs(q)
const locarray = []
locRef.forEach((loc)=> {
locarray.push({id:loc.id,...loc.data()})
})
locations.value = locarray
}
const sortList = param => {
sortAsc.value = sortBy.value === param ? !sortAsc.value : true
sortBy.value = param
refreshList()
}
onBeforeMount( async () => {
await refreshList()
})
const mapsquery = (loc)=>{
Expand All @@ -32,12 +45,12 @@ const mapsquery = (loc)=>{
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Display Name</th>
<th scope="col">Street Address</th>
<th scope="col">City</th>
<th scope="col">State</th>
<th scope="col">zip</th>
<SortableTableHeader heading="Name" sortKey="name" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sortList" />
<SortableTableHeader heading="Display Name" sortKey="displayname" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sortList" />
<SortableTableHeader heading="Street Address" sortKey="street" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sortList" />
<SortableTableHeader heading="City" sortKey="city" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sortList" />
<SortableTableHeader heading="State" sortKey="state" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sortList" />
<SortableTableHeader heading="Zip" sortKey="zip" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sortList" />
<th scope="col">Map</th>
<th scope="col">Action</th>
</tr>
Expand Down
6 changes: 5 additions & 1 deletion web/admin/src/views/ProfileAdminFormsPage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import { ref, onBeforeMount } from 'vue'
import { getFirestore, doc, getDoc, setDoc, addDoc, collection } from 'firebase/firestore'
import { getFirestore, doc, getDoc, setDoc, addDoc, updateDoc, collection } from 'firebase/firestore'
import { useAuthUserStore } from '@/stores/authUser'
import { useRouter } from 'vue-router'
import dayjs from 'dayjs'
Expand Down Expand Up @@ -88,6 +88,10 @@ const saveForm = async(formData)=>{
'approverName': adminUser.data.displayName,
})
// Update the VolunteerProfileState with the isDriverApproved value.
const vps = doc(db, 'volunteerprofilestate', props.volunteerId)
await updateDoc(vps, { isApprovedDriver: completed.value })
showSuccess.value = true
} catch (err) {
console.log('err', err)
Expand Down
5 changes: 5 additions & 0 deletions web/admin/src/views/ReleaseNotesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<template>
<div class="container">
<h1>Release Notes</h1>
<h2 id="1.13.0">January , 2024 - 1.13.0</h2>
<ul>
<li><a href="https://github.com/ncosd/food-pantry-app/issues/275">#275</a> Add sorting the column headers on Locations page.</li>
<li><a href="https://github.com/ncosd/food-pantry-app/issues/281">#281</a> Display and filter if a volunteer wants to be a driver and if they are approved.</li>
</ul>
<h2 id="1.12.0">January 17, 2024 - 1.12.0</h2>
<ul>
<li><a href="https://github.com/ncosd/food-pantry-app/issues/277">#277</a> Volunteer can indicate if they want to be a driver, Admins can see what to do to approve a driver and save the approved status.</li>
Expand Down
39 changes: 32 additions & 7 deletions web/admin/src/views/VolunteersPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@ import { reactive, computed, ref, onBeforeMount } from "vue"
import VolunteerList from "@/components/VolunteerList.vue"
import { collection, getFirestore, query, where, getDocs, orderBy } from "firebase/firestore"
var volunteers = ref()
const volunteers = ref()
const statusFilter = ref("in-review")
const sortBy = ref("firstname")
const sortAsc = ref(true)
const driverFilter = ref(false)
const approvedDriverFilter = ref(false)
const refreshList = async () => {
const db = getFirestore()
const q = query(collection(db, "volunteerprofilestate"), where("status", "==", statusFilter.value), orderBy(sortBy.value, sortAsc.value ? "asc" : "desc"))
const volunteerCollection = collection(db, "volunteerprofilestate")
let q = query(volunteerCollection, where("status", "==", statusFilter.value), orderBy(sortBy.value, sortAsc.value ? "asc" : "desc"))
if (driverFilter.value) {
q = query(q, where('isDriver', '==', true))
}
if (approvedDriverFilter.value) {
q = query(q, where('isApprovedDriver', '==', true))
}
const pstates = await getDocs(q)
volunteers.value = []
pstates.forEach(prof => {
Expand All @@ -31,9 +42,23 @@ onBeforeMount(async () => {
</script>

<template>
<div class="container">
<div class="row ms-1">
<b>Filter</b>
<div class="container">

<h1>Volunteers</h1>
<div class="p-2 m-3">
<div><b>Filter</b></div>
<div class="row ms-1" >
<div class="col">
<input id="driverFilter" class="form-check-input me-2" type="checkbox" v-model="driverFilter" @change="refreshList">
<label class="form-check-label" for="driverFilter"><i class="bi bi-car-front" title="Driver"></i> Driver</label>

<input id="approvedDriverFilter" class="form-check-input ms-3 me-2" type="checkbox" v-model="approvedDriverFilter" @change="refreshList">
<label class="form-check-label" for="approvedDriverFilter"><i class="bi bi-check-circle text-success"></i> Approved Driver</label>

</div>
</div>

<div class="row mb-3 ms-1">
<div class="col">
<label class="col-form-label" for="statusFilter">Status</label>
<select class="form-select" id="statusFilter" v-model="statusFilter" @change="refreshList">
Expand All @@ -43,7 +68,7 @@ onBeforeMount(async () => {
</select>
</div>
</div>

<volunteer-list :volunteers="volunteers" :sortBy="sortBy" :sortAsc="sortAsc" @refresh-list="refreshList" @sort-list="sortList"></volunteer-list>
</div>
<volunteer-list :volunteers="volunteers" :sortBy="sortBy" :sortAsc="sortAsc" @refresh-list="refreshList" @sort-list="sortList"></volunteer-list>
</div>
</template>
2 changes: 1 addition & 1 deletion web/app/src/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export let config = {
version: "1.12.0",
version: "1.13.0",
appNavName: import.meta.env.VITE_APP_NAV_NAME || 'APP_NAV_NAME',
OrganizationName: import.meta.env.VITE_ORGANIZATION_NAME || 'ORGANIZATION_NAME',
ProjectLongName: import.meta.env.VITE_PROJECT_LONG_NAME || 'PROJECT_LONG_NAME',
Expand Down
4 changes: 4 additions & 0 deletions web/app/src/views/ReleaseNotesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<template>
<div class="container">
<h1>Release Notes</h1>
<h2 id="1.13.0">January , 2024 - 1.13.0</h2>
<ul>
<li></li>
</ul>
<h2 id="1.12.0">January 17, 2024 - 1.12.0</h2>
<ul>
<li>No issues in the Guest app.</li>
Expand Down
58 changes: 58 additions & 0 deletions web/firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
{
"indexes": [
{
"collectionGroup": "volunteerprofilestate",
"queryScope": "COLLECTION",
"fields": [
{
"fieldPath": "isApprovedDriver",
"order": "ASCENDING"
},
{
"fieldPath": "isDriver",
"order": "ASCENDING"
},
{
"fieldPath": "status",
"order": "ASCENDING"
},
{
"fieldPath": "firstname",
"order": "ASCENDING"
}
]
},
{
"collectionGroup": "volunteerprofilestate",
"queryScope": "COLLECTION",
"fields": [
{
"fieldPath": "isApprovedDriver",
"order": "ASCENDING"
},
{
"fieldPath": "status",
"order": "ASCENDING"
},
{
"fieldPath": "firstname",
"order": "ASCENDING"
}
]
},
{
"collectionGroup": "volunteerprofilestate",
"queryScope": "COLLECTION",
"fields": [
{
"fieldPath": "isDriver",
"order": "ASCENDING"
},
{
"fieldPath": "status",
"order": "ASCENDING"
},
{
"fieldPath": "firstname",
"order": "ASCENDING"
}
]
},
{
"collectionGroup": "volunteerprofilestate",
"queryScope": "COLLECTION",
Expand Down
46 changes: 45 additions & 1 deletion web/functions/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const functions = require("firebase-functions");
const { onCall } = require('firebase-functions/v2/https');
const { onDocumentCreated, onDocumentDeleted, onDocumentWritten } = require('firebase-functions/v2/firestore');
const { onDocumentCreated, onDocumentDeleted, onDocumentWritten, onDocumentUpdated } = require('firebase-functions/v2/firestore');
const admin = require('firebase-admin');
const { FieldValue } = require('firebase-admin/firestore');
const fs = require('firebase-admin/firestore');
Expand Down Expand Up @@ -171,6 +171,8 @@ exports.addVolunteerProfileOnCreatev2 = onDocumentCreated('volunteerprofile/{use
firstname: profile.firstname,
lastname: profile.lastname,
email: profile.email,
isDriver: profile.isDriver,
isApprovedDriver: false,
status: "in-review",
created: fs.Timestamp.now(),
updated: fs.Timestamp.now()
Expand All @@ -190,6 +192,48 @@ exports.addVolunteerProfileOnCreatev2 = onDocumentCreated('volunteerprofile/{use
}
});

// When a Volunteer changes their VolunteerProfile, update the VolunteerProfileState
exports.updateVolunteerProfile = onDocumentUpdated('volunteerprofile/{userId}', async (event) => {

const profileSnap = event.data;
if (!profileSnap) {
console.log('No data.');
return;
}
const profile = event.data.after.data();

const vpsRef = db.collection('volunteerprofilestate').doc(event.params.userId)
const vpsSnap = await vpsRef.get()
let vpsData = vpsSnap.data()
let saveIt = false
if ((!Object.hasOwn(profile, 'isDriver')) || profile.isDriver !== vpsData.isDriver) {
if (!Object.hasOwn(profile, 'isDriver')) {
vpsData.isDriver = false
} else {
vpsData.isDriver = profile.isDriver
}
saveIt = true
}

if (profile.firstname !== vpsData.firstname) {
vpsData.firstname = profile.firstname
saveIt = true
}
if (profile.lastname !== vpsData.lastname) {
vpsData.lastname = profile.lastname
saveIt = true
}

if (saveIt) {
await vpsRef.update(vpsData)
console.log('saved ', vpsData)
}

});




// When an attending is created, update the window.numAttending
exports.attendingCreated = onDocumentCreated('window/{winId}/attending/{userId}', async (event) => {

Expand Down

0 comments on commit bf4307f

Please sign in to comment.