Skip to content

Commit

Permalink
AB#1064 Add owner organization to EventSeries/Event
Browse files Browse the repository at this point in the history
  • Loading branch information
gjvoosten committed Jan 23, 2025
1 parent 6c2a37c commit b9c47bb
Show file tree
Hide file tree
Showing 41 changed files with 507 additions and 123 deletions.
6 changes: 6 additions & 0 deletions anet-dictionary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ fields:
adminOrg:
label: Admin Organization
placeholder: Search for the organization that will manage the event series in ANET…
ownerOrg:
label: Owner Organization
placeholder: Search for the organization that owns the event series…
name:
label: Name
placeholder: The name of the event series
Expand All @@ -388,6 +391,9 @@ fields:
adminOrg:
label: Admin Organization
placeholder: Search for the organization that will manage the event in ANET…
ownerOrg:
label: Owner Organization
placeholder: Search for the organization that owns the event…
location:
label: Location where the event takes place
placeholder: Search for a location…
Expand Down
21 changes: 18 additions & 3 deletions client/src/components/EventSeriesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { EventSeries } from "models"
import React, { useState } from "react"
import { Table } from "react-bootstrap"
import { connect } from "react-redux"
import Settings from "settings"

const GQL_GET_EVENTSERIES_LIST = gql`
query ($eventSeriesQuery: EventSeriesSearchQueryInput) {
Expand All @@ -37,6 +38,13 @@ const GQL_GET_EVENTSERIES_LIST = gql`
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
ownerOrg {
uuid
shortName
longName
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
}
}
}
Expand Down Expand Up @@ -86,9 +94,10 @@ const EventSeriesTable = ({
<Table striped hover responsive>
<thead>
<tr>
<th>Name</th>
<th>Host Organization</th>
<th>Admin Organization</th>
<th>{Settings.fields.eventSeries.name.label}</th>
<th>{Settings.fields.eventSeries.hostOrg.label}</th>
<th>{Settings.fields.eventSeries.adminOrg.label}</th>
<th>{Settings.fields.eventSeries.ownerOrg.label}</th>
</tr>
</thead>
<tbody>
Expand All @@ -109,6 +118,12 @@ const EventSeriesTable = ({
model={eventSeries.adminOrg}
/>
</td>
<td>
<LinkTo
modelType="Organization"
model={eventSeries.ownerOrg}
/>
</td>
</tr>
))}
</tbody>
Expand Down
17 changes: 17 additions & 0 deletions client/src/components/EventSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ const GQL_GET_EVENT_LIST = gql`
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
ownerOrg {
uuid
shortName
longName
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
eventSeries {
uuid
name
Expand Down Expand Up @@ -209,6 +216,16 @@ const EventSummaryRow = ({ event, showEventSeries }: EventSummaryRowProps) => {
</Col>
</Row>
)}
{!_isEmpty(event.ownerOrg) && (
<Row>
<Col md={12}>
<span>
<strong>{Settings.fields.event.ownerOrg.label}: </strong>
<LinkTo modelType="Organization" model={event.ownerOrg} />
</span>
</Col>
</Row>
)}
{showEventSeries && !_isEmpty(event.eventSeries) && (
<Row>
<Col md={12}>
Expand Down
22 changes: 9 additions & 13 deletions client/src/components/EventTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import moment from "moment/moment"
import React, { useState } from "react"
import { Table } from "react-bootstrap"
import { connect } from "react-redux"
import Settings from "settings"

const GQL_GET_EVENT_LIST = gql`
query ($eventQuery: EventSearchQueryInput) {
Expand All @@ -34,13 +35,6 @@ const GQL_GET_EVENT_LIST = gql`
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
adminOrg {
uuid
shortName
longName
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
eventSeries {
uuid
name
Expand Down Expand Up @@ -151,12 +145,14 @@ const BaseEventTable = ({
<Table responsive hover striped id={id}>
<thead>
<tr>
<th>Name</th>
{showEventSeries && <th>Series</th>}
<th>Host Organization</th>
<th>Location</th>
<th>Start Date</th>
<th>End Date</th>
<th>{Settings.fields.event.name.label}</th>
{showEventSeries && (
<th>{Settings.fields.event.eventSeries.label}</th>
)}
<th>{Settings.fields.event.hostOrg.label}</th>
<th>{Settings.fields.event.location.label}</th>
<th>{Settings.fields.event.startDate.label}</th>
<th>{Settings.fields.event.endDate.label}</th>
</tr>
</thead>
<tbody>
Expand Down
19 changes: 13 additions & 6 deletions client/src/components/SearchFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ export const searchFilters = function(includeAdminFilters) {

filters[SEARCH_OBJECT_TYPES.EVENTS] = {
filters: {
"Event Type": {
[Settings.fields.event.type.label]: {
component: SelectFilter,
dictProps: Settings.fields.event.type,
deserializer: deserializeSelectFilter,
Expand All @@ -756,31 +756,38 @@ export const searchFilters = function(includeAdminFilters) {
labels: eventTypeOptions.map(lt => Event.humanNameOfType(lt))
}
},
"Event Series": {
[Settings.fields.event.eventSeries.label]: {
component: AdvancedSelectFilter,
deserializer: deserializeAdvancedSelectFilter,
props: {
...advancedSelectFilterEventSeriesProps,
filterDefs: eventSeriesFilters,
placeholder: "Filter by event series…",
placeholder: `Filter by ${Settings.fields.event.eventSeries.label}…`,
queryKey: "eventSeriesUuid"
}
},
"Within Host Organization": {
[`Within ${Settings.fields.event.hostOrg.label}`]: {
component: OrganizationMultiFilter,
deserializer: deserializeOrganizationMultiFilter,
props: {
queryKey: "hostOrgUuid"
}
},
"Within Admin Organization": {
[`Within ${Settings.fields.event.adminOrg.label}`]: {
component: OrganizationMultiFilter,
deserializer: deserializeOrganizationMultiFilter,
props: {
queryKey: "adminOrgUuid"
}
},
"Within Location": {
[`Within ${Settings.fields.event.ownerOrg.label}`]: {
component: OrganizationMultiFilter,
deserializer: deserializeOrganizationMultiFilter,
props: {
queryKey: "ownerOrgUuid"
}
},
[`Within ${Settings.fields.event.location.label}`]: {
component: LocationMultiFilter,
deserializer: deserializeLocationMultiFilter,
props: {
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/previews/EventPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const EventPreview = ({ className, uuid }: EventPreviewProps) => {
dictProps={Settings.fields.event.adminOrg}
value={<LinkTo modelType="Organization" model={event.adminOrg} />}
/>
<DictionaryField
wrappedComponent={PreviewField}
dictProps={Settings.fields.event.ownerOrg}
value={<LinkTo modelType="Organization" model={event.ownerOrg} />}
/>
<DictionaryField
wrappedComponent={PreviewField}
dictProps={Settings.fields.event.location}
Expand Down
7 changes: 7 additions & 0 deletions client/src/components/previews/EventSeriesPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ const EventSeriesPreview = ({ className, uuid }: EventSeriesPreviewProps) => {
<LinkTo modelType="Organization" model={eventSeries.adminOrg} />
}
/>
<DictionaryField
wrappedComponent={PreviewField}
dictProps={Settings.fields.eventSeries.ownerOrg}
value={
<LinkTo modelType="Organization" model={eventSeries.ownerOrg} />
}
/>
<DictionaryField
wrappedComponent={PreviewField}
dictProps={Settings.fields.eventSeries.status}
Expand Down
6 changes: 6 additions & 0 deletions client/src/exportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ const GQL_GET_EVENT_LIST = gql`
longName
identificationCode
}
ownerOrg {
uuid
shortName
longName
identificationCode
}
eventSeries {
uuid
name
Expand Down
8 changes: 8 additions & 0 deletions client/src/models/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class Event extends Model {
)
.default({}),
adminOrg: yup.object().nullable().default(null),
ownerOrg: yup.object().nullable().default(null),
eventSeries: yup.object().nullable().default({}),
location: yup.object().nullable().default({}),
tasks: yup.array().nullable().default([]),
Expand Down Expand Up @@ -93,6 +94,13 @@ export default class Event extends Model {
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
ownerOrg {
uuid
shortName
longName
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
eventSeries {
uuid
name
Expand Down
17 changes: 16 additions & 1 deletion client/src/models/EventSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default class EventSeries extends Model {
: true
)
.default({}),
adminOrg: yup.object().nullable().default(null)
adminOrg: yup.object().nullable().default(null),
ownerOrg: yup.object().nullable().default(null)
})

static autocompleteQuery = `
Expand All @@ -55,6 +56,13 @@ export default class EventSeries extends Model {
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
ownerOrg {
uuid
shortName
longName
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
`

static getEventSeriesQuery = gql`
Expand All @@ -79,6 +87,13 @@ export default class EventSeries extends Model {
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
ownerOrg {
uuid
shortName
longName
identificationCode
${GRAPHQL_ENTITY_AVATAR_FIELDS}
}
}
}
`
Expand Down
30 changes: 30 additions & 0 deletions client/src/pages/eventSeries/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const EventSeriesForm = ({
const isAdmin = currentUser?.isAdmin()
const hostOrgSearchQuery = { status: Model.STATUS.ACTIVE }
const adminOrgSearchQuery = { status: Model.STATUS.ACTIVE }
const ownerOrgSearchQuery = { status: Model.STATUS.ACTIVE }
// Superusers can select parent organizations among the ones their position is administrating
if (!isAdmin) {
const orgsAdministratedUuids =
Expand Down Expand Up @@ -178,6 +179,34 @@ const EventSeriesForm = ({
/>
}
/>
<DictionaryField
wrappedComponent={Field}
dictProps={Settings.fields.eventSeries.ownerOrg}
name="ownerOrg"
component={FieldHelper.SpecialField}
onChange={value => {
// validation will be done by setFieldValue
setFieldTouched("ownerOrg", true, false) // onBlur doesn't work when selecting an option
setFieldValue("ownerOrg", value)
}}
widget={
<AdvancedSingleSelect
fieldName="ownerOrg"
placeholder={
Settings.fields.eventSeries.ownerOrg.placeholder
}
value={values.ownerOrg}
overlayColumns={["Name"]}
overlayRenderRow={OrganizationOverlayRow}
filterDefs={organizationFilters}
objectType={Organization}
fields={Organization.autocompleteQuery}
queryParams={ownerOrgSearchQuery}
valueKey="shortName"
addon={ORGANIZATIONS_ICON}
/>
}
/>
<DictionaryField
wrappedComponent={FastField}
dictProps={Settings.fields.eventSeries.status}
Expand Down Expand Up @@ -275,6 +304,7 @@ const EventSeriesForm = ({
// strip tasks fields not in data model
eventSeries.hostOrg = utils.getReference(eventSeries.hostOrg)
eventSeries.adminOrg = utils.getReference(eventSeries.adminOrg)
eventSeries.ownerOrg = utils.getReference(eventSeries.ownerOrg)
return API.mutation(
edit ? GQL_UPDATE_EVENTSERIES : GQL_CREATE_EVENTSERIES,
{ eventSeries }
Expand Down
14 changes: 14 additions & 0 deletions client/src/pages/eventSeries/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ const EventSeriesShow = ({ pageDispatchers }: EventSeriesShowProps) => {
)
}
/>
<DictionaryField
wrappedComponent={Field}
dictProps={Settings.fields.eventSeries.ownerOrg}
name="ownerOrg"
component={FieldHelper.ReadonlyField}
humanValue={
eventSeries.ownerOrg && (
<LinkTo
modelType="Organization"
model={eventSeries.ownerOrg}
/>
)
}
/>
<DictionaryField
wrappedComponent={Field}
dictProps={Settings.fields.eventSeries.status}
Expand Down
Loading

0 comments on commit b9c47bb

Please sign in to comment.