3.0.0 • Published 3 months ago

@eqproject/eqp-calendar v3.0.0

Weekly downloads
-
License
-
Repository
-
Last release
3 months ago

Table of contents

Required

  • @fullcalendar/angular v5
  • @fullcalendar/daygrid v5
  • @fullcalendar/interaction v5
  • @fullcalendar/timegrid v5

Getting started

This package is a wrapper for the v5 FullCalendar calendar component. It extends the basic functionalities of the undelying package simplifying the configuration process through exposing a series of input.

Notes

It is based on FullCalendar v5.10.0, go to this link to read the official documentation.

Step 1: Install eqp-calendar:

NPM

npm install --save @eqproject/eqp-calendar

Step 2:

Import EqpCalendarModule:

import { EqpCalendarModule } from '@eqproject/eqp-calendar';

@NgModule({
  declarations: [AppComponent],
  imports: [
    EqpCalendarModule,
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

API

Inputs

InputTypeDefaultRequiredDescription
EventListArray<IEvent>new Array<IEvent>()noContains the list of events to display on the calendar.
CustomStyleany{ 'text-transform': 'capitalize' }noStyle to apply to the full-calendar tag through ngStyle attribute.
InitialViewstring"dayGridMonth"noSets the starting view mode of the calendar.
FirstDaynumber1noSets the first day of week.
ContentHeightstringnullnoSets the height of the events container cell.
Localestring"it-IT"noSets the locale of the component and manages the translations.
MonthButtonTextstring"Mese"noSets the label fot the month view mode button.
WeekButtonTextstring"Settimana"noSets the label fot the week view mode button.
DayButtonTextstring"Giorno"noSets the label fot the daily view mode button.
TodayButtonTextstring"Oggi"noSets the label fot the button to navigate to today's date.
ListButtonTextstring"Lista"noSets the label fot the month view mode button.
HeaderToolbarStartstring"title"noSets what to display in the LEFT section of the header toolbar of the full-calendar component (see notes below for more details).
HeaderToolbarCenterstring"dayGridMonth,timeGridWeek,timeGridDay"noSets what to display in the CENTER section of the header toolbar of the full-calendar component (see notes below for more details).
HeaderToolbarEndstring"today prev,next"noSets what to display in the RIGHT section of the header toolbar of the full-calendar component (see notes below for more details).
AllDayTextstring"Tutto il giorno"noSets the column name for the all-day column in the weekly and daily view mode.
EventOrderFunctionnullnoSets the function to sort events. It is similar to the .sort() typescript function and has to return -1, 0 or 1.
Notes

The HeaderToolbarStart, HeaderToolbarCenter and HeaderToolbarEnd sets what to display in each portion of the header. Each piece you want to display needes to be specified in one of the input and to separate them from one another in the same section you need to use a space or a comma. Names separated with space will have some margin between them, using a comma the pieces will be rendered attached. Open this link to read the official documentation.

Outputs

OutputEvent ArgumentsRequiredDescription
(OnViewDateChange)ViewDateChangeEventnoInvoked each time the displayed date range is changed, either if the user changes the view mode or navigates between dates. Returns an object containig the new start and end dates anche the current view mode.
(OnDateClick)DatenoInvoked when the user clicks on a date or a time slot. Returns the selected date.
(OnEventClick)IEventnoInvoked when the user clicks on an event. Returns the selected IEvent object.

Interfaces and Models used

IEvent Interface

PropertyTypeDescriptionExamples
start?DateSets when an event begins.-
end?DateSets when an event ends. If not specified the event will be marked as "all-day".-
startStr?stringAn ISO8601 string representation of the start date. If the event is all-day, there will not be a time part.-
endStr?stringAn ISO8601 string representation of the end date. If the event is all-day, there will not be a time part.-
id?stringA unique identifier of an event.-
groupId?stringEvents that share a groupId will be dragged and resized together automatically.-
allDay?booleanDetermines if the event is shown in the “all-day” section of relevant views. In addition, if true the time text is not displayed with the event.-
title?stringThe text that will appear on an event.-
url?stringA URL that will be visited when this event is clicked by the user. For more information on controlling this behavior, see the eventClick callback.-
display?stringThe rendering type of this event. Can be 'auto', 'block', 'list-item', 'background', 'inverse-background', or 'none'. See eventDisplay.-
startEditable?booleanThe value overriding the eventStartEditable setting for this specific event.-
durationEditable?booleanThe value overriding the eventDurationEditable setting for this specific event.
constraint?stringThe eventConstraint override for this specific event.-
overlap?booleanThe value overriding the eventOverlap setting for this specific event. If false, prevents this event from being dragged/resized over other events. Also prevents other events from being dragged/resized over this event. Does not accept a function.-
backgroundColor?stringThe eventBackgroundColor override for this specific event. Sets the background color of the event.-
borderColor?stringThe eventBorderColor override for this specific event. Sets the border color of the event.-
textColor?stringThe eventTextColor override for this specific event. Sets the text color of the event.-
classNames?Array<string>An array of strings like 'myclass1', myclass2' . Determines which HTML classNames will be attached to the rendered event.-
extendedProps?anyA plain object holding miscellaneous other properties specified during parsing. Receives properties in the explicitly given extendedProps hash as well as other non-standard properties. For example if the event is based on a different object you can store the source here.-
NOTES:

This interface is based on the FullCalendar Event Object. To read the official documentation click here.

ViewDateChangeEvent Model

PropertyTypeDescriptionExamples
dateStartDateRepresents the starting date displayed in current view mode.-
dateEndDateRepresents the ending date displayed in current view mode.-
viewModestringRepresent the current view mode.-

Use cases

Use Example in class :

<eqp-calendar [EventList]="eventList" [CustomStyle]="customStyle" [InitialView]="initialView" [FirstDay]="firstDay" [Locale]="locale"
    [EventOrder]="eventOrder" (OnViewDateChange)="onViewDateChange($event)" (OnDateClick)="onDateClick($event)"
    (OnEventClick)="onEventClick($event)">
</eqp-calendar>
    import { ViewDateChangeEvent } from '@eqproject/eqp-calendar';
    import { IEvent } from '@eqproject/eqp-calendar';

    eventList: Array<IEvent> = new Array<IEvent>();

    customStyle: any = { 'text-transform': 'capitalize' };
    initialView: string = "dayGridMonth";
    firstDay: number = 1;
    locale: string = "it-IT";
  
    // Example of a custom eventOrder function:
    eventOrder(eventA: IEvent, eventB: IEvent) {
        if (eventA && eventB)
            return (eventA.extendedProps.Priority > eventB.extendedProps.Priority) ? 1 : ((eventB.extendedProps.Priority > eventA.extendedProps.Priority) ? -1 : 0);
        else
            return 0;
    }
    
    onViewDateChange(event: ViewDateChangeEvent) {
        // TODO
    }

    onDateClick(event: Date) {
        // TODO
    }

    onEventClick(event: IEvent) {
        // TODO
    }

Credits

This library has been developed by EqProject SRL, for more info contact: info@eqproject.it