Skip to content

Commit

Permalink
AB#1064 fixes and test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco del Castillo committed Nov 11, 2024
1 parent c5a3a92 commit edaf108
Show file tree
Hide file tree
Showing 40 changed files with 1,190 additions and 108 deletions.
8 changes: 6 additions & 2 deletions client/src/components/EventCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const EventCollection = ({
mapId,
width,
height,
marginBottom
marginBottom,
showEventSeries
}) => {
const [viewFormat, setViewFormat] = useState(viewFormats[0])
const showHeader = viewFormats.length > 1
Expand Down Expand Up @@ -87,6 +88,7 @@ const EventCollection = ({
setPagination={setPagination}
queryParams={queryParams}
setTotalCount={setTotalCount}
showEventSeries={showEventSeries}
/>
)}
{viewFormat === FORMAT_SUMMARY && (
Expand All @@ -97,6 +99,7 @@ const EventCollection = ({
setPagination={setPagination}
queryParams={queryParams}
setTotalCount={setTotalCount}
showEventSeries={showEventSeries}
/>
)}
{viewFormat === FORMAT_CALENDAR && (
Expand Down Expand Up @@ -144,7 +147,8 @@ EventCollection.propTypes = {
mapId: PropTypes.string,
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
marginBottom: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
marginBottom: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
showEventSeries: PropTypes.bool
}

EventCollection.defaultProps = {
Expand Down
21 changes: 14 additions & 7 deletions client/src/components/EventSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const EventSummary = ({
setTotalCount,
paginationKey,
pagination,
setPagination
setPagination,
showEventSeries
}) => {
// (Re)set pageNum to 0 if the queryParams change, and make sure we retrieve page 0 in that case
const latestQueryParams = useRef(queryParams)
Expand Down Expand Up @@ -80,7 +81,11 @@ const EventSummary = ({
goToPage={setPage}
>
{events.map(event => (
<EventSummaryRow event={event} key={event.uuid} />
<EventSummaryRow
event={event}
key={event.uuid}
showEventSeries={showEventSeries}
/>
))}
</UltimatePaginationTopDown>
</div>
Expand All @@ -98,14 +103,15 @@ EventSummary.propTypes = {
setTotalCount: PropTypes.func,
paginationKey: PropTypes.string.isRequired,
setPagination: PropTypes.func.isRequired,
pagination: PropTypes.object.isRequired
pagination: PropTypes.object.isRequired,
showEventSeries: PropTypes.bool
}

const EventSummaryRow = ({ event }) => {
const EventSummaryRow = ({ event, showEventSeries }) => {
event = new Event(event)

return (
<Container fluid className="report-summary">
<Container fluid className="event-summary">
<Row>
<Col md={12}>
<span>
Expand Down Expand Up @@ -158,7 +164,7 @@ const EventSummaryRow = ({ event }) => {
</Col>
</Row>
)}
{!_isEmpty(event.eventSeries) && (
{showEventSeries && !_isEmpty(event.eventSeries) && (
<Row>
<Col md={12}>
<span>
Expand Down Expand Up @@ -259,7 +265,8 @@ const EventSummaryRow = ({ event }) => {
}

EventSummaryRow.propTypes = {
event: PropTypes.object.isRequired
event: PropTypes.object.isRequired,
showEventSeries: PropTypes.bool
}

export default EventSummary
16 changes: 10 additions & 6 deletions client/src/components/EventTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const BaseEventTable = ({
pageSize,
pageNum,
totalCount,
goToPage
goToPage,
showEventSeries
}) => {
if (_get(events, "length", 0) === 0) {
return <em>{noEventsMessage}</em>
Expand All @@ -92,7 +93,7 @@ const BaseEventTable = ({
<thead>
<tr>
<th>Name</th>
<th>Series</th>
{showEventSeries && <th>Series</th>}
<th>Host Organization</th>
<th>Location</th>
<th>Start Date</th>
Expand All @@ -105,9 +106,11 @@ const BaseEventTable = ({
<td>
<LinkTo modelType="Event" model={event} />
</td>
<td>
<LinkTo modelType="EventSeries" model={event.eventSeries} />
</td>
{showEventSeries && (
<td>
<LinkTo modelType="EventSeries" model={event.eventSeries} />
</td>
)}
<td>
<LinkTo modelType="Organization" model={event.hostOrg} />
</td>
Expand Down Expand Up @@ -138,7 +141,8 @@ BaseEventTable.propTypes = {
totalCount: PropTypes.number,
pageNum: PropTypes.number,
pageSize: PropTypes.number,
goToPage: PropTypes.func
goToPage: PropTypes.func,
showEventSeries: PropTypes.bool
}

BaseEventTable.defaultProps = {
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/NoPaginationOrganizationTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const NoPaginationOrganizationTable = ({
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Location</th>
{showDelete && <th />}
</tr>
Expand All @@ -34,7 +33,6 @@ const NoPaginationOrganizationTable = ({
<td>
<LinkTo modelType="Organization" model={organization} />
</td>
<td>{organization.description}</td>
<td>
<LinkTo
modelType="Location"
Expand Down
13 changes: 13 additions & 0 deletions client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -1278,4 +1278,17 @@ table.event-matrix-cell {
.form-horizontal .form-label {
text-align: left;
}
.event-collection header {
margin-bottom: 18px;
}

.event-collection footer {
margin-top: 18px;
}

.event-summary {
margin-top: 25px;
padding-top: 15px;
box-shadow: 0 1px 3px hsla(0, 0%, 0%, 0.15);
}
}
2 changes: 1 addition & 1 deletion client/src/models/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class Event extends Model {
.default(() => Model.STATUS.ACTIVE),
type: yup.string().required().default(""),
name: yup.string().required().default(""),
description: yup.string().required().default(""),
description: yup.string().default(""),
startDate: yupDate.required().default(null),
endDate: yupDate.required().default(null),
outcomes: yup.string().default(""),
Expand Down
2 changes: 1 addition & 1 deletion client/src/models/EventSeries.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class EventSeries extends Model {
.required()
.default(() => Model.STATUS.ACTIVE),
name: yup.string().required().default(""),
description: yup.string().required().default(""),
description: yup.string().default(""),
hostOrg: yup
.object()
.test("hostOrg", "host org error", (hostOrg, testContext) =>
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/eventSeries/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const EventSeriesForm = ({ edit, title, initialValues, notesComponent }) => {
const organizationFilters = {
allOrganizations: {
label: "All organizations",
queryVars: {}
queryVars: { status: Model.STATUS.ACTIVE }
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/eventSeries/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const EventSeriesShow = ({ pageDispatchers }) => {
</Fieldset>
<Fieldset
title={Settings.fields.eventSeries.description?.label}
id="report-text"
id="description"
>
<RichTextEditor readOnly value={eventSeries.description} />
</Fieldset>
Expand Down
31 changes: 19 additions & 12 deletions client/src/pages/events/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ const EventForm = ({ edit, title, initialValues, notesComponent }) => {
...orgsAdministratedUuids
]
}

const currentOrg =
currentUser.position && currentUser.position.organization

const locationFilters = Location.getReportLocationFilters()

const action = (
Expand All @@ -128,7 +124,7 @@ const EventForm = ({ edit, title, initialValues, notesComponent }) => {
const organizationFilters = {
allOrganizations: {
label: "All organizations",
queryVars: {}
queryVars: { status: Model.STATUS.ACTIVE }
}
}

Expand All @@ -152,20 +148,31 @@ const EventForm = ({ edit, title, initialValues, notesComponent }) => {

const tasksFilters = {}

if (currentOrg) {
tasksFilters.assignedToMyOrg = {
label: `Assigned to ${currentOrg.shortName}`,
tasksFilters.allTasks = {
label: `All ${tasksLabel}`,
queryVars: { selectable: true }
}

if (values.hostOrg) {
tasksFilters.assignedToHostOrg = {
label: `Assigned to ${values.hostOrg.shortName}`,
queryVars: {
taskedOrgUuid: currentOrg.uuid,
taskedOrgUuid: values.hostOrg.uuid,
orgRecurseStrategy: RECURSE_STRATEGY.PARENTS,
selectable: true
}
}
}

tasksFilters.allUnassignedTasks = {
label: `All unassigned ${tasksLabel}`,
queryVars: { selectable: true, isAssigned: false }
if (values.adminOrg && values.adminOrg.uuid !== values.hostOrg?.uuid) {
tasksFilters.assignedToAdminOrg = {
label: `Assigned to ${values.adminOrg.shortName}`,
queryVars: {
taskedOrgUuid: values.adminOrg.uuid,
orgRecurseStrategy: RECURSE_STRATEGY.PARENTS,
selectable: true
}
}
}

return (
Expand Down
5 changes: 3 additions & 2 deletions client/src/pages/events/MyEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const MyEvents = ({ pageDispatchers, searchQuery }) => {

function renderEventSeriesSection() {
return (
<Fieldset title="Event Series" id="event-series">
<Fieldset title="Event Series" id="my-event-series">
<EventSeriesCollection
paginationKey={`e_eventSeries_${currentUser.uuid}`}
queryParams={eventSearchQueryParams}
Expand All @@ -76,11 +76,12 @@ const MyEvents = ({ pageDispatchers, searchQuery }) => {

function renderEventsSection() {
return (
<Fieldset title="Events" id="events">
<Fieldset title="Events" id="my-events">
<EventCollection
paginationKey={`e_event_${currentUser.uuid}`}
queryParams={eventSearchQueryParams}
mapId="event"
showEventSeries
/>
</Fieldset>
)
Expand Down
14 changes: 9 additions & 5 deletions client/src/pages/events/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import React, { useContext, useState } from "react"
import { connect } from "react-redux"
import { useLocation, useParams } from "react-router-dom"
import Settings from "settings"
import { FORMAT_TABLE } from "../../components/ReportCollection"

const EventShow = ({ pageDispatchers }) => {
const { currentUser } = useContext(AppContext)
Expand Down Expand Up @@ -200,7 +201,7 @@ const EventShow = ({ pageDispatchers }) => {
</Fieldset>
<Fieldset
title={Settings.fields.event.description?.label}
id="report-text"
id="description"
>
<RichTextEditor readOnly value={event.description} />
</Fieldset>
Expand All @@ -226,11 +227,13 @@ const EventShow = ({ pageDispatchers }) => {
</Fieldset>
)}
{event.tasks.length > 0 && (
<Fieldset title={Settings.fields.task.longLabel}>
<Fieldset
id="eventTasks"
title={Settings.fields.task.longLabel}
>
<NoPaginationTaskTable
id="events-tasks"
tasks={values.tasks}
showOrganization
showDescription
noTasksMessage={`No ${tasksLabel} selected; click in the ${tasksLabel} box to view your organization's ${tasksLabel}`}
/>
Expand All @@ -239,13 +242,13 @@ const EventShow = ({ pageDispatchers }) => {
{event.outcomes && (
<Fieldset
title={Settings.fields.event.outcomes?.label}
id="report-text"
id="outcomes"
>
<RichTextEditor readOnly value={event.outcomes} />
</Fieldset>
)}
<Fieldset
id="reports"
id="eventReports"
title={`Reports for ${event.name}`}
action={
<LinkTo
Expand All @@ -263,6 +266,7 @@ const EventShow = ({ pageDispatchers }) => {
paginationKey={`r_${uuid}`}
queryParams={reportQueryParams}
mapId="reports"
viewFormats={[FORMAT_TABLE]}
/>
</Fieldset>
</Form>
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/locations/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ const LocationShow = ({ pageDispatchers }) => {
paginationKey={`e_${uuid}`}
queryParams={{ locationUuid: uuid }}
mapId="events"
showEventSeries
/>
</Fieldset>
</div>
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/organizations/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ const OrganizationShow = ({ pageDispatchers }) => {
paginationKey={`e_${uuid}`}
queryParams={eventQueryParams}
mapId="events"
showEventSeries
/>
</Fieldset>
<Fieldset
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/searches/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ const Events = ({
pageNum={curPage}
totalCount={totalCount}
goToPage={setPage}
showEventSeries
id="events-search-results"
/>
)
Expand Down
Loading

0 comments on commit edaf108

Please sign in to comment.