调整大小无法在2天后使用

时间:2018-07-31 01:51:29

标签: fullcalendar fullcalendar-scheduler

我正在使用fullcalendar,尝试了所有方法,但无法在2天后调整事件大小。一旦光标到达屏幕上的2天,它将停在那里,并且不允许用户将事件的大小调整为1天的事件。下面是我用来显示日历事件的代码。任何帮助或线索,不胜感激。我也添加了AllDay true,

我正在从数据库中获取事件,该事件的持续时间已经定义为2,3或4天事件,这就是它在屏幕上的显示方式。假设用户尝试调整事件大小,则可以将事件缩减至2天,并且curson会在此之后停止工作。就像用户想要将4天作为一日活动一样,他将无法执行。我知道,设置t时我缺少一些配置

$('#calendar').fullCalendar({
            schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
            editable: editableCheck, // enable draggable events
            selectable: true,               
            selectHelper: true,
            aspectRatio: 1.8,
            height: 600,
            weekends: true,
            eventLimit: false,
            showNonCurrentDates:false,
            header: {
                left: 'today prev,next',
                center: 'title',
                right: 'timelineThreeDays'
            },
            defaultView: 'timelineThreeDays',
            displayEventTime: false,
            views: {
                timelineThreeDays: {
                    type: 'timelineWeek',
                    duration: {
                        days: 21
                    }
                }
            },
            eventRender: function (event, element, view) {
                if(event.projectStatus == 'Rejected') {
                    element.find('.fc-title').qtip({    
                        content: {    
                            text: event.comments
                        },
                        style: { 
                            tip: {corner: true},
                            classes: 'qtip-light qtip-bootstrap'
                        },
                        position: {  
                            target: 'mouse', // Track the mouse as the positioning target
                            adjust: { x: 5, y: 5 } 
                        }
                    });
                }
                var objeventDelArray = [];
                element.on('contextmenu', function(e) {
                    var sourceFrmComm = component.get("v.boolCallSource");
                    if(sourceFrmComm == 'false'){

                        if (confirm('Are you sure you want to delete ' + event.title + '?')) 
                        {   
                            e.preventDefault();
                            $('#calendar').fullCalendar('removeEvents', event.id);
                            $('#calendar').fullCalendar('removeResource', event.id);
                            objeventDelArray = component.get("v.deleteEvents");
                            objeventDelArray.push(event.id);
                            console.log('===objeventDelArray================'+objeventDelArray);
                            component.set("v.deleteEvents", objeventDelArray);
                        }
                    }
                });

                if(event.id != null){ //workingDaysBetweenDates TODO TEMP Solution: Needs to change logic for dateTime calculation 
                    if(!event.id.startsWith('~AJ~')){
                        var da = helper.workingDaysBetweenDates(new Date(event.start), new Date(event.end));
                        if(da == 0)
                            da = 1;
                        element.find('.fc-title').prepend("D(" +  parseInt(da) +') ');
                    }else
                    {
                        var da = helper.diff_days(new Date(event.start), new Date(event.end));
                        console.log('jugaad==='+da);
                        element.find('.fc-title').prepend("D(" + da  +') ');
                    }
                    if (event.rendering == 'background') {
                        element.append('<div class="center">' + event.title + '</div>');
                    }
                }
            },
            select: function(start, end, jsEvent, view, resource) {
                var eventData;
                eventData = {
                    title:resource.title+'--'+ resource.providerName,
                    start: moment(start),
                    end: moment(end),
                    resourceId: resource.id,
                    jobID:resource.parentId,
                    activity:resource.title,
                    id:'~AJ~'+resource.title,
                    color:'#444445',
                    holiday:false
                };
                if(resource.providerName !=null && (!resource.isParentRecord ))
                    $('#calendar').fullCalendar('renderEvent', eventData, true); 
                else
                    $('#calendar').fullCalendar('unselect');


            },

            eventResize: function(event, delta, revertFunc, jsEvent, ui, view ) {
                if(event.projectStatus == 'Rejected') {  
                    $("#calendar").fullCalendar( 'removeEvents', event.id );
                    var eventDataUpdate;
                    eventDataUpdate = {title:event.title,start: moment(event.start),end: moment(1),
                                       resourceId: event.id,jobID:event.jobID,activity:event.title,id:event.id,color:'#007132',
                                       projectStatus:'Adjusted',holiday:false
                                      };
                    component.set('v.projectAppStatus','resizeTrigger');
                    $('#calendar').fullCalendar('renderEvent', eventDataUpdate, true);
                }
                component.set("v.projectID", component.get("v.projectID"));
            },
            eventDrop: function(event, delta, revertFunc, jsEvent, ui, view ) 
            { 
                if(event.projectStatus == 'Rejected') {  
                    $("#calendar").fullCalendar( 'removeEvents', event.id );
                    var eventDataUpdate;
                    eventDataUpdate = {title:event.title,start: moment(event.start),end: moment(event.end),
                                       resourceId: event.id,jobID:event.jobID,activity:event.title,id:event.id,color:'#007132',
                                       projectStatus:'Adjusted',holiday:false
                                      };
                    component.set('v.projectAppStatus','resizeTrigger');
                    $('#calendar').fullCalendar('renderEvent', eventDataUpdate, true);
                }
                component.set("v.projectID", component.get("v.projectID"));
            },

            resourceRender: function(resource, cellEls) {
                if (!resource.isParentRecord) {
                    var eventID = resource.id;   
                    var custIcon2= '<i  id="deleteIcon"  class="icon-trash" style="cursor:pointer;" ></i>' ;
                    cellEls.eq(0).find('.fc-expander-space').prepend($(custIcon2));
                    var objeventDelArray = [];
                    cellEls.eq(0).find('.icon-trash').on('click', function() {
                        if (confirm('Are you sure you want to delete ' + resource.title + '?')) 
                        {
                            objeventDelArray = component.get("v.deleteEvents");
                            objeventDelArray.push(resource.id);
                            component.set("v.deleteEvents", objeventDelArray);
                            $('#calendar').fullCalendar('removeResource', resource);
                            $('#calendar').fullCalendar('removeEvents', resource.id);
                        }
                    });
                }
                cellEls.on('dblclick', function() {
                    if (resource.isParentRecord) {
                        var title = prompt('Enter Activity Name');
                        if (title) {
                            $('#calendar').fullCalendar(
                                'addResource', {
                                    id: title,
                                    title: title,
                                    parentId: resource.id,
                                    providerName:resource.providerName
                                },
                                true // scroll to the new resource?
                            );


                        }
                    }
                });
            },

            viewRender: function(view, element) {
                if (view.name == "timelineThreeDays") {
                    $('.fc-timelineThreeDays-button').hide();
                }
            },
            eventOverlap:true,
            resourceAreaWidth: "15%",
            resourceLabelText: 'Job',
            resourcesInitiallyExpanded: true,
            resources: component.get("v.resourceList"),
            events: component.get("v.eventList")

        });
    });

0 个答案:

没有答案