twinssbc / Ionic-Calendar

A calendar directive for Ionic framework
http://twinssbc.github.io/Ionic-Calendar/demo
MIT License
159 stars 73 forks source link

Understanding your code better - List and Year views #20

Closed antoine92190 closed 8 years ago

antoine92190 commented 8 years ago

Hello again! I'm trying to customize your Week view, and create a List and Year views on top of your calendar. I'd like to have a better understanding of your code in order to take a good advantage of it.

=> List view: I'm trying to get all events in a single page, and order those by days.

list

=> Week view: same as above, but using the sliding option to navigate between weeks.

week

=> Year view: I want to display 12 months in a single page, and use the sliding option to navigate between years.

year

It would help me so much to have your input about that and understand if and how those can be implemented using your calendar.

Again, thank you so much for everything!

twinssbc commented 8 years ago

@antoine92190 Sure. I'd like to help you. The view switching is controlled using ng-switch-when in the calendar.html, so you just need to add your own directive. CalendarController is the main controller which contains some common logic, for example, slide change callback, place event logic. You will see in some methods the main controller is calling the method having the underscore prefix, these underscore methods need to be implemented in the child controller. So it gives the child controller the chance to implement the customised logic. For example, in the self.onEventSourceChanged method, it calls _onDataLoaded method, and each view has its own way to load the data. The main workflow is when the view is loaded, it calls self.render -> self.refreshView -> this._refreshView -> self.rangeChanged -> $scope.rangeChanged When you slide the view, the workflow is scope.slideChanged -> self.move -> self.refreshView -> the same afterwards.

Let me know if you need more explanation. Thanks!

antoine92190 commented 8 years ago

Thanks a lot for your explanation, I'll work on that and maybe ask you more later. Thanks again!