tui.ngx-calendar icon indicating copy to clipboard operation
tui.ngx-calendar copied to clipboard

I can't create an Event in more than 1 Calendar

Open wakadala opened this issue 3 years ago • 7 comments

When you clock anywhere in the calendar for the popup to show up, it does: and shows a drop down of calendars that were set-up in initialization of the calendar. The first calendar in the list works well enough, when its chosen, and then you save the event with required information, it saves the event in that calendar. But when I choose anyother calendar in the list, it returns calendar: false, no calendar ID. So the event is saved but without a calendar against it, so the calendar backgound color, etc are not applied.

Please help.

Thanks.

wakadala avatar Mar 28 '21 14:03 wakadala

Dooray! 메일 발송 실패 안내

메일 발송 실패 안내

@.***) 님께 보낸 메일이 전송되지 못하였습니다.

      실패 사유를 확인해보세요.
    




  
    
      
        * 받는 사람 : 

@.***)

        * 발송 시간 : 

2021-03-28T23:11:05

        * 메일 제목 : 

[nhn/tui.ngx-calendar] I can't create an Event in more than 1 Calendar (#10)

            * 실패 사유 : 
          
          
            

받는 사람이 회원님의 메일을 수신차단 하였습니다.

      이 메일은 발신전용으로 회신되지 않습니다.
      더 궁금하신 사항은
      ***@***.***
      으로 문의해 주시기 바랍니다.
    




    © Dooray!.

swtalk avatar Mar 28 '21 14:03 swtalk

Is this a reponse

Dooray! 메일 발송 실패 안내 메일 발송 실패 안내 @.) 님께 보낸 메일이 전송되지 못하였습니다. 실패 사유를 확인해보세요. * 받는 사람 :  @.) * 발송 시간 :  2021-03-28T23:11:05 * 메일 제목 :  [nhn/tui.ngx-calendar] I can't create an Event in more than 1 Calendar (#10) * 실패 사유 :  받는 사람이 회원님의 메일을 수신차단 하였습니다. 이 메일은 발신전용으로 회신되지 않습니다. 더 궁금하신 사항은 @.*** 으로 문의해 주시기 바랍니다. © Dooray!.

Is this a response to my question? I don't understand Chinese!

wakadala avatar Mar 28 '21 14:03 wakadala

Dooray! 메일 발송 실패 안내

메일 발송 실패 안내

@.***) 님께 보낸 메일이 전송되지 못하였습니다.

      실패 사유를 확인해보세요.
    




  
    
      
        * 받는 사람 : 

@.***)

        * 발송 시간 : 

2021-03-28T23:39:45

        * 메일 제목 : 

Re: [nhn/tui.ngx-calendar] I can't create an Event in more than 1 Calendar (#10)

            * 실패 사유 : 
          
          
            

받는 사람이 회원님의 메일을 수신차단 하였습니다.

      이 메일은 발신전용으로 회신되지 않습니다.
      더 궁금하신 사항은
      ***@***.***
      으로 문의해 주시기 바랍니다.
    




    © Dooray!.

swtalk avatar Mar 28 '21 14:03 swtalk

I fixed this like this: ` onBeforeCreateSchedule(event){ let calendar = this.calendars.find(cal => cal.id === event.calendarId); // get calendar from list of calendars upon saving the event - this is just to be sure that the new selected calendar is not false, and if its is, see below.

if(calendar === undefined){ // if indeed the new calendar didn't come through, here you find it from the native element
  let inputs = this.elm.nativeElement.querySelectorAll('.tui-full-calendar-popup button.tui-full-calendar-button.tui-full-calendar-popup-section-item'); // get all instances of the popup buttons
  for(var i = 0; i < inputs.length; i++){
      calendar = this.calendars.find(cal => cal.name == inputs[i].innerText.trim()); // find the selected button that corresponds to your list of calendars
      if(calendar){ // if calendar is matched, break out of the loop
        break;
      }
  }

  if(calendar === undefined){ // if loop completes and no match for the calendar is found, then, simply assign the calendar to the first calendar in your list to avoid unnecessary errors
    calendar = this.calendars[1];
  }
}

if(calendar){ // continue to define your schedule properties before saving
  event.id = event.id ? event.id : Math.random();
  event.category = calendar.category;
  event.calendarId = calendar.id;
  event.bgColor = calendar.bgColor;
  event.dragBgColor = calendar.dragBgColor;
  event.borderColor = calendar.borderColor;
  event.color = calendar.color;
  event.body = calendar.name + " Item.";
  event.dueDateClass = 'overdue_event';
}

this.tuiCalendar.createSchedules([event]);

} `

wakadala avatar Mar 28 '21 19:03 wakadala

I fixed this like this: ` onBeforeCreateSchedule(event){ let calendar = this.calendars.find(cal => cal.id === event.calendarId); // get calendar from list of calendars upon saving the event - this is just to be sure that the new selected calendar is not false, and if its is, see below.

if(calendar === undefined){ // if indeed the new calendar didn't come through, here you find it from the native element
  let inputs = this.elm.nativeElement.querySelectorAll('.tui-full-calendar-popup button.tui-full-calendar-button.tui-full-calendar-popup-section-item'); // get all instances of the popup buttons
  for(var i = 0; i < inputs.length; i++){
      calendar = this.calendars.find(cal => cal.name == inputs[i].innerText.trim()); // find the selected button that corresponds to your list of calendars
      if(calendar){ // if calendar is matched, break out of the loop
        break;
      }
  }

  if(calendar === undefined){ // if loop completes and no match for the calendar is found, then, simply assign the calendar to the first calendar in your list to avoid unnecessary errors
    calendar = this.calendars[1];
  }
}

if(calendar){ // continue to define your schedule properties before saving
  event.id = event.id ? event.id : Math.random();
  event.category = calendar.category;
  event.calendarId = calendar.id;
  event.bgColor = calendar.bgColor;
  event.dragBgColor = calendar.dragBgColor;
  event.borderColor = calendar.borderColor;
  event.color = calendar.color;
  event.body = calendar.name + " Item.";
  event.dueDateClass = 'overdue_event';
}

this.tuiCalendar.createSchedules([event]);

} `

wakadala avatar Mar 28 '21 19:03 wakadala

Dooray! 메일 발송 실패 안내

메일 발송 실패 안내

@.***) 님께 보낸 메일이 전송되지 못하였습니다.

      실패 사유를 확인해보세요.
    




  
    
      
        * 받는 사람 : 

@.***)

        * 발송 시간 : 

2021-03-29T04:16:05

        * 메일 제목 : 

Re: [nhn/tui.ngx-calendar] I can't create an Event in more than 1 Calendar (#10)

            * 실패 사유 : 
          
          
            

받는 사람이 회원님의 메일을 수신차단 하였습니다.

      이 메일은 발신전용으로 회신되지 않습니다.
      더 궁금하신 사항은
      ***@***.***
      으로 문의해 주시기 바랍니다.
    




    © Dooray!.

swtalk avatar Mar 28 '21 19:03 swtalk

Dooray! 메일 발송 실패 안내

메일 발송 실패 안내

@.***) 님께 보낸 메일이 전송되지 못하였습니다.

      실패 사유를 확인해보세요.
    




  
    
      
        * 받는 사람 : 

@.***)

        * 발송 시간 : 

2021-03-29T04:17:05

        * 메일 제목 : 

Re: [nhn/tui.ngx-calendar] I can't create an Event in more than 1 Calendar (#10)

            * 실패 사유 : 
          
          
            

받는 사람이 회원님의 메일을 수신차단 하였습니다.

      이 메일은 발신전용으로 회신되지 않습니다.
      더 궁금하신 사항은
      ***@***.***
      으로 문의해 주시기 바랍니다.
    




    © Dooray!.

swtalk avatar Mar 28 '21 19:03 swtalk