Skip to content

Commit e63fdbb

Browse files
Integrated latest changes at 05-31-2024 1:30:44 PM
1 parent 13e2147 commit e63fdbb

File tree

8 files changed

+282
-152
lines changed

8 files changed

+282
-152
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { LightningElement, api } from 'lwc';
2+
import { ShowToastEvent } from "lightning/platformShowToastEvent";
3+
import { loadStyle, loadScript } from "lightning/platformResourceLoader";
4+
import { createRecord, updateRecord, deleteRecord } from "lightning/uiRecordApi";
5+
// Static resources
6+
import schedulerFiles from "@salesforce/resourceUrl/syncfusionscheduler";
7+
8+
// Controllers
9+
import getEvents from "@salesforce/apex/SchedulerData.getEvents";
10+
function getEventsData(eventData) {
11+
const data = eventData.events.map((a) => ({
12+
Id: a.Id,
13+
Subject: a.Name,
14+
Location: a.Location__c,
15+
StartTime: a.Start_Time__c,
16+
EndTime: a.End_Time__c,
17+
IsAllDay: a.IsAllDay__c,
18+
RecurrenceRule: a.RecurrenceRule__c,
19+
RecurrenceID: a.Recurrence_Id__c,
20+
RecurrenceException: a.RecurrenceException__c
21+
}));
22+
return data;
23+
}
24+
25+
export default class Scheduler extends LightningElement {
26+
static delegatesFocus = true;
27+
@api height;
28+
schedulerInitialized = false;
29+
renderedCallback() {
30+
if (this.schedulerInitialized) {
31+
return;
32+
}
33+
this.schedulerInitialized = true;
34+
Promise.all([
35+
loadScript(this, schedulerFiles + "/syncscheduler.js"),
36+
loadStyle(this, schedulerFiles + "/syncscheduler.css")
37+
])
38+
.then(() => {
39+
this.initializeUI();
40+
})
41+
.catch((error) => {
42+
this.dispatchEvent(
43+
new ShowToastEvent({
44+
title: "Error loading scheduler",
45+
message: error.message,
46+
variant: "error"
47+
})
48+
);
49+
});
50+
}
51+
initializeUI() {
52+
const root = this.template.querySelector(".syncfusionscheduler");
53+
root.style.height = this.height + "px";
54+
const scheduleOptions = {
55+
height: this.height + "px",
56+
selectedDate: new Date(),
57+
actionComplete: function (args) {
58+
//To perform CRUD in salesforce backend
59+
if (args.addedRecords && args.addedRecords.length > 0) {
60+
var data = args.addedRecords[0];
61+
var insert = {
62+
apiName: "SchedulerEvent__c",
63+
fields: {
64+
Name: data.Subject,
65+
Location__c: data.Location,
66+
Start_Time__c: data.StartTime,
67+
End_Time__c: data.EndTime,
68+
IsAllDay__c: data.IsAllDay,
69+
RecurrenceRule__c: data.RecurrenceRule,
70+
Recurrence_Id__c: data.RecurrenceID,
71+
RecurrenceException__c: data.RecurrenceException
72+
}
73+
};
74+
createRecord(insert).then((res) => {
75+
if (scheduleObj)
76+
{
77+
scheduleObj.eventSettings.dataSource[scheduleObj.eventSettings.dataSource.length - 1].Id = res.id;
78+
scheduleObj.refreshEvents();
79+
}
80+
return { tid: res.id, ...res };
81+
});
82+
}
83+
if (args.changedRecords && args.changedRecords.length > 0) {
84+
var data = args.changedRecords[0];
85+
var update = {
86+
fields: {
87+
Id: data.Id,
88+
Name: data.Subject,
89+
Location__c: data.Location,
90+
Start_Time__c: data.StartTime,
91+
End_Time__c: data.EndTime,
92+
IsAllDay__c: data.IsAllDay,
93+
RecurrenceRule__c: data.RecurrenceRule,
94+
RecurrenceException__c: data.RecurrenceException,
95+
Recurrence_Id__c: data.RecurrenceID
96+
}
97+
};
98+
updateRecord(update).then(() => ({}));
99+
}
100+
if (args.deletedRecords && args.deletedRecords.length > 0) {
101+
args.deletedRecords.forEach(event => {
102+
deleteRecord(event.Id).then(() => ({}));
103+
});
104+
}
105+
}
106+
};
107+
const scheduleObj = new ej.schedule.Schedule(scheduleOptions, root);
108+
getEvents().then((data) => {
109+
const eventData = getEventsData(data);
110+
scheduleObj.eventSettings.dataSource = eventData;
111+
scheduleObj.dataBind();
112+
});
113+
}
114+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
2+
3+
import { LightningElement, api } from 'lwc';
4+
import { ShowToastEvent } from "lightning/platformShowToastEvent";
5+
import { loadStyle, loadScript } from "lightning/platformResourceLoader";
6+
import { createRecord, updateRecord, deleteRecord } from "lightning/uiRecordApi";
7+
// Static resources
8+
import schedulerFiles from "@salesforce/resourceUrl/syncfusionscheduler";
9+
10+
// Controllers
11+
import getEvents from "@salesforce/apex/SchedulerData.getEvents";
12+
function getEventsData(eventData) {
13+
const data = eventData.events.map((a) => ({
14+
Id: a.Id,
15+
Subject: a.Name,
16+
Location: a.Location__c,
17+
StartTime: a.Start_Time__c,
18+
EndTime: a.End_Time__c,
19+
IsAllDay: a.IsAllDay__c,
20+
RecurrenceRule: a.RecurrenceRule__c,
21+
RecurrenceID: a.Recurrence_Id__c,
22+
RecurrenceException: a.RecurrenceException__c
23+
}));
24+
return data;
25+
}
26+
27+
export default class Scheduler extends LightningElement {
28+
static delegatesFocus = true;
29+
@api height;
30+
schedulerInitialized = false;
31+
renderedCallback() {
32+
if (this.schedulerInitialized) {
33+
return;
34+
}
35+
this.schedulerInitialized = true;
36+
Promise.all([
37+
loadScript(this, schedulerFiles + "/syncscheduler.js"),
38+
loadStyle(this, schedulerFiles + "/syncscheduler.css")
39+
])
40+
.then(() => {
41+
this.initializeUI();
42+
})
43+
.catch((error) => {
44+
this.dispatchEvent(
45+
new ShowToastEvent({
46+
title: "Error loading scheduler",
47+
message: error.message,
48+
variant: "error"
49+
})
50+
);
51+
});
52+
}
53+
initializeUI() {
54+
const root = this.template.querySelector(".syncfusionscheduler");
55+
root.style.height = this.height + "px";
56+
const scheduleOptions = {
57+
height: this.height + "px",
58+
selectedDate: new Date(),
59+
actionComplete: function (args) {
60+
//To perform CRUD in salesforce backend
61+
if (args.addedRecords && args.addedRecords.length > 0) {
62+
var data = args.addedRecords[0];
63+
var insert = {
64+
apiName: "SchedulerEvent__c",
65+
fields: {
66+
Name: data.Subject,
67+
Location__c: data.Location,
68+
Start_Time__c: data.StartTime,
69+
End_Time__c: data.EndTime,
70+
IsAllDay__c: data.IsAllDay,
71+
RecurrenceRule__c: data.RecurrenceRule,
72+
Recurrence_Id__c: data.RecurrenceID,
73+
RecurrenceException__c: data.RecurrenceException
74+
}
75+
};
76+
createRecord(insert).then((res) => {
77+
if (scheduleObj)
78+
{
79+
scheduleObj.eventSettings.dataSource[scheduleObj.eventSettings.dataSource.length - 1].Id = res.id;
80+
scheduleObj.refreshEvents();
81+
}
82+
return { tid: res.id, ...res };
83+
});
84+
}
85+
if (args.changedRecords && args.changedRecords.length > 0) {
86+
var data = args.changedRecords[0];
87+
var update = {
88+
fields: {
89+
Id: data.Id,
90+
Name: data.Subject,
91+
Location__c: data.Location,
92+
Start_Time__c: data.StartTime,
93+
End_Time__c: data.EndTime,
94+
IsAllDay__c: data.IsAllDay,
95+
RecurrenceRule__c: data.RecurrenceRule,
96+
RecurrenceException__c: data.RecurrenceException,
97+
Recurrence_Id__c: data.RecurrenceID
98+
}
99+
};
100+
updateRecord(update).then(() => ({}));
101+
}
102+
if (args.deletedRecords && args.deletedRecords.length > 0) {
103+
args.deletedRecords.forEach(event => {
104+
deleteRecord(event.Id).then(() => ({}));
105+
});
106+
}
107+
}
108+
};
109+
const scheduleObj = new ej.schedule.Schedule(scheduleOptions, root);
110+
getEvents().then((data) => {
111+
const eventData = getEventsData(data);
112+
scheduleObj.eventSettings.dataSource = eventData;
113+
scheduleObj.dataBind();
114+
});
115+
}
116+
}

ej2-javascript/common/internationalization.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ Apart from the standard date type formats additional format are supported by usi
322322
| h / H | Denotes the hour. *h* for 12 hour and *H* for 24 hours format. |
323323
| m | Denotes minutes. |
324324
| s | Denotes seconds. |
325+
| f | Denotes milliseconds. |
325326
| a | Denotes the am/pm designator it will only be displayed if hour is specified in the h format. |
326327
| z | Denotes the time zone. |
327328
| ' (single quotes) | To display words in the formatted date you can specify the words with in the single quotes |

0 commit comments

Comments
 (0)