var ds = databaseManager.getDataSetByQuery(scopes.coreConfiguration.defaultDataSourceServerName, query, null, -1);
var events = [];
for (var i = 1; i <= ds.getMaxRowIndex(); i++) {
var startDate = new Date(ds.getValue(i, 1));
var endDate = new Date(ds.getValue(i, 1));
/** @type {String} */
var startTime = ds.getValue(i, 2);
startDate.setHours(startTime.substring(0, 2), startTime.substring(2, 4));
/** @type {String} */
var endTime = ds.getValue(i, 3);
endDate.setHours(endTime.substring(0, 2), endTime.substring(2, 4));
events.push({
title: ds.getValue(i, 4) + '\n' + ds.getValue(i, 5) + '\n' + ds.getValue(i, 6),
start: startDate,
end: endDate,
resourceId: 'default'
})
}
return events;
function initCalendar() {
getCalendar().fullCalendar(getCalenderOtions());
var eventSource = getCalendarEventSource();
eventSource['events'] = fetchEvents;
getCalendar().addEventSource(eventSource);
}
function timGetCalendarOptions2() {
/** @type {CustomType<svy-fullcalendar2.FullCalendarOptions>} */
var options = {};
options.headerToolbar = {
left: 'title',
center: 'dayGridMonth timeGridWeek timeGridDay',
right: 'today prev,next'
}
options.allDaySlot = false;
options.contentHeight = 'auto'; // Avoid an empty row at the bottom of the calendar.
options.displayEventTime = false;
options.displayEventEnd = false;
options.expandRows = true;
options.editable = false;
options.eventDisplay = 'block'; // Show lessen as rectangle in month view (dayGridMonth) like in the other views.
options.expandRows = true;
options.firstDay = 1; // Monday.
options.handleWindowResize = true;
options.height = 'auto';
options.initialView = 'timeGridWeek';
options.locale = scopes.coreConfiguration.defaultLanguage;
options.nowIndicator = true;
options.selectable = false;
options.slotDuration = '00:15:00'; // 15 minutes.
options.slotLabelFormat = 'H:mm';
options.slotMinTime = '07:30';
options.slotMaxTime = '18:30';
options.weekends = false; // Do not show saturday, and sunday.
options.weekNumbers = true;
options.views = {
timeGridWeek: {
// options apply to timeGridWeek view.
columnFormat: 'dd.D.M.',
titleFormat: {month: 'short', year: 'numeric', day: 'numeric', weekday: 'short'}
},
timeGrid: {
// options apply to basicDay and agendaDay views
}
}
return options;
}
john1598360627 wrote:Is the idea here that;
1. Create Event Source & connect it to the FullCalendar
2. Convert database table records into Event objects
3. Add Event Objects into Event Source
/**
* @return {RuntimeWebComponent<svy-fullcalendar.EventSourceType>|RuntimeWebComponent<svy-fullcalendar2.EventSourceType>}
*
* @abstract
*
* @properties={typeid:24,uuid:"D144507B-E64B-46B5-B3EE-934EF3F607F1"}
*/
function getCalendarEventSource() {
return null;
}
ERROR com.servoy.j2db.util.Debug - cant parse variable 'option_calendar'
var option_calendar = {
eventSources: [
function_EventSource,
array_EventSource
]
};
/**
* @type {svy-fullcalendar.EventSourceType}
*
* @properties={typeid:35,uuid:"F79A7DAB-D2F7-4447-A37E-9E2D93228963",variableType:-4}
*/
var function_EventSource = {
events: fetch_Function,
data: {search: 'Amsterdam'},
color: 'green',
ignoreTimezone: false
};
/**
*
* @type {svy-fullcalendar.EventSourceType}
*
* @properties={typeid:35,uuid:"C0468449-2EB7-4092-A90C-2106EE33BEE4",variableType:-4}
*/
var array_EventSource = {
events: [{
title: "source event",
start: new Date(),
allDay: true
}],
color: 'yellow'
};
/**
*
* @param {Date} start
* @param {Date} end
* @param {Object} [data] optional object to be used as filter parameters in fetching events
*
*
* @return {Object}
*
* @properties={typeid:24,uuid:"ACA4AFA8-6266-432B-99A5-3A609CE5034B"}
* @AllowToRunInFind
*/
function fetch_Function( start, end, data ) {
/** @type {JSFoundset<db:/fullcalendar/event_object>} */
var fs_eventobject = databaseManager.getFoundSet("db:/fullcalendar/event_object");
// search data based on your search criteria
if (fs_eventobject.find()) {
// if (data.search) fs_eventobject. = data.search
fs_eventobject.start_date = '>= ' + utils.dateFormat(scopes.svyDateUtils.toStartOfDay(new Date(start)), 'dd/MM/yyyy HH:mm:ss') + '|dd/MM/yyyy HH:mm:ss';
fs_eventobject.end_date = '<= ' + utils.dateFormat(scopes.svyDateUtils.toEndOfDay(new Date(end)), 'dd/MM/yyyy HH:mm:ss') + '|dd/MM/yyyy HH:mm:ss';
fs_eventobject.search();
}
var events = []
for (var i=1; i<=fs_eventobject.getSize(); i++ ) {
/** @type {JSRecord<db:/fullcalendar/event_object>} */
var rec = fs_eventobject.getRecord(i)
// Note: is up to the developer map a datasource to an event object
events.push({
start : rec.start_date,
end: rec.end_date,
title : rec.title_event
// location: rec.location
});
}
return events;
}
paronne wrote:Hi John,
there are calendar events onEventDrop, onEventResize which you can use to intercept the changes and store these changes in the DB yourself.
On a note; there has been a recent fix in the onEventResize event improving the event params ( https://support.servoy.com/browse/SVYX-808 ) is soon to be released with 2024.3.
Regards,
Paolo
//add ten events
var d = new Date();
for (var i = 1; i < 10; i++) {
d.setHours(d.getHours()+1); // add a new event but increase the hours by one
elements.calendar.addEvent({ title: "Event "+i, start: d })
}
for (var i = 1; i <= foundset.getSize(); i++) {
var record = foundset.getRecord(i);
elements.calendar.addEvent({ title: record.title, start: record.startDate })
}
/** @type {CustomType<svy-fullcalendar2.EventSource>} */
var eventSource = {
id: 'myeventsource',
events: resourceEventSourceCallback, // the callback method which is going to populate the calendar
editable: true,
startEditable: true,
durationEditable: true,
defaultAllDay: false
}
...
// assuming you have an option object to init the calendar
options.eventSources = [eventSource];
calendar.fullCalendar(options);
function resourceEventSourceCallback(start, end, params) {
/** @type {JSFoundSet<mem:event_objects>} */
var fs = databaseManager.getFoundSet("mem:event_objects");
// search all events with the by resource_id between start and end time
if (fs.find()) {
fs.start_date = '>= ' + scopes.svyUtils.dateFormat(scopes.svyUtils.toStartOfDay(new Date(start)), 'dd/MM/yyyy HH:mm:ss') + '|dd/MM/yyyy HH:mm:ss';
fs.end_date = '<= ' + scopes.svyUtils.dateFormat(scopes.svyUtils.toEndOfDay(new Date(end)), 'dd/MM/yyyy HH:mm:ss') + '|dd/MM/yyyy HH:mm:ss';
fs.search();
}
var record;
var retval = [];
// return the EventParsing objects for each record in foundset
for (var i = 1; i <= fs.getSize(); i++) {
record = fs.getRecord(i);
var event = getEvent(record);
retval.push(event)
}
return retval;
}
Return to Discuss possible Issues and Bugs
Users browsing this forum: No registered users and 5 guests