[ , ...]
* in chronological order by date.
@@ -50,8 +50,8 @@ export function sortByDate(tripActivities) {
/**
* Puta
andb
in display order.
* This function is a comparator.
- * @param {ActivityInfo} a Dictionary representing activity a and its fields.
- * @param {ActivityInfo} b Dictionary representing activity b and its fields.
+ * @param {!ActivityInfo} a Dictionary representing activity a and its fields.
+ * @param {!ActivityInfo} b Dictionary representing activity b and its fields.
* @return {int} -1
if a
comes before b
, else 1
.
*/
export function compareActivities(a, b) {
@@ -69,11 +69,11 @@ export function compareActivities(a, b) {
/**
* Get the field of field name fieldName from activity or the default value.
*
- * @param {ActivityInfo} activity The activity from which to get the field.
- * @param {string} fieldName Name of field to get.
- * @param {*} defaultValue Value if field is not found/is null.
- * @param {string} prefix The prefix to put before a returned value if the field exists.
- * @returns {*} activity[fieldName]
if possible, else defaultValue
.
+ * @param {!ActivityInfo} activity The activity from which to get the field.
+ * @param {!string} fieldName Name of field to get.
+ * @param {*} [defaultValue=null] Value if field is not found/is null.
+ * @param {string} [prefix=''] The prefix to put before a returned value if the field exists.
+ * @return {*} activity[fieldName]
if possible, else defaultValue
.
*/
export function getField(activity, fieldName, defaultValue=null, prefix=''){
if (activity[fieldName] === null || activity[fieldName] === undefined) {
@@ -85,10 +85,10 @@ export function getField(activity, fieldName, defaultValue=null, prefix=''){
/**
* Write contents into an activity already existing in the database.
*
- * @param {string} tripId Database ID of the trip whose actiivty should be modified.
- * @param {string} activityId Database ID of the activity to be modified.
+ * @param {!string} tripId Database ID of the trip whose actiivty should be modified.
+ * @param {!string} activityId Database ID of the activity to be modified.
* @param {Object} newValues Dictionary of the new values in {fieldName: newValue}
form
- * @returns {boolean} true
if the write was successful, false
otherwise.
+ * @return {boolean} true
if the write was successful, false
otherwise.
*/
export async function writeActivity(tripId, activityId, newValues) {
// todo: check if tripId or activityId is not valid. (#58)
@@ -113,10 +113,12 @@ export async function writeActivity(tripId, activityId, newValues) {
/**
* Get the value of a reference.
*
- * @param {Reference} ref Reference to get the value of.
- * @param {string} ignoreValue The "null" or "none" value that ref could be.
- * @param {string} defaultValue Value to return if ref.current.value === ignoreValue.
- * @returns defaultValue if ref.current.value === ignoreValue, else ref.current.value.
+ * Note: This function breaks if ref.current
is null. This is intentional.
+ *
+ * @param {!Reference} ref Reference to get the value of.
+ * @param {?string} ignoreValue The "null" or "none" value that ref could be.
+ * @param {?string} [defaultValue=null] Value to return if ref.current.value === ignoreValue.
+ * @return defaultValue if ref.current.value === ignoreValue, else ref.current.value.
*/
export function getRefValue(ref, ignoreValue, defaultValue=null) {
if (ref.current.value === ignoreValue) {
diff --git a/frontend/src/components/ViewActivities/activitylist.js b/frontend/src/components/ViewActivities/activitylist.js
index 9dad6f86..b3ad15ff 100644
--- a/frontend/src/components/ViewActivities/activitylist.js
+++ b/frontend/src/components/ViewActivities/activitylist.js
@@ -10,7 +10,7 @@ const db = app.firestore();
/**
* Gets the list of activities from the server.
*
- * @param {string} tripId The trip ID.
+ * @param {!string} tripId The trip ID.
* @return {ActivityInfo[]} The list of trip activities.
*/
export async function getActivityList(tripId) {
diff --git a/frontend/src/components/ViewActivities/editActivityFormElements.js b/frontend/src/components/ViewActivities/editActivityFormElements.js
index db1c5343..611dd892 100644
--- a/frontend/src/components/ViewActivities/editActivityFormElements.js
+++ b/frontend/src/components/ViewActivities/editActivityFormElements.js
@@ -12,11 +12,11 @@ const TZPICKERWIDTH = 3;
/**
* Create a Text element Form Group for the editActivity form.
*
- * @param {string} controlId FormGroup's control ID.
- * @param {string} formLabel The label of the field for this FormGroup.
- * @param {string} placeHolder The input's placeholder.
- * @param {ref} ref The input's reference.
- * @returns {HTML} A text element form group.
+ * @param {!string} controlId FormGroup's control ID.
+ * @param {!string} formLabel The label of the field for this FormGroup.
+ * @param {!string} placeHolder The input's placeholder.
+ * @param {?ref} ref The input's reference.
+ * @return {HTML} A text element form group.
*/
export function textElementFormGroup(controlId, formLabel, placeHolder, ref) {
return (
@@ -34,10 +34,10 @@ export function textElementFormGroup(controlId, formLabel, placeHolder, ref) {
/**
* Create a Location Dropdown element Form Group for the editActivity form.
*
- * @param {string} controlId FormGroup's control ID.
- * @param {string} formLabel The label of the field for this FormGroup.
- * @param {string} dropdown The dropdown.
- * @returns {HTML} a location dropdown form group.
+ * @param {!string} controlId FormGroup's control ID.
+ * @param {!string} formLabel The label of the field for this FormGroup.
+ * @param {!string} dropdown The dropdown.
+ * @return {HTML} a location dropdown form group.
*/
export function locationElementFormGroup(controlId, formLabel, dropdown) {
return (
@@ -52,14 +52,14 @@ export function locationElementFormGroup(controlId, formLabel, dropdown) {
* Create a Form Group for inserting date, time, and timezone for
* the editActivity form..
*
- * @param {string} controlId FormGroup's control ID.
- * @param {string} formLabel Label of the field for this FormGroup.
- * @param {ref} dateRef Date's reference.
- * @param {string} dateDefault Default date.
- * @param {ref} timeRef Time's reference.
- * @param {ref} timeDefault Default time.
- * @param {HTML} tzpicker Timezone picker dropdown.
- * @returns {HTML} A FormGroup for date, time, and timezone.
+ * @param {!string} controlId FormGroup's control ID.
+ * @param {!string} formLabel Label of the field for this FormGroup.
+ * @param {?ref} dateRef Date's reference.
+ * @param {!string} dateDefault Default date.
+ * @param {?ref} timeRef Time's reference.
+ * @param {!ref} timeDefault Default time.
+ * @param {!HTML} tzpicker Timezone picker dropdown.
+ * @return {HTML} A FormGroup for date, time, and timezone.
*/
export function dateTimeTzFormGroup(controlId, formLabel, dateRef,
dateDefault, timeRef, timeDefault, tzpicker) {
diff --git a/frontend/src/components/ViewActivities/index.js b/frontend/src/components/ViewActivities/index.js
index bbcb2a55..025491e7 100644
--- a/frontend/src/components/ViewActivities/index.js
+++ b/frontend/src/components/ViewActivities/index.js
@@ -2,10 +2,10 @@ import React from 'react';
import ActivityList from './activitylist.js';
/**
- * The whole view activities page.
+ * React component for the whole 'view activities' page.
*
- * @param {Object} props This component expects the following props:
- * - `tripId` {string} The trip's ID. This is sent to the component through the URL.
+ * @property {Object} props ReactJS props.
+ * @property {ActivityInfo} props.tripId This is sent to the component through the URL.
*/
class ViewActivities extends React.Component {
render() {
From 97c6b92e4a484453e2708ed831f924fb5136a82c Mon Sep 17 00:00:00 2001
From: Ananya Y <14322650+ananyeet@users.noreply.github.com>
Date: Thu, 23 Jul 2020 16:08:10 -0500
Subject: [PATCH 3/8] change types
---
frontend/src/components/Utils/time.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/frontend/src/components/Utils/time.js b/frontend/src/components/Utils/time.js
index c9332347..1a1d5e48 100644
--- a/frontend/src/components/Utils/time.js
+++ b/frontend/src/components/Utils/time.js
@@ -6,7 +6,7 @@ import { firestore } from 'firebase';
* Format a timestamp (in milliseconds) into a pretty string with just the time like
* '10.19 AM'.
*
- * @param {int} msTimestamp Timestamp in milliseconds of desired date.
+ * @param {number} msTimestamp Timestamp in milliseconds of desired date.
* @param {string} timezone Timezone in which to convert.
* @return {string} Time formatted into desired pretty string.
*/
@@ -18,7 +18,7 @@ export function timestampToTimeFormatted(msTimestamp, timezone = 'America/New_Yo
* Format a timestamp (in milliseconds) into a pretty string with just the date, like
* 'Monday, January 19, 1970'.
*
- * @param {int} msTimestamp Timestamp in milliseconds of desired date.
+ * @param {number} msTimestamp Timestamp in milliseconds of desired date.
* @param {string} timezone Timezone in which to convert.
* @return {string} Time formatted into desired pretty string.
*/
@@ -30,7 +30,7 @@ export function timestampToDateFormatted(msTimestamp, timezone='America/New_York
* Format a timestamp (in milliseconds) into a pretty string like
* 'Monday, January 19, 1970, 02:48 AM'.
*
- * @param {int} msTimestamp Timestamp in milliseconds of desired date.
+ * @param {number} msTimestamp Timestamp in milliseconds of desired date.
* @param {string} timezone Timezone in which to convert.
* @return {string} Time formatted into desired pretty string.
*/
@@ -60,7 +60,7 @@ export function timezonesForCountry(countryName) {
/**
* Get a date in 'YYYY-MM-DD' format.
*
- * @param {string} msTimestamp Timestamp, in milliseconds since epoch.
+ * @param {number} msTimestamp Timestamp, in milliseconds since epoch.
* @param {string} timezone The timezone which the string should be returned in.
* @returns {string} The date in 'YYYY-MM-DD' format.
*/
@@ -74,7 +74,7 @@ export function getDateBarebones(msTimestamp, timezone=null) {
/**
* Get a time in 24-hour ('HH:mm') format.
*
- * @param {string} msTimestamp Timestamp, in milliseconds since epoch.
+ * @param {number} msTimestamp Timestamp, in milliseconds since epoch.
* @param {string} timezone The timezone which the string should be returned in.
* @returns {string} The time in 24-hour (HH:mm) format.
*/
From edfd5bc39c99edfe313b145eb339285fc03cfbc9 Mon Sep 17 00:00:00 2001
From: Ananya Y <14322650+ananyeet@users.noreply.github.com>
Date: Fri, 24 Jul 2020 10:27:02 -0500
Subject: [PATCH 4/8] jsdoc links and arrays
---
frontend/src/components/ViewActivities/activityfns.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/frontend/src/components/ViewActivities/activityfns.js b/frontend/src/components/ViewActivities/activityfns.js
index 315736a3..bff000d9 100644
--- a/frontend/src/components/ViewActivities/activityfns.js
+++ b/frontend/src/components/ViewActivities/activityfns.js
@@ -25,8 +25,7 @@ const db = app.firestore();
/**
* Sort a list of trip activities by date.
* @param {!ActivityInfo[]} tripActivities Array of activities.
- * @return {DayOfActivities[]} List of trip activities in the form
- * [ , ...]
+ * @return {DayOfActivities[]} List of {@link DayOfActivities}
* in chronological order by date.
*/
export function sortByDate(tripActivities) {
From c5dcb4f31b0a5aa5f7c0948539360f72268bb67c Mon Sep 17 00:00:00 2001
From: Ananya Y <14322650+ananyeet@users.noreply.github.com>
Date: Fri, 31 Jul 2020 10:35:30 -0500
Subject: [PATCH 5/8] setup jsdoc framework
---
.gitignore | 1 +
frontend/.jsdoc.conf.json | 22 +++
frontend/package-lock.json | 136 ++++++++++++++++++
frontend/package.json | 6 +-
frontend/src/components/Utils/filter-input.js | 4 +-
5 files changed, 166 insertions(+), 3 deletions(-)
create mode 100644 frontend/.jsdoc.conf.json
diff --git a/.gitignore b/.gitignore
index 4bd0f035..e6a16856 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ target/
# Don't include log files
*.log
+frontend/docs/*
\ No newline at end of file
diff --git a/frontend/.jsdoc.conf.json b/frontend/.jsdoc.conf.json
new file mode 100644
index 00000000..9b622c1f
--- /dev/null
+++ b/frontend/.jsdoc.conf.json
@@ -0,0 +1,22 @@
+{
+ "plugins": ["plugins/markdown"],
+ "recurseDepth": 10,
+ "opts": {
+ "recurse": true,
+ "destination": "./docs/"
+ },
+ "source": {
+ "include": ["src"],
+ "includePattern": ".+\\.js(doc|x)?$",
+ "excludePattern": "node_modules"
+ },
+ "sourceType": "module",
+ "tags": {
+ "allowUnknownTags": true,
+ "dictionaries": ["jsdoc", "closure"]
+ },
+ "templates": {
+ "cleverLinks": false,
+ "monospaceLinks": false
+ }
+}
\ No newline at end of file
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 3954b7b3..0c81f2cc 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -3575,6 +3575,15 @@
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
},
+ "catharsis": {
+ "version": "0.8.11",
+ "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.11.tgz",
+ "integrity": "sha512-a+xUyMV7hD1BrDQA/3iPV7oc+6W26BgVJO05PGEoatMyIuPScQKsde6i3YorWX1qs+AZjnJ18NqdKoCtKiNh1g==",
+ "dev": true,
+ "requires": {
+ "lodash": "^4.17.14"
+ }
+ },
"chalk": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@@ -7859,11 +7868,56 @@
"esprima": "^4.0.0"
}
},
+ "js2xmlparser": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.1.tgz",
+ "integrity": "sha512-KrPTolcw6RocpYjdC7pL7v62e55q7qOMHvLX1UCLc5AAS8qeJ6nukarEJAF2KL2PZxlbGueEbINqZR2bDe/gUw==",
+ "dev": true,
+ "requires": {
+ "xmlcreate": "^2.0.3"
+ }
+ },
"jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
},
+ "jsdoc": {
+ "version": "3.6.5",
+ "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.5.tgz",
+ "integrity": "sha512-SbY+i9ONuxSK35cgVHaI8O9senTE4CDYAmGSDJ5l3+sfe62Ff4gy96osy6OW84t4K4A8iGnMrlRrsSItSNp3RQ==",
+ "dev": true,
+ "requires": {
+ "@babel/parser": "^7.9.4",
+ "bluebird": "^3.7.2",
+ "catharsis": "^0.8.11",
+ "escape-string-regexp": "^2.0.0",
+ "js2xmlparser": "^4.0.1",
+ "klaw": "^3.0.0",
+ "markdown-it": "^10.0.0",
+ "markdown-it-anchor": "^5.2.7",
+ "marked": "^0.8.2",
+ "mkdirp": "^1.0.4",
+ "requizzle": "^0.2.3",
+ "strip-json-comments": "^3.1.0",
+ "taffydb": "2.6.2",
+ "underscore": "~1.10.2"
+ },
+ "dependencies": {
+ "escape-string-regexp": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz",
+ "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==",
+ "dev": true
+ },
+ "mkdirp": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
+ "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
+ "dev": true
+ }
+ }
+ },
"jsdom": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-11.12.0.tgz",
@@ -8001,6 +8055,15 @@
"is-buffer": "^1.1.5"
}
},
+ "klaw": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz",
+ "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==",
+ "dev": true,
+ "requires": {
+ "graceful-fs": "^4.1.9"
+ }
+ },
"kleur": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
@@ -8060,6 +8123,15 @@
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz",
"integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA="
},
+ "linkify-it": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz",
+ "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==",
+ "dev": true,
+ "requires": {
+ "uc.micro": "^1.0.1"
+ }
+ },
"load-json-file": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
@@ -8292,6 +8364,31 @@
"object-visit": "^1.0.0"
}
},
+ "markdown-it": {
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz",
+ "integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==",
+ "dev": true,
+ "requires": {
+ "argparse": "^1.0.7",
+ "entities": "~2.0.0",
+ "linkify-it": "^2.0.0",
+ "mdurl": "^1.0.1",
+ "uc.micro": "^1.0.5"
+ }
+ },
+ "markdown-it-anchor": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.3.0.tgz",
+ "integrity": "sha512-/V1MnLL/rgJ3jkMWo84UR+K+jF1cxNG1a+KwqeXqTIJ+jtA8aWSHuigx8lTzauiIjBDbwF3NcWQMotd0Dm39jA==",
+ "dev": true
+ },
+ "marked": {
+ "version": "0.8.2",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-0.8.2.tgz",
+ "integrity": "sha512-EGwzEeCcLniFX51DhTpmTom+dSA/MG/OBUDjnWtHbEnjAH180VzUeAw+oE4+Zv+CoYBWyRlYOTR0N8SO9R1PVw==",
+ "dev": true
+ },
"material-design-lite": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/material-design-lite/-/material-design-lite-1.3.0.tgz",
@@ -8312,6 +8409,12 @@
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.4.tgz",
"integrity": "sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA=="
},
+ "mdurl": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
+ "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=",
+ "dev": true
+ },
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -11532,6 +11635,15 @@
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
+ "requizzle": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz",
+ "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==",
+ "dev": true,
+ "requires": {
+ "lodash": "^4.17.14"
+ }
+ },
"resolve": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz",
@@ -12825,6 +12937,12 @@
}
}
},
+ "taffydb": {
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz",
+ "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=",
+ "dev": true
+ },
"tapable": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz",
@@ -13235,6 +13353,12 @@
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
+ "uc.micro": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
+ "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==",
+ "dev": true
+ },
"uncontrollable": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-7.1.1.tgz",
@@ -13246,6 +13370,12 @@
"react-lifecycles-compat": "^3.0.4"
}
},
+ "underscore": {
+ "version": "1.10.2",
+ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.10.2.tgz",
+ "integrity": "sha512-N4P+Q/BuyuEKFJ43B9gYuOj4TQUHXX+j2FqguVOpjkssLUUrnJofCcBccJSCoeturDoZU6GorDTHSvUDlSQbTg==",
+ "dev": true
+ },
"unicode-canonical-property-names-ecmascript": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz",
@@ -14470,6 +14600,12 @@
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw=="
},
+ "xmlcreate": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.3.tgz",
+ "integrity": "sha512-HgS+X6zAztGa9zIK3Y3LXuJes33Lz9x+YyTxgrkIdabu2vqcGOWwdfCpf1hWLRrd553wd4QCDf6BBO6FfdsRiQ==",
+ "dev": true
+ },
"xmlhttprequest": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 891f2261..707532af 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -24,7 +24,8 @@
"local": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
- "eject": "react-scripts eject"
+ "eject": "react-scripts eject",
+ "docs": "./node_modules/.bin/jsdoc src -r -c ./.jsdoc.conf.json -d docs"
},
"engines": {
"node": "10.x.x"
@@ -44,5 +45,8 @@
"last 1 firefox version",
"last 1 safari version"
]
+ },
+ "devDependencies": {
+ "jsdoc": "~3.6.5"
}
}
diff --git a/frontend/src/components/Utils/filter-input.js b/frontend/src/components/Utils/filter-input.js
index ab679147..6dee05f6 100644
--- a/frontend/src/components/Utils/filter-input.js
+++ b/frontend/src/components/Utils/filter-input.js
@@ -21,9 +21,9 @@ export function getCleanedTextInput(rawInput, defaultValue) {
* TODO(#72 & #67): Remove 'remove empty fields' once there is better way to
* remove collaborators (#72) and there is email validation (#67).
*
- * @param {!Array{string}} collaboratorEmailsArr Array of emails corresponding
+ * @param {!Array. ['MM/DD/YYYY', [activities on that day]]
+ * ```['MM/DD/YYYY', [activities on that day]]```
* @typedef {Array.a
andb
in display order.
+ * Put`a and `b` in display order.
* This function is a comparator.
- * @param {!ActivityInfo} a Dictionary representing activity a and its fields.
- * @param {!ActivityInfo} b Dictionary representing activity b and its fields.
- * @return {int} -1
if a
comes before b
, else 1
.
+ * @param {!ActivityInfo} a Dictionary representing activity `a` and its fields.
+ * @param {!ActivityInfo} b Dictionary representing activity `b` and its fields.
+ * @return {int} `-1` if `a` comes before `b`, else `1`.
*/
export function compareActivities(a, b) {
if (a[DB.ACTIVITIES_START_TIME] < b[DB.ACTIVITIES_START_TIME]) {
@@ -84,30 +87,14 @@ export function compareActivities(a, b) {
return -1;
}
-
-/**
- * Get the field of field name fieldName from activity or the default value.
- *
- * @param {!ActivityInfo} activity The activity from which to get the field.
- * @param {!string} fieldName Name of field to get.
- * @param {*} [defaultValue=null] Value if field is not found/is null.
- * @param {string} [prefix=''] The prefix to put before a returned value if the field exists.
- * @return {*} activity[fieldName]
if possible, else defaultValue
.
- */
-export function getField(activity, fieldName, defaultValue=null, prefix=''){
- if (activity[fieldName] === null || activity[fieldName] === undefined) {
- return defaultValue;
- }
- return prefix + activity[fieldName];
-}
-
/**
* Write contents into an activity already existing in the database.
*
* @param {!string} tripId Database ID of the trip whose actiivty should be modified.
* @param {!string} activityId Database ID of the activity to be modified.
- * @param {Object} newValues Dictionary of the new values in {fieldName: newValue}
form
- * @return {boolean} true
if the write was successful, false
otherwise.
+ * @param {!Objects} newValues Dictionary of the new values in `{fieldName: newValue}`
+ * form. None of the entries can be lists.
+ * @return {boolean} `true` if the write was successful, `false` otherwise.
*/
export async function writeActivity(tripId, activityId, newValues) {
// todo: check if tripId or activityId is not valid. (#58)
@@ -132,7 +119,7 @@ export async function writeActivity(tripId, activityId, newValues) {
/**
* Get the value of a reference.
*
- * Note: This function breaks if ref.current
is null. This is intentional.
+ * Note: This function breaks if `ref.current` is null. This is intentional.
*
* @param {!Reference} ref Reference to get the value of.
* @param {?string} ignoreValue The "null" or "none" value that ref could be.
diff --git a/frontend/src/components/ViewActivities/activitylist.js b/frontend/src/components/ViewActivities/activitylist.js
index 4a6ba54a..f63ba7bb 100644
--- a/frontend/src/components/ViewActivities/activitylist.js
+++ b/frontend/src/components/ViewActivities/activitylist.js
@@ -27,7 +27,7 @@ class ActivityList extends React.Component {
*
* This function sets `this.state.days` to the sorted days.
*
- * @param {string} tripId The trip ID.
+ * @param {!string} tripId The trip ID.
*/
async getActivityList(tripId) {
db.collection(DB.COLLECTION_TRIPS).doc(tripId)
diff --git a/frontend/src/components/ViewActivities/editActivity.js b/frontend/src/components/ViewActivities/editActivity.js
index c2ef125f..bbc587e6 100644
--- a/frontend/src/components/ViewActivities/editActivity.js
+++ b/frontend/src/components/ViewActivities/editActivity.js
@@ -79,7 +79,11 @@ class EditActivity extends React.Component {
writeActivity(this.props.activity.tripId, this.props.activity.id, newVals);
}
- /** Runs when the `submit` button on the form is pressed. */
+ /**
+ * Runs when the `submit` button on the form is pressed.
+ *
+ * @param event The form event.
+ */
finishEditActivity(event) {
event.preventDefault();
this.editActivity();
@@ -96,9 +100,9 @@ class EditActivity extends React.Component {
* The dropdown's values change based on the corrresponding country dropdown to
* reduce scrolling and ensure that the location corresponds to the time zone.
*
- * @param st Either 'start' or 'end' depending on whether the
+ * @param {!string} st Either 'start' or 'end' depending on whether the
* timezone is for the start or end timezone.
- * @param defaultTz The default time zone.
+ * @param {!string} defaultTz The default time zone.
* @returns HTML dropdown item.
*/
timezoneDropdown(st, defaultTz) {
@@ -131,9 +135,9 @@ class EditActivity extends React.Component {
* so when the country changes here, the values in the timezone dropdown
* change as well.
*
- * @param {ref} ref The reference to attach to the dropdown.
- * @param {ref} tzref The corresponding time zone reference field.
- * @param {string} defaultCountry The default country for the dropdown.
+ * @param {!ref} ref The reference to attach to the dropdown.
+ * @param {!ref} tzref The corresponding time zone reference field.
+ * @param {!string} defaultCountry The default country for the dropdown.
* @return {HTML} HTML dropdown of all the countries with timezones.
*/
countriesDropdown(ref, tzref, defaultCountry) {
diff --git a/frontend/src/components/ViewActivities/index.js b/frontend/src/components/ViewActivities/index.js
index d718a676..27a97632 100644
--- a/frontend/src/components/ViewActivities/index.js
+++ b/frontend/src/components/ViewActivities/index.js
@@ -32,7 +32,7 @@ class ViewActivities extends React.Component {
* Create an empty activity (with filler information) to edit and then display.
* Allows us to use editActivity instead of creating a whole new form for it.
*
- * @param {string} tripId The tripId to attach to this new activity.
+ * @param {!string} tripId The tripId to attach to this new activity.
* @return {Object} Data filled into new Activity.
*/
createEmptyActivity = (tripId) => {
@@ -48,7 +48,8 @@ class ViewActivities extends React.Component {
}
/**
- * Complete "Add Activity" operation
+ * Complete "Add Activity" operation.
+ * @param e Form event.
*/
addActivity = (e) => {
e.preventDefault();
@@ -67,6 +68,28 @@ class ViewActivities extends React.Component {
newAct: null
});
};
+
+ /** @inheritdoc */
+ componentDidMount() {
+ app.firestore()
+ .collection(DB.COLLECTION_TRIPS)
+ .doc(this.tripId)
+ .get()
+ .then(doc => {
+ this.setState({
+ collaborators: doc.get(DB.TRIPS_COLLABORATORS),
+ isLoading: false,
+ error: undefined
+ });
+ })
+ .catch(e => {
+ this.setState({
+ collaborators: undefined,
+ isLoading: true,
+ error: e
+ })
+ });
+ }
render() {
const tripId = this.props.match.params.tripId;
@@ -108,28 +131,6 @@ class ViewActivities extends React.Component {
}
}
}
-
- /** @inheritdoc */
- componentDidMount() {
- app.firestore()
- .collection(DB.COLLECTION_TRIPS)
- .doc(this.tripId)
- .get()
- .then(doc => {
- this.setState({
- collaborators: doc.get(DB.TRIPS_COLLABORATORS),
- isLoading: false,
- error: undefined
- });
- })
- .catch(e => {
- this.setState({
- collaborators: undefined,
- isLoading: true,
- error: e
- })
- });
- }
}
export default ViewActivities;
From 98072194324e96db53f119b6aab59b84f9ecce2d Mon Sep 17 00:00:00 2001
From: Ananya Y <14322650+ananyeet@users.noreply.github.com>
Date: Thu, 6 Aug 2020 14:25:36 -0500
Subject: [PATCH 7/8] PR Comments.
---
frontend/src/components/Utils/time.js | 24 ++++++-------
.../src/components/ViewActivities/activity.js | 5 +--
.../components/ViewActivities/activityfns.js | 18 +++++-----
.../components/ViewActivities/activitylist.js | 2 +-
.../components/ViewActivities/editActivity.js | 6 ++--
.../editActivityFormElements.js | 34 +++++++++----------
.../src/components/ViewActivities/index.js | 2 +-
7 files changed, 46 insertions(+), 45 deletions(-)
diff --git a/frontend/src/components/Utils/time.js b/frontend/src/components/Utils/time.js
index 9953d44f..75bb35ec 100644
--- a/frontend/src/components/Utils/time.js
+++ b/frontend/src/components/Utils/time.js
@@ -6,7 +6,7 @@ import { firestore } from 'firebase';
* Format a timestamp (in milliseconds) into a pretty string with just the time.
* Example: '10:19 AM'.
*
- * @param {!number} msTimestamp Timestamp in milliseconds of desired date.
+ * @param {number} msTimestamp Timestamp in milliseconds of desired date.
* @param {string} [timezone='America/New_York']
* Timezone in which to convert (using underscores, not spaces).
* @return {string} Formatted time.
@@ -22,7 +22,7 @@ export function timestampToTimeFormatted(msTimestamp, timezone = 'America/New_Yo
* Format a timestamp (in milliseconds) into a pretty string with just the date.
* Example: 'Monday, January 19, 1970'.
*
- * @param {!number} msTimestamp Timestamp in milliseconds of desired date.
+ * @param {number} msTimestamp Timestamp in milliseconds of desired date.
* @param {string} [timezone='America/New_York']
* Timezone in which to convert (using underscores, not spaces).
* @return {string} Formatted time.
@@ -38,7 +38,7 @@ export function timestampToDateFormatted(msTimestamp, timezone='America/New_York
* Format a timestamp (in milliseconds) into a pretty string.
* Example: 'Monday, January 19, 1970 02:48 AM PST'.
*
- * @param {!number} msTimestamp Timestamp in milliseconds of desired date.
+ * @param {number} msTimestamp Timestamp in milliseconds of desired date.
* @param {string} [timezone='America/New_York']
* Timezone in which to convert (using underscores, not spaces).
* @returns {string} Formatted time.
@@ -54,7 +54,7 @@ export function timestampToFormatted(msTimestamp, timezone = 'America/New_York')
/**
* Return a Firestore Timestamp corresponding to the date in `dateStr`.
*
- * @param {!string} dateStr String containing a date in the form 'YYYY-MM-DD'.
+ * @param {string} dateStr String containing a date in the form 'YYYY-MM-DD'.
* @return {firestore.Timestamp} Firestore timestamp object created.
*/
export function getTimestampFromDateString(dateStr) {
@@ -70,7 +70,7 @@ export function getTimestampFromDateString(dateStr) {
/**
* Formats a Firestore timestamp into a date string in ISO format.
*
- * @param {!firestore.Timestamp} timestamp Firestore timestamp object.
+ * @param {firestore.Timestamp} timestamp Firestore timestamp object.
* @return {string} ISO formatted date string: "YYYY-MM-DD or 2020-05-12".
*/
export function timestampToISOString(timestamp) {
@@ -100,8 +100,8 @@ export function timezonesForCountry(countryName) {
/**
* Get a date in 'YYYY-MM-DD' format.
*
- * @param {!number} msTimestamp Timestamp, in milliseconds since epoch.
- * @param {string} [timezone=null] The timezone which the string should be returned in.
+ * @param {number} msTimestamp Timestamp, in milliseconds since epoch.
+ * @param {?string} [timezone=null] The timezone which the string should be returned in.
* @return {string} The date in 'YYYY-MM-DD' format.
* A null value will return timezone in GMT.
*/
@@ -115,8 +115,8 @@ export function getISODate(msTimestamp, timezone=null) {
/**
* Get a time in 24-hour ('HH:mm') format.
*
- * @param {!number} msTimestamp Timestamp, in milliseconds since epoch.
- * @param {string} [timezone=null] The timezone which the string should be returned in.
+ * @param {number} msTimestamp Timestamp, in milliseconds since epoch.
+ * @param {?string} [timezone=null] The timezone which the string should be returned in.
* @return {string} The time in 24-hour (HH:mm) format.
* A null value will return timezone in GMT.
*/
@@ -130,9 +130,9 @@ export function get24hTime(msTimestamp, timezone = null) {
/**
* Get a Firebase Timestamp object for time.
*
- * @param {!string} time The time in 'HH:mm' format.
- * @param {!string} date The date in 'YYYY-MM-DD' format.
- * @param {!string} tz The timezone in which the date takes place.
+ * @param {string} time The time in 'HH:mm' format.
+ * @param {string} date The date in 'YYYY-MM-DD' format.
+ * @param {string} tz The timezone in which the date takes place.
* @return {firestore.Timestamp} Firestore timestamp object at the same time.
*/
export function firebaseTsFromISO(time, date, tz) {
diff --git a/frontend/src/components/ViewActivities/activity.js b/frontend/src/components/ViewActivities/activity.js
index b0ac40ec..9feed8cd 100644
--- a/frontend/src/components/ViewActivities/activity.js
+++ b/frontend/src/components/ViewActivities/activity.js
@@ -37,7 +37,7 @@ class Activity extends React.Component {
/**
* Display the current activity, either in view or edit mode.
*
- * @return {HTML} The current activity in correct mode.
+ * @return {JSX.Element} The current activity in correct mode.
*/
displayCard = () => {
let activity = this.props.activity;
@@ -73,7 +73,8 @@ class Activity extends React.Component {
+ With SLURP, you can collaborate with others on your upcoming trips + using our intuitive, real-time itinerary planner. +
+ +