FullCalendar + React, can't made selection for day which contains allDay event - fullcalendar

Have a strange issue with FullCalendar + React, I suspect that it might be a bug, but don't sure, maybe I do something wrong. When day contains allDay event, it isn't editable. When I remove this allDay event, everything works good.
The MVCE below and link to sandbox here: https://codesandbox.io/s/elated-leaf-eeq5mp?file=/src/DemoApp.jsx
const Sandbox = () => {
const events = [
{
"_id": "6392d844690474ce8cd8db01",
"startTime": "05:00:00",
"endTime": "11:00:00",
"frequency": 10,
"description": "testrrr",
"daysOfWeek": [
4
],
"_createdAt": "2022-12-09T06:40:04.085Z"
},
{
"_id": "63935c8a192093deab4bccd5",
"startTime": "01:30:00",
"endTime": "04:00:00",
"frequency": 1,
"description": "",
"daysOfWeek": [
4
],
"title": "Hello World!",
"_createdAt": "2022-12-09T16:04:26.123Z"
},
{
"title": "186",
"infoEvent": true,
"start": "2022-12-08T13:06:26.812Z",
"allDay": true,
"editable": false,
"daysOfWeek": [
"4"
]
}
];
const select = selectionInfo => {
console.log(selectionInfo);
}
return (
<FullCalendar
eventOverlap={false}
selectable
selectOverlap={false}
select={select}
contentHeight='auto'
aspectRatio={2}
plugins={[
dayGridPlugin,
interactionPlugin,
timegridPlugin
]}
headerToolbar={{
left: 'timeGridDay,timeGridWeek,dayGridMonth',
center: 'title'
}}
allDaySlot={true}
events={events}
editable
initialView="timeGridWeek"
/>
)
}
export default Sandbox;
UPDATE: Tried to reimplement with the plain FullCalendar, without React wrapper, and couldn't reproduce this error https://codepen.io/anatoly314/pen/ExRJRYz?editors=0010. Opened an issue at FullCalendar's github community: https://github.com/fullcalendar/fullcalendar-react/issues/212

It isn't a bug but a feature because I have allDay events and defined eventOverlap as false. Existed allDay event was blocked creating another event.
When I created MVCE for StackOverflow in vanilla JS I didn't use the property eventOverlap and this is a reason why it worked in my example above. When I tried to write my own React component for FullCalendar, I encountered the same behavior. And later, one of the contributors to FullCalendar confirmed this behavior: https://github.com/fullcalendar/fullcalendar-react/issues/212
So, If you need to disable overlap but keep allDay events you need to write your own logic in function rather than boolean, something like this:
const eventOverlap = (stillEvent, movingEvent) => {
return stillEvent.allDay;
}

Related

Fullcalendar: Show additional event data in list view

