Skip to content

Commit

Permalink
Merge branch '_staging' into 1676-cache-prior-periods
Browse files Browse the repository at this point in the history
  • Loading branch information
as1729 authored Nov 21, 2023
2 parents 0660125 + 09d9fb1 commit 8c90453
Show file tree
Hide file tree
Showing 38 changed files with 2,327 additions and 1,254 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Follow these steps to start contributing:

```bash
$ git fetch origin
$ git rebase origin/master
$ git rebase origin/_staging
```

Push the changes to your account using:
Expand Down
4 changes: 4 additions & 0 deletions packages/client/.nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"include": "src/**",
"extension": [".js", ".vue"]
}
5 changes: 5 additions & 0 deletions packages/client/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
],
env: {
test: {
plugins: [['babel-plugin-istanbul']],
},
},
};
2 changes: 2 additions & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"jquery": "3.6.0",
"lodash": "^4.17.21",
"lodash-checkit": "^2.3.3",
"luxon": "^3.4.3",
"moment": "^2.29.2",
"numeral": "^2.0.6",
"popper.js": "1.16.1",
Expand Down Expand Up @@ -52,6 +53,7 @@
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/test-utils": "^1.0.3",
"babel-eslint": "^10.1.0",
"babel-plugin-istanbul": "^6.1.1",
"chai": "^4.3.4",
"eslint": "^7.12.1",
"eslint-config-standard": "^16.0.3",
Expand Down
18 changes: 6 additions & 12 deletions packages/client/src/arpa_reporter/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
<div class="row">
<AlertBox v-if="alert" :text="alert.text" :level="alert.level" v-on:dismiss="clearAlert" />
</div>
<div class="row" v-if="isAdmin">
<AlertBox text="Service Interruption - Please reach out to [email protected] for treasury report generation." level="err" />
</div>
<div class="row mt-5 mb-5" v-if="viewingOpenPeriod">
<div class="col" v-if="this.$route.query.sync_treasury_download && isAdmin">
<DownloadButton :href="downloadTreasuryReportURL()" class="btn btn-primary btn-block">Download Treasury Report</DownloadButton>
</div>

<div class="col" v-if="isAdmin">
<button disabled title="Please reach out to [email protected] for the treasury report." class="btn btn-primary btn-block" @click="sendTreasuryReport">
<button class="btn btn-primary btn-block" @click="sendTreasuryReport" :disabled="sending" id="sendTreasuryReportButton">
<span v-if="sending">Sending...</span>
<span v-else>Send Treasury Report by Email</span>
</button>
Expand All @@ -23,14 +20,14 @@
</div>

<div class="col" v-if="isAdmin">
<button class="btn btn-info btn-block" @click="sendAuditReport" :disabled="sending">
<button class="btn btn-info btn-block" @click="sendAuditReport" :disabled="sending" id="sendAuditReportButton">
<span v-if="sending">Sending...</span>
<span v-else>Send Audit Report by Email</span>
</button>
</div>

<div class="col">
<button @click.prevent="startUpload" class="btn btn-primary btn-block">Submit Workbook</button>
<button @click.prevent="startUpload" class="btn btn-primary btn-block" id="submitWorkbookButton">Submit Workbook</button>
</div>

<div class="col">
Expand All @@ -39,12 +36,12 @@
</div>

<div class="row border border-danger rounded m-3 mb-3 p-3" v-else>
<div class="col">
<div class="col" id="closedReportingPeriodMessage">
This reporting period is closed.
</div>
</div>

