Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
08aab7d
Start add note editing ability
chessmyers Nov 22, 2020
b149041
Add modal for adding notes (currently hits backend endpoint, doesn't …
chessmyers Feb 7, 2021
6e0c916
Update story
chessmyers Feb 7, 2021
00b8566
Merge remote-tracking branch 'origin/develop' into editable-notes
chessmyers Feb 7, 2021
5786d4c
Change to use twin macro
chessmyers Feb 7, 2021
6adbf8c
Change to use twin macro
chessmyers Feb 7, 2021
6f09c38
Add include student ID in request body
chessmyers Feb 7, 2021
7ed06cd
Start adding student details page note box
chessmyers Feb 11, 2021
06a5dc5
Merge remote-tracking branch 'origin/develop' into add-note-view-to-s…
chessmyers Feb 11, 2021
dd3db57
Note box looking aight
chessmyers Mar 11, 2021
cbf94fe
Merge remote-tracking branch 'origin/develop' into editable-notes
chessmyers Mar 18, 2021
c0c392b
Merge remote-tracking branch 'origin/connect-to-backend' into editabl…
chessmyers Mar 18, 2021
81be176
Make changes from merge
chessmyers Mar 19, 2021
143a105
Refactor to be a ListBase
chessmyers Mar 19, 2021
450321b
Abandon using listbase
chessmyers Mar 21, 2021
3359466
Merge remote-tracking branch 'origin/connect-to-backend' into add-not…
chessmyers Mar 21, 2021
e983bfa
Drawer and pagination working
chessmyers Mar 28, 2021
1aa1cac
Fix note styling
chessmyers Apr 1, 2021
bf94b94
Show tags on notes
chessmyers Apr 4, 2021
786e503
Merge remote-tracking branch 'origin/editable-notes' into add-note-vi…
chessmyers Apr 4, 2021
f2ed998
Show tags on notes
chessmyers Apr 11, 2021
381151b
Merge remote-tracking branch 'origin/develop' into add-note-view-to-s…
chessmyers Apr 11, 2021
3fdc1d8
Fix deleting and proper fetch notes
chessmyers Apr 18, 2021
cc81ee8
Set up to update notes on modal close... now how tf do you actually d…
chessmyers Apr 22, 2021
9fa3e73
Show more text on note title
chessmyers Apr 23, 2021
a235e63
Merge remote-tracking branch 'origin/develop' into add-note-view-to-s…
chessmyers Apr 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pharmd-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@storybook/addon-links": "^5.3.13",
"@storybook/addons": "^5.3.13",
"@storybook/preset-create-react-app": "^1.5.2",
"@storybook/react": "^5.3.13",
"@storybook/react": "^5.3.21",
"@svgr/webpack": "^5.1.0",
"babel-loader": "^8.0.6",
"babel-plugin-macros": "^2.8.0",
Expand Down
2 changes: 2 additions & 0 deletions pharmd-app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AuthProvider, DataProvider } from "./services";
import createLigthTheme from "./themes/light-theme";
import DashboardLayout from "./components/Layout/DashboardLayout";
import customRoutes from "./config/customRoutes";
import customReducers from './redux/reducers';

const App = () => {
return (
Expand All @@ -23,6 +24,7 @@ const App = () => {
authProvider={AuthProvider}
dashboard={Dashboard}
theme={theme}
customReducers={customReducers}
customRoutes={customRoutes}
>
<Resource name="users" {...profile} />
Expand Down
27 changes: 27 additions & 0 deletions pharmd-app/src/components/Basic/BasicTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import tw, { styled } from "twin.macro";
import Chip from "@material-ui/core/Chip";

// ${props => props.theme.typography.size4}
const Pill = styled(Chip)`

${tw`rounded-lg capitalize w-16 fontStyle-4 text-xs font-bold tracking-wider`}
margin: 3px;
color: ${props => props.color};
background-color: #b5c7f8;
`;

const Field = styled.a`
${tw`p-0`}
`;

const BasicTag = ({ text, color }) => {
const tagColor = color || '#f2994a'
return (
<Field>
<Pill label={text} color={tagColor} />
</Field>
);
};

export default BasicTag;
6 changes: 6 additions & 0 deletions pharmd-app/src/components/Basic/NoteIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const SVG = styled(SvgIcon)`
color: black;
`}

${props =>
props.color === "red" &&
css`
color: red;
`}

${props =>
props.primary &&
css`
Expand Down
78 changes: 78 additions & 0 deletions pharmd-app/src/components/Fields/NoteBoxField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React from 'react'
import tw, { styled } from "twin.macro";
import MuiPaper from "@material-ui/core/Paper";
import {NOTE} from "../../constants/apiObjects";
import CardHeader from "@material-ui/core/CardHeader";
import CardContent from "@material-ui/core/CardContent";
import BasicTag from "../Basic/BasicTag";
import {DeleteButton} from 'react-admin';

const CardRoot = styled.div`
flex-grow: 1;
margin: 15px;
`

const Paper = styled(MuiPaper)`
${tw`rounded-xl h-64 w-56 shadow-cardLight`}
padding: 7px;
margin: auto;

`;

const Tags = styled.div`
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-around;
`

const MAX_TITLE_LENGTH = 25;
const MAX_BODY_LENGTH = 30;

const NoteBoxField = ({ record, studentId, onDelete }) => {
const id = record[NOTE.ID];
const title = record[NOTE.TITLE];
const body = record[NOTE.BODY];
const tags = record[NOTE.TAGS];
const date = new Date(record[NOTE.DATE]).toLocaleDateString();

function truncate(str, n){
return (str.length > n) ? str.substr(0, n-1) + '…' : str;
}

return (
<CardRoot>
<Paper>

<CardHeader
action={
<div>
<DeleteButton label="" onClick={onDelete} basePath={`/students/${studentId}/details`} record={record} resource="notes" />
</div>
}
title={truncate(title, MAX_TITLE_LENGTH)}
subheader={date}
/>
<CardContent>
<p>
{truncate(body, MAX_BODY_LENGTH)}
</p>
<Tags>
{tags.map((tag, ind) => {
if (ind < 2) {
return <BasicTag text={tag}/>;
} else {
const more = `${tags.length - 2} more`
return <BasicTag text={more} />
}

})}
</Tags>

</CardContent>
</Paper>
</CardRoot>
)
}

export default NoteBoxField;
23 changes: 19 additions & 4 deletions pharmd-app/src/components/Fields/NoteListField.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from "react";
import { Error, Loading, useQuery } from "react-admin";
import { useDispatch } from "react-redux";
import { setNotesModal } from "../../redux/actions";
import { useQuery, Loading, Error } from "react-admin";
import tw, { styled } from "twin.macro";
import NoteField from "./NoteField";
import IconButton from "@material-ui/core/IconButton";
import AddCircleOutlineOutlinedIcon from '@material-ui/icons/AddCircleOutlineOutlined';
import NoteIcon from "../Basic/NoteIcon";

const Label = styled.h1`
${tw`fontStyle-6 font-medium inline-flex`}
Expand Down Expand Up @@ -32,16 +37,26 @@ const NoteListField = ({ record = {}, source }) => {
}
});

const dispatch = useDispatch();

function addNote() {
dispatch(setNotesModal({ isOpen: true }))
}

if (loading) return <Loading />;
if (error) return <Error />;
if (!data) return null;

return (
<Notes>
<Label>Recent Notes</Label>
{data.map(note => {
return <NoteField source="id" record={note} />;
})}
<IconButton onClick={addNote}>
<NoteIcon src={AddCircleOutlineOutlinedIcon} size="small" isPrimary="primary" />
</IconButton>
{data.map((note, ind) => {
return <NoteField source='id' record={note} key={ind}/>
})
}
</Notes>
);
};
Expand Down
22 changes: 22 additions & 0 deletions pharmd-app/src/components/Layout/NoteCreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { Create, TextInput, SimpleForm, required } from 'react-admin';

const NoteCreate = props => {
// Input --> Record
const parseInput = input => input && input.split(" ")

// Record --> Input
const formatInput = record => record && record.join(" ")

return (
<Create {...props} resource="notes" onSuccess={props.onSuccess} basePath="notes">
<SimpleForm initialValues={ {student: props.match.params.id} }>
<TextInput label="Note Title" source="title" validate={required()} />
<TextInput label="Note Content" source="body" validate={required()} />
<TextInput label="Tags" source="tags" validate={required()} format={formatInput} parse={parseInput} />
</SimpleForm>
</Create>
)
}

export default NoteCreate;
54 changes: 54 additions & 0 deletions pharmd-app/src/components/Layout/PharmDModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import Modal from '@material-ui/core/Modal';
import { styled } from "twin.macro";
import PropTypes from "prop-types";

const ModalFrame = styled(Modal)`
margin-top: 10%;
margin-bottom: 10%;
margin-left: 15%;
margin-right: 15%;

`

const InnerModal = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
color: ${props => props.theme.palette.primary.main};
background-color: white;
padding: 20px;
`

const PharmDModal = props => {

return (
<ModalFrame open={props.open}
onBackdropClick={props.onClose}
aria-labelledby={props.title}
aria-describedby="PharmD Modal View"
>
<InnerModal>
{typeof props.title === "string" ?
<h2>{props.title}</h2>
: props.title
}
{props.children}
</InnerModal>
</ModalFrame>
)
}

PharmDModal.propTypes = {
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
open: PropTypes.bool,
onClose: PropTypes.func,
}

PharmDModal.defaultProps = {
title: "",
open: false,
onClose: null
}

export default PharmDModal;
5 changes: 5 additions & 0 deletions pharmd-app/src/redux/actions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { UI_NOTES_MODAL } from "../constants/action-types";

export function setNotesModal(payload) {
return { type: UI_NOTES_MODAL, payload}
}
1 change: 1 addition & 0 deletions pharmd-app/src/redux/constants/action-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const UI_NOTES_MODAL = "UI_MODAL";
7 changes: 7 additions & 0 deletions pharmd-app/src/redux/reducers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import studentSideBarReducer from "./studentSideBarReducer";
import notesModalReducer from "./notesModalReducer";

export default {
studentSidebarOpen: studentSideBarReducer,
notesModalOpen: notesModalReducer
}
8 changes: 8 additions & 0 deletions pharmd-app/src/redux/reducers/notesModalReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { UI_NOTES_MODAL} from "../constants/action-types";

export default (previousState = [false, () => {}], {type, payload}) => {
if (type === UI_NOTES_MODAL) {
return [payload.isOpen, payload.onClose]
}
return previousState;
}
Loading