I'm using fullcalendar to display a month view which shows the time and title of events (and a popover showing the description when hovered). When I click the event, I show a listday view that shows all the events for that day. That all works fine and I have this working with this code:
var calendar = new FullCalendar.Calendar(calendarEl, {
headerToolbar: {
start: 'dayGridMonth,listDay',
center: 'title',
end: 'prev,next'
},
initialView: 'dayGridMonth',
initialDate: '2023-01-12',
height: 'auto',
dayMaxEvents: 3,
moreLinkClick: 'listDay',
eventClick: function(info){
switchToListView(info)
},
eventColor: 'green',
views: {
listDay: {
displayEventEnd: true
}
},
events: [
{
title: 'All Day Event',
start: '2023-01-01'
},
{
title: 'Meeting',
description: 'My Description',
start: '2023-01-12T10:30:00',
end: '2023-01-12T12:30:00'
},
and in this code pen
I'd like to show the description text for the event in addition to the title in the listday view and I can't figure out how to do this. I don't know whether I need to use an event hook or what. I just can't make my way through the docs and examples to see what to do.
Appreciate any help.
I got this working with this use of eventDidMount.
eventDidMount: function(info) {
info.el.querySelector('.fc-list-event-title a').innerHTML += ` ${info.event.extendedProps.description}`
},
Frankly, it feels a little weird that I need to go into the depths of the rendered HTML to adjust the output instead of changing what is going INTO the generated HTML but I guess that's just how it works (??)
Thanks to #ADyson for the push in the right direction.

Multiples instances of VideoJS playlist are deprecated

I'm developing a Wordpress Plugin that allows users to add custom video playlists to their pages or posts, and for that I'm using Videojs and Videojs Playlist libraries.
I've successfully managed to add a single playlist into a page, but when a second one is created the first player is disabled.
First Player disabled
Other problem I'm facing is that, although the vjs-playlist div is added, it only shows in the first player created.
Code display in the browser
var options = {"techOrder": ["html5","youtube", "flash"]};
var myPlayer = videojs('my-playlist-player', {options, "autoplay": false, "controls": true, "fluid": true, "liveui": true});
myPlayer.playlist([{
name: 'Test item 1 type .m3u8',
description: 'Testing for videojs-playlist-ui integration',
duration: '45',
sources: [
{src: '//vjs.zencdn.net/v/oceans.mp4',type: 'video/mp4'}
],
thumbnail: [
{
srcset: '//bcvid.brightcove.com/players-example-content/clouds-1800.jpg',
type: 'image/jpeg',
style: 'max-height: 120px;'
}
]
},{
name: resTitle,
description: resDesc,
duration: resDuration,//'45',
sources: [
{src: resItemSrc, type: resMime}
],
thumbnail: [
{
srcset: resThumbnail,
type: resImgType,
style: thumbStyle//'max-height: 120px;'
}
]
}
}
]);
console.log(myPlayer.playlist());
myPlayer.playlistUi({el: document.getElementById('vjs-playlist'), horizontal: true});
myPlayer.playlist.autoadvance(1);
I believe my errors happen because videojs functions are detecting the same id in all elements, but if so how could I avoid this?
Any other ideas or opinions on why this errors might be happening, would be great.
Thanks in advance.
A bit more of information, I wanted to check how many players the script detected and so I printed in the console the window.videojs.players and only one player is detected even if more are created. Check result
Could this be because they have the same ID? If so how could it be fixed? HTML Result

Change background color based on event title Fullcalendar 4

I'm trying to change the background color of an event (in Day View) of fullcalendar v4. I've spent hours trying to implement eventRender, to no avail. This has led me to find other workarounds, but now, I'm striking out!
I'm trying to figure out the solution explained here: [Fullcalendar - change event color based on value ..
But, every time the search for the word 'yes' is TRUE, I get an error in chrome console saying 'Failure parsing JSON'. If I change the search query to something that will create 'false', I do not get this error. To me, this means that the search is working, but the event render function is failing somehow.
my code:
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'interaction', 'resourceDayGrid', 'resourceTimeGrid' ],
defaultView: 'resourceTimeGridDay',
defaultDate: '<?php echo $startdate?>',
validRange: {
start: '<?php echo $startdate?>',
end: '<?php echo $maxdaycal?>'
},
height: 700,
...
...
eventSources: [
{
url: 'getevents2.php?festid=<?php echo $festid?>&room=<?php echo $roomabv?>',
cache: false,
},
{
url: 'getbreaks2.php?festid=<?php echo $festid?>&room=<?php echo $roomabv?>',
cache: false,
color: 'grey',
editable: false,
}
],
eventRender: function(info) {
if(info.event.extendedProps.desc == "yes") {
element.style.css('background-color', '#000');
}
},
....
});
calendar.render();
});
My goal: Search for the word "Accomp" in the title of the element (probably in info.event.title) .. and have the background change to a different color .. like red .. or something.
I've also tried to show an Icon in this field if the word Accomp is present, but -- I had to show it in a modal, because I couldnt get eventrender to show html.
I think this is because of the differences in FC v4 .. but I'm not sure.
I've also tried: [Is it possible to assign the background colour of a FullCalendar event based on its title? .. but I couldn't get that sorted out either.
UPDATE: The search function is working, as I can see it in the console log, but whenever I try to set the css, the calendar does not render.
eventRender: function(info) {
console.log(info.event.title);
if(-1 != info.event.title.indexOf("Accomp")) {
console.log(info.event.title);
fc-title.css('background-color', '#000');
}
},
This is based on some other answers that areavailable, but it appears that there are differences in FC4... This works for me!
eventRender: function(info) {
if(-1 != info.event.title.indexOf("Accomp")) {
info.el.style.backgroundColor = "red";
}
},