<p>
<p id="welcomeToArpaReporter">
Welcome to the ARPA reporter.
To get started, click the "Download Empty Template" button, above, to get a copy of an empty template for reporting.
</p>
Expand Down Expand Up @@ -81,9 +78,6 @@ export default {
viewingOpenPeriod() {
return this.$store.getters.viewPeriodIsCurrent;
},
isClosed() {
return !(this.$store.getters.viewPeriodIsCurrent);
},
},
data() {
let alert;
Expand Down Expand Up @@ -143,7 +137,7 @@ export default {
this.sending = true;
try {
const result = await getJson('/api/exports?async=true');
const result = await getJson('/api/exports?queue=true');
if (result.error) {
this.alert = {
Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/components/GrantsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ export default {
},
{
key: 'viewed_by',
sortable: true,
},
{
key: 'interested_agencies',
sortable: true,
},
{
// opportunity_status
Expand Down
7 changes: 1 addition & 6 deletions packages/client/src/components/GrantsTableNext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</b-row>
<b-row align-v="center">
<b-col cols="12">
<b-table fixed id="grants-table" sticky-header="32rem" hover :items="formattedGrants" responsive
<b-table id="grants-table" sticky-header="70vh" hover :items="formattedGrants"
:fields="fields.filter(field => !field.hideGrantItem)" selectable striped :sort-by.sync="orderBy"
:sort-desc.sync="orderDesc" :no-local-sorting="true" :bordered="true" select-mode="single" :busy="loading"
@row-selected="onRowSelected" show-empty emptyText="No matches found">
Expand Down Expand Up @@ -110,11 +110,9 @@ export default {
},
{
key: 'viewed_by',
sortable: true,
},
{
key: 'interested_agencies',
sortable: true,
},
{
// opportunity_status
Expand All @@ -128,9 +126,6 @@ export default {
{
key: 'cost_sharing',
},
{
key: 'award_floor',
},
{
key: 'award_ceiling',
sortable: true,
Expand Down
19 changes: 13 additions & 6 deletions packages/client/src/components/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<template>
<div>
<b-navbar type="dark" variant="dark">
<b-navbar :type="navBarType" :variant="navBarVariant">
<b-navbar-brand href="/#/grants" class="d-flex align-items-center">
<b-img :src="require('../assets/usdr_logo_white_wide.svg')" style="height: 1.625rem;" class="" alt="United States Digital Response logo in white" />
<b-img v-if="myProfileEnabled" :src="require('../assets/usdr_logo_standard_wide.svg')" style="height: 1.625rem;" class="" alt="United States Digital Response logo" />
<b-img v-else :src="require('../assets/usdr_logo_white_wide.svg')" style="height: 1.625rem;" class="" alt="United States Digital Response logo in white" />
<h3 class="ml-3 mb-0">Grants Identification Tool</h3>
</b-navbar-brand>
<!-- <b-navbar-brand href="/#/grants">
Grants Identification Tool</b-navbar-brand> -->

<b-collapse id="nav-collapse" is-nav>

<!-- Right aligned nav items -->
Expand Down Expand Up @@ -57,7 +55,7 @@

<script>
import { mapGetters } from 'vuex';
import { useNewGrantsTable } from '@/helpers/featureFlags';
import { myProfileEnabled, useNewGrantsTable } from '@/helpers/featureFlags';
import ProfileSettingsModal from '@/components/Modals/ProfileSettings.vue';
import AlertBox from '../arpa_reporter/components/AlertBox.vue';
Expand All @@ -84,12 +82,21 @@ export default {
canSeeTenantsTab() {
return this.loggedInUser && this.loggedInUser.isUSDRSuperAdmin;
},
myProfileEnabled() {
return myProfileEnabled();
},
useNewGrantsTable() {
return useNewGrantsTable();
},
showTabs() {
return !(this.$route.meta.hideLayoutTabs === true);
},
navBarType() {
return myProfileEnabled() ? 'light' : 'dark';
},
navBarVariant() {
return myProfileEnabled() ? 'white' : 'dark';
},
},
methods: {
logout(e) {
Expand Down
106 changes: 106 additions & 0 deletions packages/client/src/components/Modals/EditUser.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<template>
<b-modal
id="edit-user-modal"
title="Edit your profile"
header-class="heading"
footer-class="footer"
ok-title="Save"
@show="resetModal"
@hidden="resetModal"
@ok="handleOk"
:ok-disabled="$v.formData.$invalid"
>
<b-form>
<b-form-group
:state="!$v.formData.name.$invalid"
label="Name"
label-for="name-input"
invalid-feedback="Please enter your preferred first and last name"
>
<b-form-input
type="text"
id="name-input"
v-model="formData.name"
@keydown.enter.native="handleSubmit"
required
trim
autofocus
></b-form-input>
</b-form-group>
</b-form>
</b-modal>
</template>

<script>
import { mapGetters, mapActions } from 'vuex';
import { required, minLength } from 'vuelidate/lib/validators';
export default {
data() {
return {
formData: {
name: null,
},
};
},
validations: {
formData: {
name: {
required,
minLength: minLength(4),
},
},
},
computed: {
...mapGetters({
loggedInUser: 'users/loggedInUser',
}),
},
methods: {
...mapActions({
updateUser: 'users/updateUser',
}),
resetModal() {
this.formData.name = this.loggedInUser.name;
},
handleOk(bvModalEvt) {
// Prevent modal from closing
bvModalEvt.preventDefault();
this.handleSubmit();
},
async handleSubmit() {
this.formData.id = this.loggedInUser.id;
// Exit when the form isn't valid
if (this.$v.formData.$invalid) {
return;
}
try {
await this.updateUser(this.formData);
} catch (error) {
this.$store.commit('alerts/addAlert', {
text: `Error updating user: ${error.message}`,
level: 'err',
});
}
// // Hide the modal manually
this.$nextTick(() => {
this.$bvModal.hide('edit-user-modal');
});
},
},
};
</script>

<style>
.heading > h5 {
font-family: Inter, Helvetica, Arial, sans-serif;
font-size: 20px;
font-weight: 700;
}
.footer {
border: none;
}
</style>
8 changes: 3 additions & 5 deletions packages/client/src/components/Modals/SearchPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ import { mapActions, mapGetters } from 'vuex';
import { VBToggle } from 'bootstrap-vue';
import Multiselect from 'vue-multiselect';
import { billOptions } from '@/helpers/constants';
import { DateTime } from 'luxon';
const defaultCriteria = {
includeKeywords: null,
Expand Down Expand Up @@ -371,17 +372,14 @@ export default {
this.formData.criteria = { ...criteria };
} else {
this.formData.searchId = null;
this.formData.searchTitle = `My Saved Search ${this.getNextSearchId()}`;
const now = DateTime.now();
this.formData.searchTitle = `${now.toLocaleString(DateTime.DATE_SHORT)} - ${now.toLocaleString(DateTime.TIME_WITH_SECONDS)}`;
this.formData.criteria = { ...defaultCriteria };
}
},
onShown() {
this.initFormState();
},
getNextSearchId() {
const searchIds = this.savedSearches.data.map((s) => s.id);
return Math.max(...searchIds, 0) + 1;
},
async onEnter() {
if (this.saveEnabled) {
await this.onSubmit();
Expand Down
18 changes: 18 additions & 0 deletions packages/client/src/helpers/fetchApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,21 @@ export function put(url, body) {
.then((text) => Promise.reject(new Error(text || r.statusText)));
});
}

export function patch(url, body) {
const options = {
method: 'PATCH',
credentials: 'include',
headers: getDefaultHeaders(),
body: JSON.stringify(body),
};
return fetch(addOrganizationId(apiURL(url)), options)
.then((r) => {
if (r.ok) {
return r.json();
}
return r
.text()
.then((text) => Promise.reject(new Error(text || r.statusText)));
});
}
30 changes: 24 additions & 6 deletions packages/client/src/store/modules/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,32 @@ export default {
await fetchApi.post('/api/organizations/:organizationId/users', user);
await dispatch('fetchUsers');
},
async deleteUser({ dispatch }, userId) {
await fetchApi.deleteRequest(`/api/organizations/:organizationId/users/${userId}`);
async updateUser({ commit }, user) {
const { id, name } = user;
const data = await fetchApi.patch(`/api/organizations/:organizationId/users/${id}`, { name });
commit('SET_LOGGED_IN_USER', data.user);
},
async deleteUser({ dispatch, commit }, userId) {
try {
await fetchApi.deleteRequest(
`/api/organizations/:organizationId/users/${userId}`,
);
} catch (error) {
commit('alerts/addAlert', {
text: `Error deleting user: ${error.message}`,
level: 'err',
}, { root: true });
}
await dispatch('fetchUsers');
},
async updateEmailSubscriptionPreferences({ dispatch }, { userId, preferences }) {
await fetchApi.put(`/api/organizations/:organizationId/users/${userId}/email_subscription`, {
preferences,
});
async updateEmailSubscriptionPreferences({ dispatch, commit }, { userId, preferences }) {
const data = await fetchApi.put(
`/api/organizations/:organizationId/users/${userId}/email_subscription`,
{
preferences,
},
);
commit('SET_LOGGED_IN_USER', data.user);
dispatch('fetchUsers');
},
},
Expand Down
Loading

0 comments on commit 8c90453

Please sign in to comment.