Is there a way to do this in FullCalendar jquery - fullcalendar

You can make description that says Kids Art School Day in April 12 to April 17th. It will make a bar across from that date like this"Kids Art School Day". How do you make each day show the same thing like a tradition paper calendar. April 12 says "Kids Art School Day", April 13 says "Kids Art School Day", April 14 says "Kids Art School Day", ........ all saying the same thing? I can do it in the events ,like this
'title': 'Kids Art School Day ',
'start': '2015-04-13',
'end': '2015-07-13',
'color': '#FFFFFF',
'textColor': '#3300FF'
'title': 'Kids Art School Day ',
'start': '2015-04-14',
'end': '2015-07-14',
'color': '#FFFFFF',
'textColor': '#3300FF'
I did a range but they want it to show each box the same thing..beats me.. ideas? In the calendar there is a lot of them.. making this json readable will be too much...

This isn't directly supported and so the solution is a little tricky.
Essentially, you break up the events into single day events when they are loaded. Use the function event source for this.
events: function (start, end, timezone, callback) {
//Get the events with an ajax call or whatever.
//Here, they're just declared globally as 'events'
var chunkedEvents = [];
for (var i = 0; i < events.length; i++) {
var days = moment(events[i].end).diff(events[i].start, 'days'); //length of event
if (typeof events[i].end !== "undefined" && days > 0) {
for (var j = 0; j <= days; j++) {
chunkedEvents.push($.extend({}, events[i], {
start: moment(events[i].start).subtract(j, 'days'),
end: moment(events[i].end).subtract(days + j, 'days')
}))
}
} else {
chunkedEvents.push(events[i]);
}
}
callback(chunkedEvents);
}
JSFiddle

Related

What causing this error Immer only supports setting array indices and the 'length' property

I am new to redux. I am now going to select movies to be pinned to another page. I can passed the id selected to the reducer. Then i will change the one of the variable so that it can be display on the other page. Once I checked the checkbox, I encounter this problem
My reducer
showSelectedPinnedMovie: function(state,action){
alert(action.payload);
if(action.payload) {
state.count++
state.movieId.push(action.payload)
};
if(state.count >= 6){
alert("You cannot pinned more than 5")
}
for(let c=0; c < state.value.length; c++ ){
state.value.selecttobepinned = false;
}
for(let i=0; i< state.value.length; i++ ){
for(let c=0; c< state.selectedPinnedId.length; c++){
if(state.value[i].id !== state.selectedPinnedId[c]){
return Object.assign({},state.value[i],{ "selecttobepinned" : true});
}
}
return state.value;
}
for(let i=0; i< state.value.length; i++ ){
for(let c=0; c< state.selectedPinnedId.length; c++){
if(state.value[i].id === state.selectedPinnedId[c]){
return Object.assign({},state.value[i],{ "selecttobepinned" : true});
}
}
return state.value;
}
state.count =0;
state.selectedPinnedId = [];
},
My initial data
initialState: {
value: [
{ "id": 1,"movie name" : "Ticket to Paradise","display":true,"description":"Academy Award® winners George Clooney and Julia Roberts reunite on the big screen as exes who find themselves on a shared mission to stop their lovestruck daughter from making the same mistake they once made","genre" :"Comedy", "lead actor": ["George Clooney", "Julia Roberts"],"rating":5,"displayOneMovie":false,"selecttobepinned":false,"language":"english"},
{ "id": 2, "movie name": "Black Panter","display":true,"description":"Queen Ramonda (Angela Bassett), Shuri (Letitia Wright), M’Baku (Winston Duke), Okoye (Danai Gurira) and the Dora Milaje (including Florence Kasumba), fight to protect their nation from intervening world powers in the wake of King T’Challa’s death.","genre":"Action","lead actor":["Angela Bassett","Letitia Wright"],"rating":6,"displayOneMovie":false,"selecttobepinned":false,"language":"english"},
{ "id":3, "movie name": "Smile","display":true,"description":"After witnessing a bizarre, traumatic incident involving a patient, Dr. Rose Cotter (Sosie Bacon) starts experiencing frightening occurrences that she can't explain.","genre":"Drama","lead actor":["Sosie Bacon","Jessie T. Usher"],"rating":6,"displayOneMovie":false,"selecttobepinned":false,"language":"english"},
{"id":4,"movie name":"Come Back Home","display":true,"description":"In the cold winter, a group of Shenzhen tourist families take a trip to the northeast Changbai Mountain. It was originally intended to be a happy and harmonious holiday, but due to the negligence of his father, an 8-year-old boy is unfortunately lost.","genre":"Mistery","lead actor":["Donnie Yen", "Han Xue"],"rating":6,"displayOneMovie":false,"selecttobepinned":false,"language":"mandarian"},
{"id":5,"movie name":"Ajoomma","display":true,"description":"Auntie (Hong Huifang), is a middle-aged Singaporean woman who has dedicated the best years of her life to caring for her family. Now widowed with her grown up son, Sam (Shane Pow) about to fly the roost, Auntie is left to contend with a whole new identity beyond her roles of daughter, wife, and mother.","genre":"Drama","lead actor":["Hong Huifang", "Jung Dong-Hwan"],"rating":4,"displayOneMovie":false,"selecttobepinned":false,"language":"mandarian"},
{"id":6,"movie name":"The King Of Musang King","display":true,"description":"Mao Shan (Jack Neo) is an ambitious durian farmer who wishes to expand his sales overseas, against pressures from the “Three Heavenly Kings” of the business. He helps Mei Lian (Yeo Yann Yann), his neighbour and sole supporter, to improve her durian farm harvests, and develops feelings for her in the process.","genre":"Comedy","lead actor":["Mark Lee","Henry Thia"],"rating":4,"displayOneMovie":false,"selecttobepinned":false,"language":"mandarian"}
],
movieId: [],
count: 0,// No records initially
},
I don't know whether I am updateing the state correctly. Can anyone solve this problem for me?

