Skip to content

Commit

Permalink
Add new columns and filters for created and modified fields
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Castillo <[email protected]>
  • Loading branch information
tomrndom committed Jun 19, 2024
1 parent 9d01672 commit c6d40f9
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 29 deletions.
20 changes: 20 additions & 0 deletions src/actions/event-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,26 @@ const parseFilters = (filters, term = null) => {
}
}

if (filters.created_filter && filters.created_filter.some(e => e !== null)) {
if(filters.created_filter.every(e => e !== null )) {
// between
filter.push(`created[]${filters.created_filter[0]}&&${filters.created_filter[1]}`);
} else {
filter.push(`${filters.created_filter[0] !== null ? `created>=${filters.created_filter[0]}` : ``}
${filters.created_filter[1] !== null ? `created<=${filters.created_filter[1]}` : ``}`);
}
}

if (filters.modified_filter && filters.modified_filter.some(e => e !== null)) {
if(filters.modified_filter.every(e => e !== null )) {
// between
filter.push(`last_edited[]${filters.modified_filter[0]}&&${filters.modified_filter[1]}`);
} else {
filter.push(`${filters.modified_filter[0] !== null ? `last_edited>=${filters.modified_filter[0]}` : ``}
${filters.modified_filter[1] !== null ? `last_edited<=${filters.modified_filter[1]}` : ``}`);
}
}

if (filters.duration_filter) {
// multiply values to send the minutes in seconds
if (Array.isArray(filters.duration_filter)) {
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,8 @@
"apply_filters": "Apply Filters",
"select_fields": "Show Columns",
"review_status": "Review Status",
"created": "Created",
"modified": "Modified",
"review_status_accepted": "Accepted",
"review_status_in_review": "In Review",
"review_status_no_submitted": "Not Submitted",
Expand Down Expand Up @@ -1054,6 +1056,10 @@
"start_date_to": "Filter Start Date to",
"end_date_from": "Filter End Date from",
"end_date_to": "Filter End Date to",
"created_from": "Filter Created Date from",
"created_to": "Filter Created Date to",
"modified_from": "Filter Modified Date from",
"modified_to": "Filter Modified Date to",
"select_fields": "Select data to display",
"submitters": "Filter by Submitter",
"submitter_company": "Filter by Submitter Company",
Expand Down
107 changes: 78 additions & 29 deletions src/pages/events/summit-event-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const fieldNames = [
{ columnKey: 'streaming_type', value: 'streaming_type', sortable: true },
{ columnKey: 'status', value: 'submission_status', sortable: false, title: true },
{ columnKey: 'progress_flags', value: 'progress_flags', sortable: true, title: true },
{ columnKey: 'created', value: 'created', sortable: true },
{ columnKey: 'modified', value: 'modified', sortable: true },
{ columnKey: 'media_uploads', value: 'media_uploads', sortable: false, render :(e, field) => {
if(!field?.length) return 'N/A';
return (<>{(e.media_uploads.map( m =>
Expand Down Expand Up @@ -101,6 +103,8 @@ const defaultFilters = {
tags_filter: [],
published_filter: null,
progress_flag: [],
created_filter: Array(2).fill(null),
modified_filter: Array(2).fill(null),
start_date_filter: Array(2).fill(null),
end_date_filter: Array(2).fill(null),
duration_filter: '',
Expand Down Expand Up @@ -138,8 +142,7 @@ class SummitEventListPage extends React.Component {
this.handleExtraFilterChange = this.handleExtraFilterChange.bind(this);
this.handleTagOrSpeakerFilterChange = this.handleTagOrSpeakerFilterChange.bind(this);
this.handleSetPublishedFilter = this.handleSetPublishedFilter.bind(this);
this.handleChangeStartDate = this.handleChangeStartDate.bind(this);
this.handleChangeEndDate = this.handleChangeEndDate.bind(this);
this.handleChangeDateFilter = this.handleChangeDateFilter.bind(this);
this.handleApplyEventFilters = this.handleApplyEventFilters.bind(this);
this.handleFiltersChange = this.handleFiltersChange.bind(this);
this.handleColumnsChange = this.handleColumnsChange.bind(this);
Expand Down Expand Up @@ -364,28 +367,18 @@ class SummitEventListPage extends React.Component {
} else {
this.setState({...this.state, enabledFilters: value, selectedFilterCriteria: null});
}
}

handleChangeStartDate(ev, lastDate) {
const {value} = ev.target;
const {start_date_filter} = this.state.eventFilters;

this.setState({...this.state, eventFilters: {
...this.state.eventFilters,
start_date_filter: lastDate ? [start_date_filter[0], value.unix()] : [value.unix(), start_date_filter[1]]
}});
}
}

handleChangeEndDate(ev, lastDate) {
const {value} = ev.target;
const {end_date_filter} = this.state.eventFilters;
handleChangeDateFilter(ev, lastDate) {
const {value, id} = ev.target;
const newDateFilter = this.state.eventFilters[id];

this.setState({...this.state, eventFilters: {
...this.state.eventFilters,
end_date_filter: lastDate ? [end_date_filter[0], value.unix()] : [value.unix(), end_date_filter[1]]
}});
this.setState({...this.state, eventFilters: {
...this.state.eventFilters,
[id]: lastDate ? [newDateFilter[0], value.unix()] : [value.unix(), newDateFilter[1]]
}});
}

handleColumnsChange(ev) {
const {value} = ev.target;
const {selectedColumns} = this.state;
Expand Down Expand Up @@ -530,6 +523,8 @@ class SummitEventListPage extends React.Component {
{label: T.translate("event_list.submission_status"), value: 'submission_status_filter' },
{label: T.translate("event_list.media_upload_with_type"), value: 'media_upload_with_type' },
{label: 'Review Status', value: 'review_status_filter'},
{label: 'Created', value: 'created_filter'},
{label: 'Modified', value: 'modified_filter'},
]

const ddl_columns = [
Expand Down Expand Up @@ -558,6 +553,8 @@ class SummitEventListPage extends React.Component {
{ value: 'progress_flags', label: T.translate("event_list.progress_flags") },
{ value: 'media_uploads', label: T.translate("event_list.media_uploads") },
{ value: 'review_status', label: T.translate("event_list.review_status") },
{ value: 'created', label: T.translate("event_list.created") },
{ value: 'modified', label: T.translate("event_list.modified") },
];

const ddl_filterByEventTypeCapacity = [
Expand Down Expand Up @@ -860,22 +857,22 @@ class SummitEventListPage extends React.Component {
<>
<div className={'col-md-3'}>
<DateTimePicker
id="start_date_from_filter"
id="start_date_filter"
format={{date:"YYYY-MM-DD", time: "HH:mm"}}
inputProps={{placeholder: T.translate("event_list.placeholders.start_date_from")}}
timezone={currentSummit.time_zone.name}
onChange={(ev) => this.handleChangeStartDate(ev, false)}
onChange={(ev) => this.handleChangeDateFilter(ev, false)}
value={epochToMomentTimeZone(eventFilters.start_date_filter[0], currentSummit.time_zone_id)}
className={'event-list-date-picker'}
/>
</div>
<div className={'col-md-3'}>
<DateTimePicker
id="start_date_to_filter"
id="start_date_filter"
format={{date:"YYYY-MM-DD", time: "HH:mm"}}
inputProps={{placeholder: T.translate("event_list.placeholders.start_date_to")}}
timezone={currentSummit.time_zone.name}
onChange={(ev) => this.handleChangeStartDate(ev, true)}
onChange={(ev) => this.handleChangeDateFilter(ev, true)}
value={epochToMomentTimeZone(eventFilters.start_date_filter[1], currentSummit.time_zone_id)}
className={'event-list-date-picker'}
/>
Expand All @@ -886,28 +883,80 @@ class SummitEventListPage extends React.Component {
<>
<div className={'col-md-3'}>
<DateTimePicker
id="end_date_from_filter"
id="end_date_filter"
format={{date:"YYYY-MM-DD", time: "HH:mm"}}
inputProps={{placeholder: T.translate("event_list.placeholders.end_date_from")}}
timezone={currentSummit.time_zone.name}
onChange={(ev) => this.handleChangeEndDate(ev, false)}
onChange={(ev) => this.handleChangeDateFilter(ev, false)}
value={epochToMomentTimeZone(eventFilters.end_date_filter[0], currentSummit.time_zone_id)}
className={'event-list-date-picker'}
/>
</div>
<div className={'col-md-3'}>
<DateTimePicker
id="end_date_to_filter"
id="end_date_filter"
format={{date:"YYYY-MM-DD", time: "HH:mm"}}
inputProps={{placeholder: T.translate("event_list.placeholders.end_date_to")}}
timezone={currentSummit.time_zone.name}
onChange={(ev) => this.handleChangeEndDate(ev, true)}
onChange={(ev) => this.handleChangeDateFilter(ev, true)}
value={epochToMomentTimeZone(eventFilters.end_date_filter[1], currentSummit.time_zone_id)}
className={'event-list-date-picker'}
/>
</div>
</>
}
{enabledFilters.includes('created_filter') &&
<>
<div className={'col-md-3'}>
<DateTimePicker
id="created_filter"
format={{date:"YYYY-MM-DD", time: "HH:mm"}}
inputProps={{placeholder: T.translate("event_list.placeholders.created_from")}}
timezone={currentSummit.time_zone.name}
onChange={(ev) => this.handleChangeDateFilter(ev, false)}
value={epochToMomentTimeZone(eventFilters.created_filter[0], currentSummit.time_zone_id)}
className={'event-list-date-picker'}
/>
</div>
<div className={'col-md-3'}>
<DateTimePicker
id="created_filter"
format={{date:"YYYY-MM-DD", time: "HH:mm"}}
inputProps={{placeholder: T.translate("event_list.placeholders.created_to")}}
timezone={currentSummit.time_zone.name}
onChange={(ev) => this.handleChangeDateFilter(ev, true)}
value={epochToMomentTimeZone(eventFilters.created_filter[1], currentSummit.time_zone_id)}
className={'event-list-date-picker'}
/>
</div>
</>
}
{enabledFilters.includes('modified_filter') &&
<>
<div className={'col-md-3'}>
<DateTimePicker
id="modified_filter"
format={{date:"YYYY-MM-DD", time: "HH:mm"}}
inputProps={{placeholder: T.translate("event_list.placeholders.modified_from")}}
timezone={currentSummit.time_zone.name}
onChange={(ev) => this.handleChangeDateFilter(ev, false)}
value={epochToMomentTimeZone(eventFilters.modified_filter[0], currentSummit.time_zone_id)}
className={'event-list-date-picker'}
/>
</div>
<div className={'col-md-3'}>
<DateTimePicker
id="modified_filter"
format={{date:"YYYY-MM-DD", time: "HH:mm"}}
inputProps={{placeholder: T.translate("event_list.placeholders.modified_to")}}
timezone={currentSummit.time_zone.name}
onChange={(ev) => this.handleChangeDateFilter(ev, true)}
value={epochToMomentTimeZone(eventFilters.modified_filter[1], currentSummit.time_zone_id)}
className={'event-list-date-picker'}
/>
</div>
</>
}
{enabledFilters.includes('submitters') &&
<div className={'col-md-6'}>
<MemberInput
Expand Down
2 changes: 2 additions & 0 deletions src/reducers/events/event-list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ const eventListReducer = (state = DEFAULT_STATE, action) => {
start_date: e.start_date ? moment(e.start_date * 1000).tz(state.summitTZ).format('MMMM Do YYYY, h:mm a') : 'TBD',
end_date: e.end_date ? moment(e.end_date * 1000).tz(state.summitTZ).format('MMMM Do YYYY, h:mm a') : 'TBD',
sponsor: (e.sponsors) ? e.sponsors.map(s => s.name).join(', ') : 'N/A',
created: e.created ? moment(e.created * 1000).tz(state.summitTZ).format('MMMM Do YYYY, h:mm a') : 'TBD',
modified: e.last_edited ? moment(e.last_edited * 1000).tz(state.summitTZ).format('MMMM Do YYYY, h:mm a') : 'TBD',
media_uploads: e?.media_uploads?.map( m => ({...m, created:moment(m.created * 1000).tz(state.summitTZ).format('MMMM Do YYYY, h:mm a') })),
progress_flags: e?.actions?.map(a => `${a.type.label} (${a.is_completed ? 'ON' : 'OFF'})`).join(', '),
review_status: e.review_status ?? 'N/A',
Expand Down

0 comments on commit c6d40f9

Please sign in to comment.