Commit 182079f3 authored by Maxime Chaillet's avatar Maxime Chaillet

fix bug on the number of collpased event in event list when the user edits or...

fix bug on the number of collpased event in event list when the user edits or cancel. This fix also fixes the long time delay when the user clicks the cancel button during edition creation. It fixes icat/E-DataPortal#156.
parent 103a7d23
......@@ -10,13 +10,13 @@ import LazyLoad from 'react-lazyload';
import { EVENT_CATEGORY_COMMANDLINE, NOTIFICATION } from '../../../constants/EventTypes.js';
require("./eventList.css");
const COLLAPSED_EVENT_TYPES = "EVENTS";
/**
* The list of the all events
*/
class EventList extends React.Component {
collapse(items) {
var collapsed = [];
debugger;
let collapsed = [];
for (let i = 0; i < items.length; i++) {
const event = items[i];
if (event.category === EVENT_CATEGORY_COMMANDLINE && !event.previousVersionEvent) {
......@@ -24,8 +24,9 @@ class EventList extends React.Component {
if (lastEvent.category === EVENT_CATEGORY_COMMANDLINE) {
if (!lastEvent.events) {
lastEvent.events = [event];
} else {
lastEvent.events.push(event);
}
lastEvent.events.push(event);
continue;
}
}
......@@ -36,15 +37,16 @@ class EventList extends React.Component {
/** Returns the list of items to be displayed in the table: events + days */
getItems() {
var items = [];
var lastDate = null; // format DDMMYYYY
for (var i = 0; i < this.props.events.length; i++) {
var date = Moment(getOriginalEvent(this.props.events[i]).creationDate).format("MMMM Do YYYY");
let eventsCopy = _.cloneDeep(this.props.events);
let items = [];
let lastDate = null; // format DDMMYYYY
for (let i = 0; i < eventsCopy.length; i++) {
let date = Moment(getOriginalEvent(eventsCopy[i]).creationDate).format("MMMM Do YYYY");
if (date !== lastDate) {
lastDate = date;
items.push({ text: date, type: "date", anchor: date });
}
items.push(this.props.events[i]);
items.push(eventsCopy[i]);
}
return this.collapse(items);
}
......@@ -94,6 +96,7 @@ class Event extends React.Component {
}
render() {
debugger
let events = [this.props.event];
if (this.props.event.events && !this.state.collapsed) {
events = events.concat(this.props.event.events);
......@@ -112,7 +115,7 @@ class Event extends React.Component {
<LazyContentEvent event={event} />
{event.events && this.state.collapsed ? <Label style={{ color: "blue", backgroundColor: "white", cursor: "pointer" }} onClick={this.handleClick} >.... {event.events.length} command lines more</Label> : null}
</td>
<td style={{ width: '50px', border: 0 }}>
<td classNmae='eventActionBox' style={{ width: '50px', border: 0 }}>
<Button bsStyle="link" bsSize="small" style={{ padding: '0px' }} onClick={() => this.props.onEventClicked(event)}>
<Glyphicon glyph='edit' style={{ width: '40px' }} />
</Button>
......@@ -128,7 +131,6 @@ 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,6 @@ 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.onEventUpdated(updatedEvent);
}
......
......@@ -445,7 +445,6 @@ 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);
......
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