Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose internal date and add support for events in calendar view #70

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jeffhuys
Copy link

Exposing the internal date object
I've added support for exposing the internal date object of the calendar view. You can use this as follows:

<div pickadate ng-model="calendarDate" current-date="calendarCurrentDate"></div>

Now, calendarCurrentDate will be the Date object of the calendars' current view. For instance, when the user sees "December 2015", and calls calendarCurrentDate.getMonth() it will return the month number.

Showing events on the calendar
I've also added support for supplying an array with formatted dates to show in the calendar. Use it like this:

<div pickadate ng-model="calendarDate" dates-with-events="calendarPopulatedDates"></div>

In my case, I've added dates like this:

// Get all events from the API
Event.getAll(function(events) {
    console.log('Events retrieved', events);
    $scope.events = events;

    // Add every event to the calendar
    events.forEach(function(event) {
        var date = new Date(event.begin * 1000);
        var year = date.getFullYear().toString();
        var month = (date.getMonth()+1).toString();
        var day = date.getDate().toString();

        $scope.calendarPopulatedDates.push(year + '-' + (month[1]? month : '0'+month[0]) + '-' + (day[1]? day : '0' + day[0]));
    });
});

Note: this may not be the most efficient way to do this.

It looks like this:

screen shot 2015-12-15 at 14 21 58

To conclude

This is one of my first pull requests. I hope everything is right! If not, please let me know. I'll gladly update my code.

@restorandodeploy
Copy link

By analyzing the blame information on this pull request, we identified @gschammah, @ndrisso and @asharbitz to be potential reviewers

@jeffhuys
Copy link
Author

The build seems to have failed. I've updated the code.

EDIT: If someone could help me out with parsing the errors, I'd appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants