Commit 103a7d23 authored by Maxime Chaillet's avatar Maxime Chaillet

fix event list does not refresh when an event is commented.

parent 96b99fda
......@@ -15,18 +15,6 @@ const COLLAPSED_EVENT_TYPES = "EVENTS";
* The list of the all events
*/
class EventList extends React.Component {
constructor(props) {
super(props)
this.state = {
items: this.getItems()
}
}
componentDidMount() {
this.setState({ items: this.getItems() })
}
collapse(items) {
var collapsed = [];
for (let i = 0; i < items.length; i++) {
......@@ -44,8 +32,8 @@ class EventList extends React.Component {
collapsed.push(event);
}
return collapsed;
}
/** Returns the list of items to be displayed in the table: events + days */
getItems() {
var items = [];
......@@ -68,7 +56,7 @@ class EventList extends React.Component {
return <Table responsive style={{ fontSize: '12px' }} >
<tbody>
{this.state.items.map((event, index) => {
{this.getItems().map((event, index) => {
if (event.type === "date") {
return <tr><td style={{ borderTop: '1px solid #f2f2f2', textAlign: 'center', fontSize: '18px', fontWeight: 'bold' }} colSpan={3} ><a name={event.anchor}></a> {event.text}</td></tr>;
}
......@@ -140,6 +128,7 @@ class LazyContentEvent extends React.Component {
return getContent(event.content, 'html') ? convertImagesToThumbnails(getContent(event.content, 'html')) : convertImagesToThumbnails(getContent(event.content, 'plainText'));
}
render() {
debugger;
var content = this.getHTMLContent(this.props.event);
if (content) {
/** For performance only events with images are lazy loaded */
......
......@@ -176,7 +176,7 @@ class NewOrEditEventPanel extends React.Component {
* Callback triggered when the event has been successfully updated on the server side
*/
onSuccessfullyUpdated = (updatedEvent) => {
this.props.setEditEventVisibility(EDIT_EVENT_INVISIBLE);
//this.props.setEditEventVisibility(EDIT_EVENT_INVISIBLE);
this.props.onEventUpdated(updatedEvent);
}
......
......@@ -445,6 +445,7 @@ class LogbookContainer extends React.Component {
* @param {Object} event the updated event as provided by the server
*/
onEventUpdated(updatedEvent) {
debugger;
let copyPageEvents = this.state.pageEvents.map(event => event);
let foundIndex1 = _.findIndex(copyPageEvents, (event) => event._id === updatedEvent._id);
copyPageEvents.splice(foundIndex1, 1, updatedEvent);
......@@ -455,7 +456,8 @@ class LogbookContainer extends React.Component {
this.setState({
downloadedEvents: copyDownloadedEvents,
pageEvents: copyPageEvents
pageEvents: copyPageEvents,
eventBeingEdited: null
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment