How to disable set random order of schedule in TUI-Calendar

Viewed 1701

I am using toast UI calendar for making schedule management in the Laravel project. But I need to disable random order of schedule every day.

This is screenshot This is before clicking the refresh button

If I click the refresh button it will change like the below screenshot. This is after clicking the refresh button

This is generateSchedule function

function generateSchedule(viewName, renderStart, renderEnd, check_key) {
  ScheduleList = [];
  realize_schedule.forEach(function(real_item){
    var i = 0, length = 1;
    if (viewName === 'month') {
      length = 1;
    } else if (viewName === 'day') {
      length = 2;
    }
    for (i; i < length; i += 1) {
      var index_calendar = real_item.roomRate_type;
      if(index_calendar > 0){
        index_calendar = index_calendar-1;
      }
      if(check_key === ""){
        generateRandomSchedule(CalendarList[index_calendar], real_item, new Date(real_item.start), new Date(real_item.end));
      }else{
        if(check_key === real_item.roomRate_nameCode){
          generateRandomSchedule(CalendarList[index_calendar], real_item, new Date(real_item.start), new Date(real_item.end));
        }
      }
    }
  })
}

This is generateRandomSchedule function

function generateRandomSchedule(calendar, roomRate, renderStart, renderEnd) {
  var schedule = new ScheduleInfo();

  schedule.id = roomRate.id;
  schedule.calendarId = calendar.id;

  schedule.title = calendar.name;
  schedule.body = roomRate.roomRate_nameCode;
  schedule.isReadOnly = false;
  generateTime(schedule, renderStart, renderEnd);
  schedule.isPrivate = false;
  schedule.location = roomRate.roomRate_value;
  schedule.state =roomRate.status;
  schedule.attendees=[roomRate.night_stayval];
  schedule.recurrenceRule = roomRate.allotmant;

  schedule.color = calendar.color;
  schedule.bgColor = calendar.bgColor;
  schedule.dragBgColor = calendar.dragBgColor;
  schedule.borderColor = calendar.borderColor;

  if (schedule.category === 'milestone') {
    schedule.color = schedule.bgColor;
    schedule.bgColor = 'transparent';
    schedule.dragBgColor = 'transparent';
    schedule.borderColor = 'transparent';
  }

  schedule.raw.memo = chance.sentence();
  schedule.raw.creator.name = chance.name();
  schedule.raw.creator.avatar = chance.avatar();
  schedule.raw.creator.company = chance.company();
  schedule.raw.creator.email = chance.email();
  schedule.raw.creator.phone = chance.phone();
  schedule.raw.creator.bug = "";

  if (chance.bool({ likelihood: 20 })) {
    var travelTime = chance.minute();
    schedule.goingDuration = travelTime;
    schedule.comingDuration = travelTime;
  }

  ScheduleList.push(schedule);
}

So I want to disable that random feature for schedule order in the day field. Please help me if anybody has experience in it.

5 Answers

Please see this... enter link description here

You can see reference code from that url. If you want to disable random to set order of schedule, it may changed some code of libarary.

I think it is impossible because these schedule are arranged random. So you should to use createSchedules function orderly.

For example, you create schedule with this function one by one. I think this is only solution for that.

You should to change content of gnerateRandomSchedule. I think it is better to upload that function too.

I think you should change child order of realize_schedule list. In generateSchedule, this list is explained orderly.

realize_schedule.forEach(function(real_item){
  var i = 0, length = 1;
  if (viewName === 'month') {
    length = 1;
  } else if (viewName === 'day') {
    length = 2;
  }
  for (i; i < length; i += 1) {
    var index_calendar = real_item.roomRate_type;
    if(index_calendar > 0){
      index_calendar = index_calendar-1;
    }
    if(check_key === ""){
      generateRandomSchedule(CalendarList[index_calendar], real_item, new Date(real_item.start), new Date(real_item.end));
    }else{
      if(check_key === real_item.roomRate_nameCode){
        generateRandomSchedule(CalendarList[index_calendar], real_item, new Date(real_item.start), new Date(real_item.end));
      }
    }
  }
})

So do like that.

I think about this problem for long times. But it is impossible to arrange orderly. Because this use createSchedules function to create schedules. Before calling this function, schedules are arranged orderly.

This is code example.

function setSchedules() {
  cal.clear();
  generateSchedule(cal.getViewName(), cal.getDateRangeStart(), cal.getDateRangeEnd(), filter_Code);
  cal.createSchedules(ScheduleList);
  console.log(ScheduleList);
  refreshScheduleVisibility();
}

You can see scheduleList with console.log(). Sorry for making code in hand.

If you have any question, let me know.

Related