How can I Set Week which starts from Friday and Ends on Next Thursday in DaterangePicker

I am Using JQuery DateRangePicker by Dan Grossman, right now I Configured it to enable Current Week's Dates only by momentjs.
Here is my script
var startDate = moment().startOf('week').toDate();
var endDate = moment().endOf('week').toDate();
$(document).ready(function () {
$("#paymentDateTimePicker").daterangepicker({
singleDatePicker: true,
autoUpdateInput: false,
minDate: startDate,
maxDate: endDate,
locale: {
format: 'MM/DD/YYYY',
firstDay: 1
}
});
});
By default, this configuration starts from Sunday to Saturday.
Here is the output.
Now I want to Configure this dateRangePicker to starts on Friday instead of Sunday and ends on Thursday.
OR We can say From 2nd Of OCT to 8th of OCT.
I tried the add() and subtract() Methods of momentjs but can not find a proper solution to this.
Help me with this.
Thanks for your help, Above solution will work on regular days but if Today's Saturday then
it will not work.
here is a possible solution.
var day = moment().day();
var startDate;
var endDate;
if (day >= 5) {
startDate = moment().day(5).toDate();
endDate = moment().day(5).add(6, 'days').toDate()
}
else {
startDate = moment().startOf('week').subtract(2, 'days').toDate();
endDate = moment().endOf('week').subtract(2, 'days').toDate();
}
or can also use Datejs for easy chaining.
You can Modify as the date range from the Week Like This
var startDate = moment().startOf('week').subtract(2,'days').toDate();
var endDate = moment().endOf('week').subtract(2, 'days').toDate();

Get the next upcoming Friday at 5 PM

