Skip to content

Commit

Permalink
move utils to c/calendarUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
effordDev committed Jan 26, 2023
1 parent 7f103f6 commit dd05651
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 67 deletions.
2 changes: 1 addition & 1 deletion force-app/main/default/lwc/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { api, LightningElement } from 'lwc';
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import fullCalendar from "@salesforce/resourceUrl/fullCalendar";
import { loadStyle, loadScript } from "lightning/platformResourceLoader";
import { jsToApexDate, invertColor, msToHMS} from './utils'
import { jsToApexDate } from 'c/calendarUtils'
export default class Calendar extends LightningElement {

calendarLabel = ''
Expand Down
62 changes: 0 additions & 62 deletions force-app/main/default/lwc/calendar/utils.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { createElement } from 'lwc';
import CalendarUtils from 'c/calendarUtils';

describe('c-calendar-utils', () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file so reset the DOM
while (document.body.firstChild) {
document.body.removeChild(document.body.firstChild);
}
});

it('TODO: test case generated by CLI command, please fill in test logic', () => {
// Arrange
const element = createElement('c-calendar-utils', {
is: CalendarUtils
});

// Act
document.body.appendChild(element);

// Assert
// const div = element.shadowRoot.querySelector('div');
expect(1).toBe(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const formatEvents = (events, config) => {
return events.map(event => {
event.id = event.Id
// event.status = event.Shift_Status__c
event.title = event?.Name
event.title = event[config.titleField]
event.start = event[config.startDatetimeField]
event.end = event[config.endDatetimeField]
// event.textColor = invertColor(event?.Color__c, true)
Expand All @@ -57,5 +57,4 @@ const jsToApexDate = (date) => {
return `${year}-${month}-${day}`
}


export { formatEvents, jsToApexDate }
export { formatEvents, jsToApexDate }
4 changes: 3 additions & 1 deletion force-app/main/default/lwc/customCalendar/customCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled } from 'lig
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'
import Id from '@salesforce/user/Id';
import getEvents from "@salesforce/apex/CustomCalendarHelper.getEvents"
import { formatEvents } from "./utilities"
import { formatEvents } from "c/calendarUtils"
export default class CustomCalendar extends NavigationMixin(LightningElement) {
@api recordId
@api childObject
@api parentFieldName
@api startDatetimeField
@api endDatetimeField
@api titleField
@api channelName

userId = Id
Expand Down Expand Up @@ -60,6 +61,7 @@ export default class CustomCalendar extends NavigationMixin(LightningElement) {
parentFieldName: this.parentFieldName,
startDatetimeField: this.startDatetimeField,
endDatetimeField: this.endDatetimeField,
titleField: this.titleField,
startDate: this.startDate,
endDate: this.endDate
}
Expand Down

0 comments on commit dd05651

Please sign in to comment.