Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event and event series entities #4868

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 60 additions & 0 deletions anet-dictionary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SUPPORT_EMAIL_ADDR: support@example.com

regularUsersCanCreateLocations: true
engagementsIncludeTimeAndDuration: true
eventsIncludeStartAndEndTime: true

calendarOptions:
attendeesType: advisor
Expand Down Expand Up @@ -359,6 +360,61 @@ fields:
authorizationGroupRelatedObjects:
label: Members

eventSeries:
hostOrg:
label: Host Organization
placeholder: Search for the organization hosting the event series...
adminOrg:
label: Admin Organization
placeholder: Search for the organization that will manage the event series in ANET...
name:
label: Name
placeholder: The name of the event series
description:
label: Description
placeholder: The description of the event series

event:
eventSeries:
label: Event Series this event belongs to
placeholder: Search for an event series
hostOrg:
label: Host Organization
placeholder: Search for the organization hosting the event...
adminOrg:
label: Admin Organization
placeholder: Search for the organization that will manage the event in ANET...
location:
label: Location where the event takes place
placeholder: Search for a location…
type:
label: Type
placeholder: The type of the event
name:
label: Name
placeholder: The name of the event
description:
label: Description
placeholder: The description of the event
startDate:
label: Start Date
placeholder: The start date of the event
endDate:
label: End Date
placeholder: The end date of the event
outcomes:
label: Outcomes
placeholder: The outcomes of the event
organizations:
label: Organizations attending
placeholder: Organizations attending the event
people:
label: People attending
placeholder: People attending the event
tasks:
label: Objectives
placeholder: Objectives of the event

report:
canUnpublishReports: true
intent:
Expand Down Expand Up @@ -406,6 +462,10 @@ fields:
- label: Linguists
filter:
orgUuid: 70193ee9-05b4-4aac-80b5-75609825db9f
event:
label: Event
placeholder: Was the engagement part of an event?
filter: [CONFERENCE, EXERCISE, VISIT_BAN, OTHER]
customFields:
gridLocation:
type: geo_location
Expand Down
9 changes: 6 additions & 3 deletions client/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const SEARCH_OBJECT_TYPES = {
LOCATIONS: "LOCATIONS",
TASKS: "TASKS",
AUTHORIZATION_GROUPS: "AUTHORIZATION_GROUPS",
ATTACHMENTS: "ATTACHMENTS"
ATTACHMENTS: "ATTACHMENTS",
EVENTS: "EVENTS"
}

export const SEARCH_OBJECT_LABELS = {
Expand All @@ -36,7 +37,8 @@ export const SEARCH_OBJECT_LABELS = {
[SEARCH_OBJECT_TYPES.LOCATIONS]: "Locations",
[SEARCH_OBJECT_TYPES.TASKS]: pluralize(Settings.fields.task.shortLabel),
[SEARCH_OBJECT_TYPES.AUTHORIZATION_GROUPS]: "Authorization Groups",
[SEARCH_OBJECT_TYPES.ATTACHMENTS]: "Attachments"
[SEARCH_OBJECT_TYPES.ATTACHMENTS]: "Attachments",
[SEARCH_OBJECT_TYPES.EVENTS]: "Events"
}

export const DEFAULT_SEARCH_PROPS = {
Expand All @@ -49,7 +51,8 @@ export const DEFAULT_SEARCH_PROPS = {
SEARCH_OBJECT_TYPES.LOCATIONS,
SEARCH_OBJECT_TYPES.TASKS,
SEARCH_OBJECT_TYPES.AUTHORIZATION_GROUPS,
SEARCH_OBJECT_TYPES.ATTACHMENTS
SEARCH_OBJECT_TYPES.ATTACHMENTS,
SEARCH_OBJECT_TYPES.EVENTS
]
}
export const DEFAULT_SEARCH_QUERY = {
Expand Down
8 changes: 7 additions & 1 deletion client/src/components/CreateButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { useNavigate } from "react-router-dom"

const DEFAULT_ACTIONS = [Models.Report]

const SUPERUSER_ACTIONS = [Models.Person, Models.Position, Models.Location]
const SUPERUSER_ACTIONS = [
Models.Person,
Models.Position,
Models.Location,
Models.Event,
Models.EventSeries
]

const ADMIN_ACTIONS = [
Models.Organization,
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/CustomDateInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const CustomDateInput = ({
disabled,
showIcon,
maxDate,
minDate,
placement,
withTime,
value,
Expand Down Expand Up @@ -74,7 +75,7 @@ const CustomDateInput = ({
}}
placeholder={inputFormat}
maxDate={maxDate}
minDate={moment().subtract(100, "years").startOf("year").toDate()}
minDate={minDate}
canClearSelection={canClearSelection}
showActionsBar
closeOnSelection={!withTime}
Expand All @@ -92,6 +93,7 @@ CustomDateInput.propTypes = {
disabled: PropTypes.bool,
showIcon: PropTypes.bool,
maxDate: PropTypes.instanceOf(Date),
minDate: PropTypes.instanceOf(Date),
placement: PropTypes.string,
withTime: PropTypes.bool,
value: PropTypes.oneOfType([
Expand All @@ -107,6 +109,7 @@ CustomDateInput.defaultProps = {
disabled: false,
showIcon: true,
maxDate: moment().add(20, "years").endOf("year").toDate(),
minDate: moment().subtract(100, "years").startOf("year").toDate(),
placement: "auto",
withTime: false,
canClearSelection: false
Expand Down
74 changes: 74 additions & 0 deletions client/src/components/EventCalendar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import API from "api"
import { eventsToCalendarEvents } from "components/aggregations/utils"
import Calendar from "components/Calendar"
import Model from "components/Model"
import { PageDispatchersPropType } from "components/Page"
import _isEqual from "lodash/isEqual"
import { Event } from "models"
import moment from "moment"
import PropTypes from "prop-types"
import React, { useRef } from "react"
import { useNavigate } from "react-router-dom"

const EventCalendar = ({
pageDispatchers: { showLoading, hideLoading },
queryParams,
setTotalCount
}) => {
const navigate = useNavigate()
const prevEventQuery = useRef(null)
const apiPromise = useRef(null)
const calendarComponentRef = useRef(null)
return (
<Calendar
events={getEvents}
eventClick={info => {
navigate(info.event.url)
// Prevent browser navigation to the url
info.jsEvent.preventDefault()
}}
calendarComponentRef={calendarComponentRef}
/>
)

function getEvents(fetchInfo, successCallback, failureCallback) {
const eventQuery = Object.assign({}, queryParams, {
status: Model.STATUS.ACTIVE,
pageSize: 0,
startDate: moment(fetchInfo.start).startOf("day"),
endDate: moment(fetchInfo.end).endOf("day")
})
if (_isEqual(prevEventQuery.current, eventQuery)) {
// Optimise, return API promise instead of calling API.query again
return apiPromise.current
}
prevEventQuery.current = eventQuery
if (setTotalCount) {
// Reset the total count
setTotalCount(null)
}
// Store API promise to use in optimised case
showLoading()
apiPromise.current = API.query(Event.getEventListQuery, {
eventQuery
}).then(data => {
const events = data ? data.eventList.list : []
if (setTotalCount) {
const { totalCount } = data.eventList
setTotalCount(totalCount)
}
const results = eventsToCalendarEvents(events)
hideLoading()
return results
})
return apiPromise.current
}
}

EventCalendar.propTypes = {
pageDispatchers: PageDispatchersPropType,
queryParams: PropTypes.object,
setTotalCount: PropTypes.func
}

export default EventCalendar
Loading
Loading