-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev-v0.2.4' into feature-drawer-component
- Loading branch information
Showing
13 changed files
with
347 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div id="fleetbase-full-calendar" class="fleetbase-full-calendar" {{did-insert this.setupCalendar}}></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
import { classify } from '@ember/string'; | ||
import { Calendar } from '@fullcalendar/core'; | ||
import dayGridPlugin from '@fullcalendar/daygrid'; | ||
import interactionPlugin from '@fullcalendar/interaction'; | ||
|
||
export default class FullCalendarComponent extends Component { | ||
/** | ||
* @var {HTMLElement} calendarEl | ||
*/ | ||
@tracked calendarEl; | ||
|
||
/** | ||
* @var {Calendar} calendar | ||
* @package @fullcalendar/core | ||
*/ | ||
@tracked calendar; | ||
|
||
/** | ||
* Default events to trigger for | ||
* @var {Array} | ||
*/ | ||
@tracked events = ['dateClick', 'drop', 'eventReceive', 'eventClick', 'eventDragStop', 'eventDrop', 'eventAdd', 'eventChange', 'eventRemove']; | ||
|
||
/** | ||
* Tracked calendar event listeners | ||
* @var {Array} | ||
*/ | ||
@tracked _listeners = []; | ||
|
||
/** | ||
* Initializes and renders the calendar component | ||
* | ||
* @param {HTMLElement} calendarEl | ||
*/ | ||
@action setupCalendar(calendarEl) { | ||
// track calendar htmlelement | ||
this.calendarEl = calendarEl; | ||
|
||
// get events | ||
let events = this.args.events || []; | ||
|
||
// initialize calendar | ||
this.calendar = new Calendar(calendarEl, { | ||
events, | ||
plugins: [dayGridPlugin, interactionPlugin], | ||
initialView: 'dayGridMonth', | ||
editable: true, | ||
headerToolbar: { | ||
left: 'prev,next today', | ||
center: 'title', | ||
right: '', | ||
}, | ||
}); | ||
|
||
// trigger callback on initialize | ||
if (typeof this.args.onInit === 'function') { | ||
this.args.onInit(this.calendar); | ||
} | ||
|
||
// render calendar | ||
this.calendar.render(); | ||
|
||
// listen for events | ||
this.createCalendarEventListeners(); | ||
} | ||
|
||
triggerCalendarEvent(eventName, ...params) { | ||
if (typeof this[eventName] === 'function') { | ||
this[eventName](...params); | ||
} | ||
|
||
if (typeof this.args[eventName] === 'function') { | ||
this.args[eventName](...params); | ||
} | ||
} | ||
|
||
createCalendarEventListeners() { | ||
for (let i = 0; i < this.events.length; i++) { | ||
const eventName = this.events.objectAt(i); | ||
const callbackName = `on${classify(eventName)}`; | ||
|
||
if (typeof this.args[callbackName] === 'function') { | ||
// track for destroy purposes | ||
this._listeners.pushObject({ | ||
eventName, | ||
callbackName, | ||
}); | ||
|
||
// create listener | ||
this.calendar.on(eventName, this.triggerCalendarEvent.bind(this, callbackName)); | ||
} | ||
} | ||
|
||
// check for custom events | ||
// @todo | ||
} | ||
|
||
destroyCalendarEventListeners() { | ||
for (let i = 0; i < this._listeners.length; i++) { | ||
const listener = this._listeners.objectAt(i); | ||
const { eventName, callbackName } = listener; | ||
|
||
// kill listener | ||
this.calendar.off(eventName, this.triggerCalendarEvent.bind(this, callbackName)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="fleetbase-full-calendar-draggable" data-event={{@eventData}} {{did-insert this.makeDraggable}} ...attributes> | ||
{{yield}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
import { Draggable } from '@fullcalendar/interaction'; | ||
|
||
export default class DraggableFullcalendarEventComponent extends Component { | ||
@tracked draggable; | ||
@tracked eventData = {}; | ||
|
||
constructor() { | ||
super(...arguments); | ||
this.eventData = this.args.eventData ?? {}; | ||
} | ||
|
||
@action makeDraggable(element) { | ||
this.draggable = new Draggable(element); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { helper } from '@ember/component/helper'; | ||
|
||
export default helper(function jsonHash(positional /*, named*/) { | ||
return positional; | ||
export default helper(function jsonHash(positional, named) { | ||
let json = JSON.stringify(named); | ||
return json; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
.fleetbase-full-calendar .fc-toolbar-title { | ||
@apply text-base text-gray-900 font-semibold; | ||
} | ||
|
||
body[data-theme='dark'] .fleetbase-full-calendar.fc .fc-toolbar-title { | ||
@apply text-gray-200; | ||
} | ||
|
||
.fleetbase-full-calendar.fc td, | ||
.fleetbase-full-calendar.fc th { | ||
@apply border-gray-200; | ||
} | ||
|
||
body[data-theme='dark'] .fleetbase-full-calendar.fc td, | ||
body[data-theme='dark'] .fleetbase-full-calendar.fc th { | ||
@apply border-gray-700; | ||
} | ||
|
||
.fleetbase-full-calendar.fc table.fc-scrollgrid { | ||
@apply border-gray-200; | ||
} | ||
|
||
body[data-theme='dark'] .fleetbase-full-calendar.fc table.fc-scrollgrid { | ||
@apply border-gray-700; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-button { | ||
@apply inline-flex items-center px-3 py-2 text-sm font-medium leading-4 transition duration-150 ease-in-out border border-transparent rounded-md text-gray-800; | ||
cursor: default !important; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-button:disabled, | ||
.fleetbase-full-calendar.fc .fc-button-primary:disabled, | ||
body[data-theme='dark'] .fleetbase-full-calendar.fc .fc-button-primary:disabled { | ||
@apply opacity-50 cursor-not-allowed; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-button .fc-icon { | ||
font-size: 1rem; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-toolbar { | ||
justify-content: start; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-toolbar.fc-header-toolbar { | ||
margin-bottom: 1rem; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-toolbar > .fc-toolbar-chunk { | ||
margin-right: 1.25rem; | ||
} | ||
|
||
body[data-theme='dark'] .fleetbase-full-calendar.fc .fc-button-primary { | ||
@apply text-gray-300 bg-gray-700 border-gray-900 shadow; | ||
} | ||
|
||
body[data-theme='dark'] .fleetbase-full-calendar.fc .fc-button-primary:hover:not(:disabled) { | ||
@apply text-gray-200 bg-gray-600; | ||
} | ||
|
||
body[data-theme='dark'] .fleetbase-full-calendar.fc .fc-button-primary:focus { | ||
@apply outline-0; | ||
} | ||
|
||
body[data-theme='dark'] .fleetbase-full-calendar.fc .fc-button-primary:active:not(:disabled) { | ||
@apply text-gray-300 bg-gray-600; | ||
} | ||
|
||
body[data-theme='dark'] .fleetbase-full-calendar.fc .fc-button .fc-icon { | ||
@apply text-gray-300; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-button-primary { | ||
@apply bg-white border-gray-300 shadow-sm text-gray-800; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-button-primary:hover:not(:disabled) { | ||
@apply text-gray-500 | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-button-primary:focus { | ||
@apply border-gray-300 outline-0; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-button-primary:active:not(:disabled) { | ||
@apply text-gray-800 bg-gray-50; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-button .fc-icon { | ||
@apply text-gray-900; | ||
} | ||
|
||
.fleetbase-full-calendar.fc .fc-button-primary:not(:disabled).fc-button-active:focus, | ||
.fleetbase-full-calendar.fc .fc-button-primary:not(:disabled):active:focus, | ||
body[data-theme='dark'] .fleetbase-full-calendar.fc .fc-button-primary:not(:disabled).fc-button-active:focus, | ||
body[data-theme='dark'] .fleetbase-full-calendar.fc .fc-button-primary:not(:disabled):active:focus { | ||
box-shadow: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from '@fleetbase/ember-ui/components/full-calendar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from '@fleetbase/ember-ui/components/full-calendar/draggable'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.