Role-Based Access
The following example demonstrates how to implement role-based permissions in a calendar by simulating a logged in user. The selected user determines which role and permissions are applied:
- Project manager (Full access) - can manage all tasks
- Employees (Limited access) - can only edit their own tasks
- Clients (Read-only) - can view the schedule without making changes
The demo uses an outside control to simulate logging in as a specific user. Based on the chosen role, the calendar applies the corresponding permissions conditionally.
This approach shows how you could pass the logged in user's role from your authentication system and dynamically configure what actions are allowed in the timeline.
Demo
html<mbsc-eventcalendar
[data]="myEvents"
[resources]="myResources"
[view]="myView"
[clickToCreate]="editEvents"
[dragToCreate]="editEvents"
[dragToMove]="editEvents"
[dragToResize]="editEvents"
[eventDelete]="editEvents"
[extendDefaultEvent]="myDefaultEvent">
</mbsc-eventcalendar>
ts// Simulated logged in user
user = {
};
editEvents = false;
myDefaultEvent(): MbscCalendarEvent {
return {};
}
myView: MbscEventcalendarView = {
timeline: {
type: 'week',
startTime: '08:00',
endTime: '20:00',
},
};
myEvents: MbscCalendarEvent[] = [{
start: '2026-10-24T11:00',
end: '2026-10-24T15:00',
title: 'Task 1',
resource: 1
}, {
start: '2026-10-24T14:00',
end: '2026-10-24T17:00',
title: 'Task 2',
resource: 3
}, {
start: '2026-10-24T12:00',
end: '2026-10-24T14:00',
title: 'Task 3',
resource: 4
}, {
start: '2026-10-25T10:00',
end: '2026-10-25T15:00',
title: 'Task 4',
resource: 1
}, {
start: '2026-10-25T11:00',
end: '2026-10-25T13:00',
title: 'Task 5',
resource: 2
}, {
start: '2026-10-25T14:00',
end: '2026-10-25T17:00',
title: 'Task 6',
resource: 2
}, {
start: '2026-10-25T12:00',
end: '2026-10-25T15:00',
title: 'Task 7',
resource: 3
}, {
start: '2026-10-25T17:00',
end: '2026-10-25T20:00',
title: 'Task 8',
resource: 3
}, {
start: '2026-10-25T08:00',
end: '2026-10-25T11:30',
title: 'Task 9',
resource: 4
}, {
start: '2026-10-25T12:00',
end: '2026-10-25T14:00',
title: 'Task 10',
resource: 4
}, {
start: '2026-10-25T10:00',
end: '2026-10-25T13:00',
title: 'Task 11',
resource: 5
}, {
start: '2026-10-25T14:00',
end: '2026-10-25T16:00',
title: 'Task 12',
resource: 5
}, {
start: '2026-10-25T16:30',
end: '2026-10-25T19:00',
title: 'Task 13',
resource: 5
}, {
start: '2026-10-26T11:00',
end: '2026-10-26T14:00',
title: 'Task 14',
resource: 2
}, {
start: '2026-10-26T16:00',
end: '2026-10-26T20:00',
title: 'Task 15',
resource: 5
}]
myResources: MbscResource[] = [{
id: 1,
name: 'Jude Chester',
color: '#af2ec3'
}, {
id: 2,
name: 'Willis Cane',
color: '#cccc39'
}, {
id: 3,
name: 'Derek Austyn',
color: '#56ca2c'
}, {
id: 4,
name: 'Merv Kenny',
color: '#af2424'
}, {
id: 5,
name: 'Fred Waldez',
color: '#256ebc'
}]
// Simulate login
login(): void {
const newTasks = [...this.myEvents];
const newResources = [...this.myResources];
let defaultColor = '';
if (this.user.role === 'readonly') {
for (const task of newTasks) {
// Disable editing for all events
task.editable = false;
// Make event colors uniform
task.color = '#af2ec3';
}
} else if (this.user.role === 'limited') {
defaultColor = '#af2424';
for (const task of newTasks) {
if (task.resource !== user.id) {
// Disable editing events of other users
task.editable = false
// Set disabled event colors to gray
task.color = '#6a6a6a'
} else {
// Make event colors uniform
task.color = '#af2424'
}
}
for (const res of newResources) {
if (res.id !== this.user.id) {
// Disable event creation for other users
res.eventCreation = false;
}
}
}
// Update events, resources and d&d options
this.myEvents = newTasks;
this.myResources = newResources;
this.editEvents = this.user.role != 'readonly';
this.myDefaultEvent = function (): MbscCalendarEvent {
return {
color: defaultColor
};
}
}
ngOnInit(): void {
this.login();
}

import { CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import {
MbscCalendarEvent,
MbscEventcalendarView,
MbscModule,
MbscResource,
Notifications,
setOptions ,
} from '@mobiscroll/angular';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
standalone: true,
imports: [CommonModule, MbscModule],
})
export class AppComponent implements OnInit {
constructor(private notify: Notifications) {}
user = { id: 2, name: 'Willis Cane', role: 'limited' };
/* Other user examples
user = { id: 'client', name: 'Client', role: 'readonly' };
user = { id: 'manager', name: 'Project Manager', role: 'full' }; */
editEvents = false;
defaultColor = '';
myView: MbscEventcalendarView = {
timeline: {
type: 'week',
startTime: '08:00',
endTime: '20:00',
},
};
myEvents: MbscCalendarEvent[] = [
{
start: '2026-10-24T11:00',
end: '2026-10-24T15:00',
title: 'Task 1',
resource: 1,
},
{
start: '2026-10-24T14:00',
end: '2026-10-24T17:00',
title: 'Task 2',
resource: 3,
},
{
start: '2026-10-24T12:00',
end: '2026-10-24T14:00',
title: 'Task 3',
resource: 4,
},
{
start: '2026-10-25T10:00',
end: '2026-10-25T15:00',
title: 'Task 4',
resource: 1,
},
{
start: '2026-10-25T11:00',
end: '2026-10-25T13:00',
title: 'Task 5',
resource: 2,
},
{
start: '2026-10-25T14:00',
end: '2026-10-25T17:00',
title: 'Task 6',
resource: 2,
},
{
start: '2026-10-25T12:00',
end: '2026-10-25T15:00',
title: 'Task 7',
resource: 3,
},
{
start: '2026-10-25T17:00',
end: '2026-10-25T20:00',
title: 'Task 8',
resource: 3,
},
{
start: '2026-10-25T08:00',
end: '2026-10-25T11:30',
title: 'Task 9',
resource: 4,
},
{
start: '2026-10-25T12:00',
end: '2026-10-25T14:00',
title: 'Task 10',
resource: 4,
},
{
start: '2026-10-25T10:00',
end: '2026-10-25T13:00',
title: 'Task 11',
resource: 5,
},
{
start: '2026-10-25T14:00',
end: '2026-10-25T16:00',
title: 'Task 12',
resource: 5,
},
{
start: '2026-10-25T16:30',
end: '2026-10-25T19:00',
title: 'Task 13',
resource: 5,
},
{
start: '2026-10-26T11:00',
end: '2026-10-26T14:00',
title: 'Task 14',
resource: 2,
},
{
start: '2026-10-26T16:00',
end: '2026-10-26T20:00',
title: 'Task 15',
resource: 5,
},
];
myResources: MbscResource[] = [
{ id: 1, name: 'Jude Chester', color: '#af2ec3' },
{ id: 2, name: 'Willis Cane', color: '#cccc39' },
{ id: 3, name: 'Derek Austyn', color: '#56ca2c' },
{ id: 4, name: 'Merv Kenny', color: '#af2424' },
{ id: 5, name: 'Fred Waldez', color: '#256ebc' },
];
myDefaultEvent = (): MbscCalendarEvent => ({
color: this.defaultColor,
});
// Simulate login
login(): void {
const newTasks = [...this.myEvents];
const newResources = [...this.myResources];
if (this.user.role === 'readonly') {
this.defaultColor = '';
for (const task of newTasks) {
task.editable = false;
task.color = '#af2ec3';
}
this.notify.toast({
message: 'Client with read-only access logged in',
});
} else if (this.user.role === 'limited') {
this.defaultColor = '#af2424';
for (const task of newTasks) {
if (task.resource !== this.user.id) {
task.editable = false;
task.color = '#6a6a6a';
} else {
task.color = '#af2424';
}
}
for (const res of newResources) {
if (res.id !== this.user.id) {
res.eventCreation = false;
}
}
this.notify.toast({
message: 'User ' + this.user.name + ' with limited access logged in',
});
} else {
this.defaultColor = '';
this.notify.toast({
message: 'User with full access logged in',
});
}
this.myEvents = newTasks;
this.myResources = newResources;
this.editEvents = this.user.role != 'readonly';
}
ngOnInit(): void {
this.login();
}
}
<mbsc-eventcalendar
class="mds-role-based-timeline"
[data]="myEvents"
[resources]="myResources"
[view]="myView"
[clickToCreate]="editEvents"
[dragToCreate]="editEvents"
[dragToMove]="editEvents"
[dragToResize]="editEvents"
[eventDelete]="editEvents"
[extendDefaultEvent]="myDefaultEvent"
/>
.mds-role-based-timeline .mbsc-schedule-event:not(.mbsc-readonly-event) .mbsc-schedule-event-background {
border: 2px solid currentColor;
}
.mds-role-based-timeline .mbsc-schedule-event .mbsc-schedule-event-background::after {
content: '';
position: absolute;
inset: 0;
background: rgba(255, 255, 255, 0.6);
}