Class

Calendar

kiss.ui.Calendar(config)

The Calendar derives from DataComponent.

It's a powerful calendar with the following features:

  • various range of periods (1 week, 2 weeks, 3 weeks, 1 month)
  • 1 week + details view
  • choosing the fields to display in the cards
  • choosing the field to use as the date reference
  • complex filtering with combination of AND/OR filters
  • display the week-end or not
  • start the week on Monday or not
Constructor

# new Calendar(config)

Its a Custom Web Component. Do not use the constructor directly with the new keyword. Instead, use one of the 3 following methods:

Create the Web Component and call its init method:

const myCalendar = document.createElement("a-calendar").init(config)

Or use the shorthand for it:

const myCalendar = createCalendar({
  id: "my-calendar",
  color: "#00aaee",
  collection: kiss.app.collections["meetings"],
  
  // We can add custom methods, and also override default ones
  methods: {

     // Override the createRecord method
     createRecord(model) {
         // Create a record from this model
         console.log(model)
     },

     // Override the selectRecord method
     selectRecord(record) {
         // Show the clicked record
         console.log(record)
     },

     sayHello: () => console.log("Hello"),
  }
})

myCalendar.render()
Parameters:
Name Type Attributes Description
config object
date string <optional>

The initial date to display in the timeline (default = today)

period string <optional>

"month" (default) | "3 weeks" | "2 weeks" | "1 week" | "1 week + details"

startOnMonday boolean <optional>
showWeekend boolean <optional>
dateField string

The field to use as reference for the calendar

timeField string <optional>
collection Collection

The data source collection

record object <optional>

Record to persist the view configuration into the db

columns Array.<object> <optional>

Where each column is: {title: "abc", type: "text|number|integer|float|date|button", id: "fieldId", button: {config}, renderer: function() {}}

color string <optional>

Hexa color code. Ex: #00aaee

showToolbar boolean <optional>

false to hide the toolbar (default = true)

showActions boolean <optional>

false to hide the custom actions button (default = true)

showSetup boolean <optional>

false to hide the setup button (default = true)

canFilter boolean <optional>

false to hide the filter button (default = true)

canSelectFields boolean <optional>

false to hide the button to select fields (default = true)

canChangePeriod boolean <optional>

false to hide the possibility to change period (1 month, 2 weeks...) (default = true)

canCreateRecord boolean <optional>

Can we create new records from the calendar?

actions Array.<object> <optional>

Array of menu actions, where each menu entry is: {text: "abc", icon: "fas fa-check", action: function() {}}

width number | string <optional>
height number | string <optional>

View Source client/ui/data/calendar.js, line 49

this

Generated markup

<a-calendar class="a-calendar">
     <div class="calendar-toolbar">
         <!-- Calendar toolbar items -->
     </div>
     <div class="calendar-body">
         <!-- Calendar entries here -->
     </div>
</a-calendar>

Methods

# async reload()

Reload the data and re-render

View Source client/ui/data/calendar.js, line 181

# async setColor(newColor)

Update the calendar color (toolbar buttons + modal windows)

Parameters:
Name Type Description
newColor string

View Source client/ui/data/calendar.js, line 201

# showCalendar(date)

Show the calendar at a given date

Parameters:
Name Type Description
date date | string

Date given as a Date or an ISO date string like "2023-06-24"

View Source client/ui/data/calendar.js, line 215

this

# showFieldsWindow()

Show the window just under the fields selector button

View Source client/ui/data/calendar.js, line 397

# showFilterWindow()

Show the window just under the filter button

View Source client/ui/data/calendar.js, line 406

# showSetupWindow()

Show the window to setup the calendar:

  • source date field
  • source time field
  • prefered layout (1 month, 2 weeks, 1 week...)
  • show week-ends
  • week starts on monday

View Source client/ui/data/calendar.js, line 236

# updateLayout()

Update the calendar layout

View Source client/ui/data/calendar.js, line 190