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 authored and gjvoosten committed Nov 26, 2024
1 parent bb5e5ad commit 8349397
Show file tree
Hide file tree
Showing 40 changed files with 1,186 additions and 104 deletions.
6 changes: 5 additions & 1 deletion client/src/components/EventCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface EventCollectionProps {
width?: number | string
height?: number | string
marginBottom?: number | string
showEventSeries?: boolean
}

const EventCollection = ({
Expand All @@ -50,7 +51,8 @@ const EventCollection = ({
mapId,
width,
height,
marginBottom
marginBottom,
showEventSeries
}: EventCollectionProps) => {
const [viewFormat, setViewFormat] = useState(viewFormats[0])
const showHeader = viewFormats.length > 1
Expand Down Expand Up @@ -106,6 +108,7 @@ const EventCollection = ({
setPagination={setPagination}
queryParams={queryParams}
setTotalCount={setTotalCount}
showEventSeries={showEventSeries}
/>
)}
{viewFormat === FORMAT_SUMMARY && (
Expand All @@ -116,6 +119,7 @@ const EventCollection = ({
setPagination={setPagination}
queryParams={queryParams}
setTotalCount={setTotalCount}
showEventSeries={showEventSeries}
/>
)}
{viewFormat === FORMAT_CALENDAR && (
Expand Down
17 changes: 12 additions & 5 deletions client/src/components/EventSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface EventSummaryProps {
paginationKey: string
setPagination: (...args: unknown[]) => unknown
pagination: any
showEventSeries?: boolean
}

const EventSummary = ({
Expand All @@ -32,7 +33,8 @@ const EventSummary = ({
setTotalCount,
paginationKey,
pagination,
setPagination
setPagination,
showEventSeries
}: EventSummaryProps) => {
// (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 @@ -88,7 +90,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 @@ -102,13 +108,14 @@ const EventSummary = ({

interface EventSummaryRowProps {
event: any
showEventSeries?: boolean
}

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

return (
<Container fluid className="report-summary">
<Container fluid className="event-summary">
<Row>
<Col md={12}>
<span>
Expand Down Expand Up @@ -161,7 +168,7 @@ const EventSummaryRow = ({ event }: EventSummaryRowProps) => {
</Col>
</Row>
)}
{!_isEmpty(event.eventSeries) && (
{showEventSeries && !_isEmpty(event.eventSeries) && (
<Row>
<Col md={12}>
<span>
Expand Down
14 changes: 9 additions & 5 deletions client/src/components/EventTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interface BaseEventTableProps {
pageNum?: number
pageSize?: number
goToPage?: (...args: unknown[]) => unknown
showEventSeries?: boolean
}

const BaseEventTable = ({
Expand All @@ -87,7 +88,8 @@ const BaseEventTable = ({
pageSize,
pageNum,
totalCount,
goToPage
goToPage,
showEventSeries
}: BaseEventTableProps) => {
if (_get(events, "length", 0) === 0) {
return <em>{noEventsMessage}</em>
Expand All @@ -107,7 +109,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 @@ -120,9 +122,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
2 changes: 0 additions & 2 deletions client/src/components/NoPaginationOrganizationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const NoPaginationOrganizationTable = ({
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Location</th>
{showDelete && <th />}
</tr>
Expand All @@ -41,7 +40,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.ts
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.ts
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.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const EventSeriesForm = ({
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.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const EventSeriesShow = ({ pageDispatchers }: EventSeriesShowProps) => {
</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.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ const EventForm = ({
...orgsAdministratedUuids
]
}

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

const locationFilters = Location.getReportLocationFilters()

const action = (
Expand All @@ -139,7 +135,7 @@ const EventForm = ({
const organizationFilters = {
allOrganizations: {
label: "All organizations",
queryVars: {}
queryVars: { status: Model.STATUS.ACTIVE }
}
}

Expand All @@ -163,20 +159,31 @@ const EventForm = ({

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.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const MyEvents = ({ pageDispatchers, searchQuery }: MyEventsProps) => {

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 @@ -81,11 +81,12 @@ const MyEvents = ({ pageDispatchers, searchQuery }: MyEventsProps) => {

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.tsx
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"

interface EventShowProps {
pageDispatchers?: PageDispatchersPropType
Expand Down Expand Up @@ -204,7 +205,7 @@ const EventShow = ({ pageDispatchers }: EventShowProps) => {
</Fieldset>
<Fieldset
title={Settings.fields.event.description?.label}
id="report-text"
id="description"
>
<RichTextEditor readOnly value={event.description} />
</Fieldset>
Expand All @@ -230,11 +231,13 @@ const EventShow = ({ pageDispatchers }: EventShowProps) => {
</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 @@ -243,13 +246,13 @@ const EventShow = ({ pageDispatchers }: EventShowProps) => {
{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 @@ -267,6 +270,7 @@ const EventShow = ({ pageDispatchers }: EventShowProps) => {
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.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ const LocationShow = ({ pageDispatchers }: LocationShowProps) => {
paginationKey={`e_${uuid}`}
queryParams={{ locationUuid: uuid }}
mapId="events"
showEventSeries
/>
</Fieldset>
</div>
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/organizations/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ const OrganizationShow = ({ pageDispatchers }: OrganizationShowProps) => {
paginationKey={`e_${uuid}`}
queryParams={eventQueryParams}
mapId="events"
showEventSeries
/>
</Fieldset>
<Fieldset
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/searches/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ const Events = ({
pageNum={curPage}
totalCount={totalCount}
goToPage={setPage}
showEventSeries
id="events-search-results"
/>
)
Expand Down
Loading

0 comments on commit 8349397

Please sign in to comment.