forked from vergnet/application-amicale
Removed multiple day management (will be handled by server)
This commit is contained in:
parent
3824683385
commit
53ef08219c
1 changed files with 1 additions and 38 deletions
|
@ -194,53 +194,16 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getClonedEventArray(event: Object, times: number) {
|
|
||||||
let cloneArray = [];
|
|
||||||
if (times > 1) {
|
|
||||||
for (let i = 0; i < times; i++) {
|
|
||||||
let clone = JSON.parse(JSON.stringify(event));
|
|
||||||
let startDate = PlanningEventManager.stringToDate(clone["date_begin"]);
|
|
||||||
let endDate = new Date();
|
|
||||||
if (i !== 0) {
|
|
||||||
startDate.setHours(0, 0, 0);
|
|
||||||
startDate.setDate(startDate.getDate() + i);
|
|
||||||
clone["date_begin"] = PlanningEventManager.dateToString(startDate);
|
|
||||||
}
|
|
||||||
if (i !== (times - 1)) {
|
|
||||||
endDate = PlanningEventManager.stringToDate(clone["date_end"]);
|
|
||||||
endDate.setHours(23, 59, 0);
|
|
||||||
endDate.setFullYear(startDate.getFullYear(),
|
|
||||||
startDate.getMonth(),
|
|
||||||
startDate.getDate() + i);
|
|
||||||
clone["date_end"] = PlanningEventManager.dateToString(endDate);
|
|
||||||
}
|
|
||||||
cloneArray.push(clone)
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
cloneArray = [event];
|
|
||||||
return cloneArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
generateEventAgenda(eventList: Array<Object>) {
|
generateEventAgenda(eventList: Array<Object>) {
|
||||||
let agendaItems = this.generateEmptyCalendar();
|
let agendaItems = this.generateEmptyCalendar();
|
||||||
for (let i = 0; i < eventList.length; i++) {
|
for (let i = 0; i < eventList.length; i++) {
|
||||||
if (PlanningEventManager.getDateOnlyString(eventList[i]["date_begin"]) !== undefined) {
|
if (PlanningEventManager.getDateOnlyString(eventList[i]["date_begin"]) !== undefined) {
|
||||||
const clonedEventArray = this.getClonedEventArray(
|
this.pushEventInOrder(agendaItems, eventList[i], PlanningEventManager.getDateOnlyString(eventList[i]["date_begin"]));
|
||||||
eventList[i],
|
|
||||||
PlanningEventManager.getEventDaysNumber(eventList[i]["date_begin"], eventList[i]["date_end"])
|
|
||||||
);
|
|
||||||
this.pushEvents(agendaItems, clonedEventArray);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setState({agendaItems: agendaItems})
|
this.setState({agendaItems: agendaItems})
|
||||||
}
|
}
|
||||||
|
|
||||||
pushEvents(agendaItems: Object, eventList: Array<Object>) {
|
|
||||||
for (let i = 0; i < eventList.length; i++) {
|
|
||||||
this.pushEventInOrder(agendaItems, eventList[i], PlanningEventManager.getDateOnlyString(eventList[i]["date_begin"]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pushEventInOrder(agendaItems: Object, event: Object, startDate: string) {
|
pushEventInOrder(agendaItems: Object, event: Object, startDate: string) {
|
||||||
if (agendaItems[startDate].length === 0)
|
if (agendaItems[startDate].length === 0)
|
||||||
agendaItems[startDate].push(event);
|
agendaItems[startDate].push(event);
|
||||||
|
|
Loading…
Reference in a new issue