From 609bbfab71b32c84645a8114b37ca2e82edbbf22 Mon Sep 17 00:00:00 2001
From: Joshua Graber
Date: Mon, 13 Jan 2025 08:24:48 -0500
Subject: [PATCH 01/47] fix: not found text for typeahead
---
src/components/SearchForm.vue | 6 +-
src/pages/data-request/create.vue | 152 ++++----
src/pages/data-source/create.vue | 568 ++++++++++++++----------------
3 files changed, 349 insertions(+), 377 deletions(-)
diff --git a/src/components/SearchForm.vue b/src/components/SearchForm.vue
index a256b41..8d8c0c3 100644
--- a/src/components/SearchForm.vue
+++ b/src/components/SearchForm.vue
@@ -25,9 +25,9 @@
- No results found.
- Please check your spelling and search for a place in the United
- States.
+ We don't have agencies in the place you're looking for. Is it spelled
+ correctly? If our database is missing something, please reach us at
+ contact@pdap.io
diff --git a/src/pages/data-request/create.vue b/src/pages/data-request/create.vue
index 47f7197..432b780 100644
--- a/src/pages/data-request/create.vue
+++ b/src/pages/data-request/create.vue
@@ -18,14 +18,12 @@
name="new-request"
:schema="SCHEMA"
@error="error"
- @submit="submit"
- >
+ @submit="submit">
+ placeholder="Briefly describe the general purpose or topic.">
Request title
@@ -47,8 +45,7 @@
if (indexToRemove > -1)
selectedLocations.splice(indexToRemove, 1);
}
- "
- />
+ " />
+ @on-input="fetchTypeaheadResults">
-
+ v-html="typeaheadRef?.boldMatchText(getFullLocationText(item))" />
{{ item.type }}
Select
+
+
+ We don't have agencies in the place you're looking for. Is it
+ spelled correctly? If our database is missing something, please
+ reach us at
+ contact@pdap.io
+
+
+ position="left">
Coverage range
@@ -105,8 +106,7 @@
class="md:col-span-2"
:name="INPUT_NAMES.target"
:options="SELECT_OPTS"
- placeholder="When would you like to see this request filled?"
- >
+ placeholder="When would you like to see this request filled?">
Target date
@@ -117,8 +117,7 @@
class="md:col-start-1 md:col-end-2"
:name="INPUT_NAMES.notes"
placeholder="What are you trying to learn? Is there anything you've already tried?"
- rows="4"
- >
+ rows="4">
Request notes
@@ -129,31 +128,27 @@
class="md:col-start-2 md:col-end-3"
:name="INPUT_NAMES.requirements"
placeholder="Details the data must have, like 'case numbers' or 'incident location'."
- rows="4"
- >
+ rows="4">
@@ -168,42 +163,42 @@ import {
InputText,
InputSelect,
InputTextArea,
- InputDatePicker,
-} from "pdap-design-system";
-import Typeahead from "@/components/TypeaheadInput.vue";
-import LocationSelected from "@/components/TypeaheadSelected.vue";
-import { toast } from "vue3-toastify";
-import { createRequest } from "@/api/data-requests";
-import { getFullLocationText } from "@/util/locationFormatters";
-import _debounce from "lodash/debounce";
-import _cloneDeep from "lodash/cloneDeep";
-import { nextTick, ref, watch } from "vue";
-import { getTypeaheadLocations } from "@/api/typeahead";
+ InputDatePicker
+} from 'pdap-design-system';
+import Typeahead from '@/components/TypeaheadInput.vue';
+import LocationSelected from '@/components/TypeaheadSelected.vue';
+import { toast } from 'vue3-toastify';
+import { createRequest } from '@/api/data-requests';
+import { getFullLocationText } from '@/util/locationFormatters';
+import _debounce from 'lodash/debounce';
+import _cloneDeep from 'lodash/cloneDeep';
+import { nextTick, ref, watch } from 'vue';
+import { getTypeaheadLocations } from '@/api/typeahead';
const INPUT_NAMES = {
// contact: 'contact',
- title: "title",
- area: "area",
- range: "coverage_range",
- target: "request_urgency",
- notes: "submission_notes",
- requirements: "data_requirements",
+ title: 'title',
+ area: 'area',
+ range: 'coverage_range',
+ target: 'request_urgency',
+ notes: 'submission_notes',
+ requirements: 'data_requirements'
};
const SELECT_OPTS = [
- { value: "urgent", label: "Urgent (Less than a week)" },
+ { value: 'urgent', label: 'Urgent (Less than a week)' },
{
- value: "somewhat_urgent",
- label: "Somewhat urgent (Less than a month)",
+ value: 'somewhat_urgent',
+ label: 'Somewhat urgent (Less than a month)'
},
{
- value: "not_urgent",
- label: "Not urgent (A few months)",
+ value: 'not_urgent',
+ label: 'Not urgent (A few months)'
},
{
- value: "long_term",
- label: "Long term (6 months or more)",
+ value: 'long_term',
+ label: 'Long term (6 months or more)'
},
- { value: "indefinite_unknown", label: "Indefinite/Unknown" },
+ { value: 'indefinite_unknown', label: 'Indefinite/Unknown' }
];
const SCHEMA = [
// {
@@ -220,47 +215,46 @@ const SCHEMA = [
validators: {
required: {
value: true,
- message: "Please let us know what to call this request.",
- },
- },
+ message: 'Please let us know what to call this request.'
+ }
+ }
},
{
name: INPUT_NAMES.range,
validators: {
required: {
value: true,
- message: "Please let us know a range of years to look for this data.",
- },
- },
+ message: 'Please let us know a range of years to look for this data.'
+ }
+ }
},
{
name: INPUT_NAMES.target,
validators: {
required: {
value: true,
- message:
- "Please let us know when you'd like this request to be filled.",
- },
- },
+ message: "Please let us know when you'd like this request to be filled."
+ }
+ }
},
{
name: INPUT_NAMES.notes,
validators: {
required: {
value: true,
- message: "Please let us know a little more about your request.",
- },
- },
+ message: 'Please let us know a little more about your request.'
+ }
+ }
},
{
name: INPUT_NAMES.requirements,
validators: {
required: {
value: true,
- message: "Please let us know the requirements for this request.",
- },
- },
- },
+ message: 'Please let us know the requirements for this request.'
+ }
+ }
+ }
];
const selectedLocations = ref([]);
@@ -286,7 +280,7 @@ const fetchTypeaheadResults = _debounce(
}
},
350,
- { leading: true, trailing: true },
+ { leading: true, trailing: true }
);
async function clear() {
@@ -296,9 +290,9 @@ async function clear() {
.reduce(
(acc, cur) => ({
...acc,
- [cur]: "",
+ [cur]: ''
}),
- {},
+ {}
);
formRef.value.setValues(newVal);
@@ -310,22 +304,22 @@ async function clear() {
function error(v$) {
// Janky error handling for typeahead because it's not a controlled input - on form error, check for this error, too
if (v$.value.$anyDirty && !selectedLocations.value.length) {
- typeaheadError.value = "Please include a location with your request";
+ typeaheadError.value = 'Please include a location with your request';
}
}
async function submit(values) {
if (!selectedLocations.value.length) {
// Janky error handling for typeahead because it's not a controlled input - if form doesn't error, check for this error anyway.
- typeaheadError.value = "Please include a location with your request";
+ typeaheadError.value = 'Please include a location with your request';
return;
}
requestPending.value = true;
if (values[INPUT_NAMES.range]?.length) {
const range = values[INPUT_NAMES.range]
- .map((d) => (typeof d === "number" ? String(d) : ""))
- .join(" - ");
+ .map((d) => (typeof d === 'number' ? String(d) : ''))
+ .join(' - ');
values[INPUT_NAMES.range] = range;
}
@@ -340,8 +334,8 @@ async function submit(values) {
delete loc.display_name;
delete loc.location_id;
return loc;
- }),
- ],
+ })
+ ]
};
try {
@@ -352,7 +346,7 @@ async function submit(values) {
} catch (error) {
if (error) {
console.error(error);
- formError.value = "Something went wrong, please try again.";
+ formError.value = 'Something went wrong, please try again.';
formRef.value.setValues({ ...values });
var isError = !!error;
}
@@ -375,9 +369,9 @@ watch(
// clearing and re-applying when dirty
if (!selected.length && formRef.value.v$.$anyDirty) {
- typeaheadError.value = "Please include a location with your request";
+ typeaheadError.value = 'Please include a location with your request';
}
- },
+ }
);
diff --git a/src/pages/data-source/create.vue b/src/pages/data-source/create.vue
index e7d74fe..d376875 100644
--- a/src/pages/data-source/create.vue
+++ b/src/pages/data-source/create.vue
@@ -21,17 +21,18 @@
class="flex flex-col gap-2"
name="new-request"
:schema="SCHEMA"
- @submit="submit"
- >
+ @submit="submit">
+ @input="checkDuplicates">
-
Source URL*
+
+ Source URL
+ *
+
@@ -39,8 +40,7 @@
:id="'input-' + INPUT_NAMES.readMeUrl"
class="md:col-span-2"
:name="INPUT_NAMES.readMeUrl"
- placeholder="A link to any contextual info, like a data dictionary or explanation of the data."
- >
+ placeholder="A link to any contextual info, like a data dictionary or explanation of the data.">
README URL
@@ -61,8 +61,7 @@
const indexToRemove = selectedAgencies.indexOf(agency);
if (indexToRemove > -1) selectedAgencies.splice(indexToRemove, 1);
}
- "
- />
+ " />
+ @on-input="fetchTypeaheadResults">
@@ -106,9 +104,9 @@
items = [];
typeaheadRef.clearInput();
}
- "
- >
- No results found. Would you like to suggest
+ ">
+ No results found.
+ Would you like to suggest
{{ typeaheadRef.value }}
be added to our agencies database?
@@ -126,8 +124,7 @@
+ @click="agencyNotAvailable = ''" />
@@ -136,10 +133,12 @@
class="md:col-start-1 md:col-end-2"
:name="INPUT_NAMES.name"
placeholder="For example, “Arrest records for Portsmouth PD”"
- rows="4"
- >
+ rows="4">
-
Source name *
+
+ Source name
+ *
+
@@ -148,10 +147,12 @@
class="md:col-start-2 md:col-end-3"
:name="INPUT_NAMES.description"
placeholder="If the source is difficult to understand or categorize, please share more information about how it was processed or can be used."
- rows="4"
- >
+ rows="4">
-
Description *
+
+ Description
+ *
+
@@ -159,20 +160,21 @@
:id="'input-' + INPUT_NAMES.contact"
class="md:col-start-1 md:col-end-2"
:name="INPUT_NAMES.contact"
- placeholder="Please provide an email address so we can give credit or follow up with questions."
- >
+ placeholder="Please provide an email address so we can give credit or follow up with questions.">
How long are records kept? There may be guidelines regarding how
@@ -347,8 +337,7 @@
:key="schedule"
:name="INPUT_NAMES.schedule"
:value="schedule"
- :label="schedule"
- />
+ :label="schedule" />
“PDAP provides data necessary to understand how police use-of-force
incidents are processed in the courts, which reveals whether legal
diff --git a/src/pages/index.vue b/src/pages/index.vue
index 5d6e711..4a24996 100644
--- a/src/pages/index.vue
+++ b/src/pages/index.vue
@@ -14,5 +14,5 @@
diff --git a/src/pages/jobs.vue b/src/pages/jobs.vue
index 297923d..778793a 100644
--- a/src/pages/jobs.vue
+++ b/src/pages/jobs.vue
@@ -62,8 +62,7 @@
work on our software projects. During an initial interview, we will
discuss which issues on
+ href="https://github.com/orgs/Police-Data-Accessibility-Project/projects/21/views/2">
the roadmap
seem like a good fit for your skills.
@@ -112,8 +111,6 @@
diff --git a/src/pages/profile/_components/APIKey.vue b/src/pages/profile/_components/APIKey.vue
index 6ebeb0b..7602695 100644
--- a/src/pages/profile/_components/APIKey.vue
+++ b/src/pages/profile/_components/APIKey.vue
@@ -1,7 +1,6 @@
- {{ error ? "Error validating your account" : "Validating your account" }}
+ {{ error ? 'Error validating your account' : 'Validating your account' }}
+ class="flex flex-col items-start sm:gap-4">
{{
isExpiredToken
- ? "Sorry, that token has expired."
- : "Sorry, that token is invalid."
+ ? 'Sorry, that token has expired.'
+ : 'Sorry, that token is invalid.'
}}