rust rhai ui components wip
This commit is contained in:
54
examples/calendar/backend/models/calendar_model.rhai
Normal file
54
examples/calendar/backend/models/calendar_model.rhai
Normal file
@@ -0,0 +1,54 @@
|
||||
// calendar_model.rhai - Calendar data model
|
||||
|
||||
// Create a new calendar object
|
||||
fn create_calendar(id, name, owner_id, description, color, shared_with, visibility) {
|
||||
return #{
|
||||
id: id,
|
||||
name: name,
|
||||
owner_id: owner_id,
|
||||
description: description,
|
||||
color: color,
|
||||
shared_with: shared_with,
|
||||
visibility: visibility
|
||||
};
|
||||
}
|
||||
|
||||
// Sample calendars data
|
||||
fn get_sample_calendars() {
|
||||
let calendars = [];
|
||||
|
||||
// Calendar 1: Work Calendar
|
||||
calendars.push(create_calendar(
|
||||
"cal1",
|
||||
"Work Calendar",
|
||||
"user1",
|
||||
"Main work calendar for team coordination",
|
||||
"#4285F4",
|
||||
["user2", "user3", "user4"],
|
||||
"team"
|
||||
));
|
||||
|
||||
// Calendar 2: Personal Calendar
|
||||
calendars.push(create_calendar(
|
||||
"cal2",
|
||||
"Personal Calendar",
|
||||
"user1",
|
||||
"Personal appointments and reminders",
|
||||
"#0F9D58",
|
||||
["user5"],
|
||||
"private"
|
||||
));
|
||||
|
||||
// Calendar 3: Project Calendar
|
||||
calendars.push(create_calendar(
|
||||
"cal3",
|
||||
"Project Calendar",
|
||||
"user2",
|
||||
"Project-specific deadlines and milestones",
|
||||
"#DB4437",
|
||||
["user1", "user3", "user4"],
|
||||
"public"
|
||||
));
|
||||
|
||||
return calendars;
|
||||
}
|
92
examples/calendar/backend/models/event_model.rhai
Normal file
92
examples/calendar/backend/models/event_model.rhai
Normal file
@@ -0,0 +1,92 @@
|
||||
// event_model.rhai - Event data model
|
||||
|
||||
// Create a new event object
|
||||
fn create_event(id, title, description, start_time, end_time, location, calendar_id, organizer_id, attendees, recurring, status) {
|
||||
return #{
|
||||
id: id,
|
||||
title: title,
|
||||
description: description,
|
||||
start_time: start_time,
|
||||
end_time: end_time,
|
||||
location: location,
|
||||
calendar_id: calendar_id,
|
||||
organizer_id: organizer_id,
|
||||
attendees: attendees,
|
||||
recurring: recurring,
|
||||
status: status
|
||||
};
|
||||
}
|
||||
|
||||
// Create a recurring event object (extends regular event)
|
||||
fn create_recurring_event(id, title, description, start_time, end_time, location, calendar_id, organizer_id, attendees, recurrence_pattern, status) {
|
||||
let event = create_event(id, title, description, start_time, end_time, location, calendar_id, organizer_id, attendees, true, status);
|
||||
event.recurrence_pattern = recurrence_pattern;
|
||||
return event;
|
||||
}
|
||||
|
||||
// Sample events data
|
||||
fn get_sample_events() {
|
||||
let events = [];
|
||||
|
||||
// Event 1: Team Meeting
|
||||
events.push(create_event(
|
||||
"event1",
|
||||
"Team Meeting",
|
||||
"Weekly team sync meeting",
|
||||
"2025-04-04T10:00:00",
|
||||
"2025-04-04T11:00:00",
|
||||
"Conference Room A",
|
||||
"cal1",
|
||||
"user1",
|
||||
["user1", "user2", "user3"],
|
||||
false,
|
||||
"confirmed"
|
||||
));
|
||||
|
||||
// Event 2: Project Deadline
|
||||
events.push(create_event(
|
||||
"event2",
|
||||
"Project Deadline",
|
||||
"Final submission for Q2 project",
|
||||
"2025-04-15T17:00:00",
|
||||
"2025-04-15T18:00:00",
|
||||
"Virtual",
|
||||
"cal1",
|
||||
"user2",
|
||||
["user1", "user2", "user4"],
|
||||
false,
|
||||
"confirmed"
|
||||
));
|
||||
|
||||
// Event 3: Lunch with Client
|
||||
events.push(create_event(
|
||||
"event3",
|
||||
"Lunch with Client",
|
||||
"Discuss upcoming partnership",
|
||||
"2025-04-10T12:30:00",
|
||||
"2025-04-10T14:00:00",
|
||||
"Downtown Cafe",
|
||||
"cal2",
|
||||
"user1",
|
||||
["user1", "user5"],
|
||||
false,
|
||||
"tentative"
|
||||
));
|
||||
|
||||
// Event 4: Weekly Status Update (recurring)
|
||||
events.push(create_recurring_event(
|
||||
"event4",
|
||||
"Weekly Status Update",
|
||||
"Regular status update meeting",
|
||||
"2025-04-05T09:00:00",
|
||||
"2025-04-05T09:30:00",
|
||||
"Conference Room B",
|
||||
"cal1",
|
||||
"user3",
|
||||
["user1", "user2", "user3", "user4"],
|
||||
"weekly",
|
||||
"confirmed"
|
||||
));
|
||||
|
||||
return events;
|
||||
}
|
72
examples/calendar/backend/models/user_model.rhai
Normal file
72
examples/calendar/backend/models/user_model.rhai
Normal file
@@ -0,0 +1,72 @@
|
||||
// user_model.rhai - User data model
|
||||
|
||||
// Create user preferences object
|
||||
fn create_user_preferences(notification_time, default_calendar_id) {
|
||||
return #{
|
||||
notification_time: notification_time,
|
||||
default_calendar_id: default_calendar_id
|
||||
};
|
||||
}
|
||||
|
||||
// Create a new user object
|
||||
fn create_user(id, name, email, timezone, preferences) {
|
||||
return #{
|
||||
id: id,
|
||||
name: name,
|
||||
email: email,
|
||||
timezone: timezone,
|
||||
preferences: preferences
|
||||
};
|
||||
}
|
||||
|
||||
// Sample users data
|
||||
fn get_sample_users() {
|
||||
let users = [];
|
||||
|
||||
// User 1: John Doe
|
||||
users.push(create_user(
|
||||
"user1",
|
||||
"John Doe",
|
||||
"john.doe@example.com",
|
||||
"UTC+2",
|
||||
create_user_preferences(15, "cal1")
|
||||
));
|
||||
|
||||
// User 2: Jane Smith
|
||||
users.push(create_user(
|
||||
"user2",
|
||||
"Jane Smith",
|
||||
"jane.smith@example.com",
|
||||
"UTC+1",
|
||||
create_user_preferences(30, "cal1")
|
||||
));
|
||||
|
||||
// User 3: Bob Johnson
|
||||
users.push(create_user(
|
||||
"user3",
|
||||
"Bob Johnson",
|
||||
"bob.johnson@example.com",
|
||||
"UTC",
|
||||
create_user_preferences(10, "cal2")
|
||||
));
|
||||
|
||||
// User 4: Alice Brown
|
||||
users.push(create_user(
|
||||
"user4",
|
||||
"Alice Brown",
|
||||
"alice.brown@example.com",
|
||||
"UTC-5",
|
||||
create_user_preferences(20, "cal1")
|
||||
));
|
||||
|
||||
// User 5: Charlie Davis
|
||||
users.push(create_user(
|
||||
"user5",
|
||||
"Charlie Davis",
|
||||
"charlie.davis@example.com",
|
||||
"UTC+3",
|
||||
create_user_preferences(15, "cal2")
|
||||
));
|
||||
|
||||
return users;
|
||||
}
|
Reference in New Issue
Block a user