Receiving "Highcharts is not defined" error when using maps (Highmaps / Highcharts)

I've used Highcharts quite a bit and the charts work great, but I've been stuck trying to make Highmaps work for quite a while now.
I believe I have everything setup correctly with my test map that I'm trying to make work because it works correctly in JSFiddle.
The error I'm receiving in my browser console is this:
"Uncaught ReferenceError: Highcharts is not defined at
https://code.highcharts.com/mapdata/custom/world-highres.js:1:1 (anonymous function) # world-highres.js:1"
The first part of world-highres.js is: Highcharts.maps["custom/world-highres"] = { ...
Does anyone know why Highcharts would be coming back as undefined here?
I'm using Meteor 1.3.5.1 and I have Highcharts 5.0.4 installed through NPM.
Here's how I currently have things setup:
exampleTemplate.js
import Highcharts from 'highcharts';
require('highcharts/modules/map')(Highcharts);
Template.exampleTemplate.onRendered(function() {
// Example data
var mymapdata = [
{
key: "US",
value: 198812
},
{
key: "GB",
value: 52894
},
{
key: "CA",
value: 35572
}
];
// Initiate
Highcharts.mapChart('country-map-container', {
title: {
text: 'Highmaps Example'
},
subtitle: {
text: 'Example'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
colorAxis: {
min: 0
},
series: [{
data: mymapdata,
mapData: Highcharts.maps['custom/world-highres'],
joinBy: ['iso-a2', 'key'],
name: 'Random data',
states: {
hover: {
color: '#a4edba'
}
},
dataLabels: {
enabled: true,
format: '{point.name}'
}
}]
});
});
exampleTemplate.html
<template name="exampleTemplate">
<div id="country-map-container" style="width:100%; height:400px;"></div>
</template>
Head tag:
<head>
<script src="https://code.highcharts.com/mapdata/custom/world-highres.js"></script>
</head>
Here's what it looks like with the code above:
I've tried a lot of different things and spent a ton of time on this but nothing I've tried seems to make it work... Any help with this would be extremely appreciated.
Make sure your order is as follows,
<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/maps/modules/data.js"></script>
<script src="http://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="http://code.highcharts.com/mapdata/custom/world-highres.js"></script>
JSFIDDLE

Highcharts - Maps data structure

I am trying to build an array of data returned from a third party API, and display it using the Highcharts map module.
I've done so with the charts module, using line and pie charts both with not much difficulty. Now that I've moved onto maps, I seem to be running into a bit of difficulty. It was quite clear from the examples provided how the data should be structured to be properly read by Highcharts.
When it comes to the maps module, the data structure is not clear at all. How would I structure my data to pass into my Highcharts map???
[ 'US' , 'United States' , 32 ] , [ 'CA' , 'Canada' , 100 ]
If I use the provided :
jQuery.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=world-population-density.json&callback=?', function (data) {
console.log(data);
// Initiate the chart
jQuery('#geo_map').highcharts('Map', {
title : {
text : 'Campaign Link Clicks Around The World'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
colorAxis: {
min: 1,
max: 1000,
type: 'logarithmic'
},
series : [{
data : data,
mapData: Highcharts.maps['custom/world'],
joinBy: ['iso-a2', 'code'],
name: 'Population density',
states: {
hover: {
color: '#BADA55'
}
},
tooltip: {
valueSuffix: '/kmĀ²'
},
}],
credits: {
enabled: false
},
});
});
});
It works. But I can't seem to figure out how to pass in my data. I thought it was as simple as
[ 'Abbreviation' , 'Name' , Value ] , [ 'Abbreviation' , 'Name' , Value ]
but clearly not. The documentation isn't very clear on data structure.
Thanks.

Resources