I need to display how far away a deadline is that is every Friday at 5PM. Moment will give me that date for a day of the week, but it's always the current time, so the deadline always displays 'x days, 23 hours, 59 minutes'. How do I get the day, AND a specific time from moment? In my example, I need deadline to be 'next Friday, at 17:00' instead of 'next Friday, at the current time'
console.log(timeLeft());
function timeLeft() {
var dayINeed = 5; // for Friday
var deadline;
// if we haven't yet passed the day of the week that I need:
if (moment().isoWeekday() <= dayINeed) {
// then just give me this week's instance of that day
deadline = moment().isoWeekday(dayINeed);
} else {
// otherwise, give me next week's instance of that day
deadline = moment().add(1, 'weeks').isoWeekday(dayINeed);
}
console.log(deadline);
const now = moment();
const days = deadline.diff(now, 'days');
const hours = deadline.subtract(days, 'days').diff(now, 'hours');
const minutes = deadline.subtract(hours, 'hours').diff(now, 'minutes');
return `${days} days, ${hours} hours, and ${minutes} minutes`;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.js"></script>
You have to set to deadline the time (17:00), instead of getting current time, you can use moment startOf() and set(), simply add the following to your code:
deadline.startOf('day').set({h: 17});
This way you are setting 17:00:00 to deadline and you will get the desired output.
Here a full example:
console.log(timeLeft());
function timeLeft() {
var dayINeed = 5; // for Friday
var deadline;
// if we haven't yet passed the day of the week that I need:
if (moment().isoWeekday() <= dayINeed) {
// then just give me this week's instance of that day
deadline = moment().isoWeekday(dayINeed);
} else {
// otherwise, give me next week's instance of that day
deadline = moment().add(1, 'weeks').isoWeekday(dayINeed);
}
deadline.startOf('day').set({h: 17});
console.log(deadline.format());
const now = moment();
const days = deadline.diff(now, 'days');
const hours = deadline.subtract(days, 'days').diff(now, 'hours');
const minutes = deadline.subtract(hours, 'hours').diff(now, 'minutes');
return `${days} days, ${hours} hours, and ${minutes} minutes`;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.js"></script>
If you want, you can use setter like hour(), minute() etc to set 17:00:00 to deadline.

Full calendar ResourceView horizontal and vertical axis

I'm using the fullcalendar resourceviews fork version 1.6.1.6...
I used an older version which had the resources on the top and the times on the left axis.
But now it is different. The times are on the top and the resources are on the left axis. It's not that good anymore. Is there a way to change it?
I need the newer version of it because of the refetchResources function.
I modified the resource object (using Ike Lin fullCalendar) and added an array which includes the number of the day, start time and end time like 0 -> 09:00 -> 12:00, 1 10:00 -> 15:30 ...
Then I changed the fullcalendar.js
function updateCells() {
var i;
var headCell;
var bodyCell;
var date;
var d;
var maxd;
var today = clearTime(new Date());
for (i=0; i<colCnt; i++) {
date = resourceDate(i);
headCell = dayHeadCells.eq(i);
if(resources[i].anwesenheit[date.getDay()-1] != null){
var von = resources[i].anwesenheit[date.getDay()-1].von;
var _von = von.substring(0, 5);
var bis = resources[i].anwesenheit[date.getDay()-1].bis;
var _bis = bis.substring(0, 5);
headCell.html(resources[i].name + "<p style='font-weight: normal; font-size: 11px;'>" + _von + " - " + _bis + " Uhr</p>");
} else {
headCell.html(resources[i].name);
}
headCell.attr("id", resources[i].id);
bodyCell = dayBodyCells.eq(i);
if (+date == +today) {
bodyCell.addClass(tm + '-state-highlight fc-today');
}else{
bodyCell.removeClass(tm + '-state-highlight fc-today');
}
setDayID(headCell.add(bodyCell), date);
}
}
This shows the work time from each resource right unter the name of the resource.
Also I added a serverside function to the select function which checks if the resource is available. If yes, then the event will be created, else the event won't be created and I get an error message.
Now I can work with it. It's not exactly what I wanted, but it's nice to use now. It updates the times under the resource name on every day change so I have an overview when a resource is available and when it's not available.

How can we specify custom date range with fullcalendar?

I want to use fullcalendar with custom date range for ex. it should display view for particular date range like from 15th April to 4th May(Spans between two months).
Any suggestions?.
you can call this function to gt events in date range. but this will bring you only 30 days evnt. if you pass dates like '01-may-2013' to 15-June-2013' then it will show data from 01-may2013 to 30st may 2013. Lt me know if you can find any clue for this issue.
function GetAgendaEvents(datefrom, dateTo) {
var fromDate = new Date($("#from").val());
var toDate = new Date($("#to").val());
if (fromDate.getTime() <= toDate.getTime()) {
$('#fullcal').fullCalendar('removeEvents').fullCalendar('addEventSource', events);
$('#fullcal').fullCalendar('refetchEvents');
var filteredEvent = $('#fullcal').fullCalendar('clientEvents', function (event) {
return event.start >= fromDate && event.start <= toDate;
});
$('#fullcal').fullCalendar('gotoDate', fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate());
$('#fullcal').fullCalendar('changeView', 'agenda'/* or 'basicDay' */);
$('#fullcal').fullCalendar('removeEvents').fullCalendar('addEventSource', filteredEvent);
$('#fullcal').fullCalendar('refetchEvents');
}
}

Resources