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.

Download and try example

Demo

Simulate logged in user
var user = {
    
    
    
}

var myResources = [{
    id: 1,
    name: 'Jude Chester',
    color: '#fadaff'
}, {
    id: 2,
    name: 'Willis Cane',
    color: '#ffffd0'
}, {
    id: 3,
    name: 'Derek Austyn',
    color: '#e1ffd6'
}, {
    id: 4,
    name: 'Merv Kenny',
    color: '#fac4c4'
}, {
    id: 5,
    name: 'Fred Waldez',
    color: '#bfdeff'
}];

var myEvents = [{
    start: '2026-10-22T11:00',
    end: '2026-10-22T15:00',
    title: 'Task 1',
    resource: 1
}, {
    start: '2026-10-22T14:00',
    end: '2026-10-22T17:00',
    title: 'Task 2',
    resource: 3
}, {
    start: '2026-10-22T12:00',
    end: '2026-10-22T14:00',
    title: 'Task 3',
    resource: 4
}, {
    start: '2026-10-23T10:00',
    end: '2026-10-23T15:00',
    title: 'Task 4',
    resource: 1
}, {
    start: '2026-10-23T11:00',
    end: '2026-10-23T13:00',
    title: 'Task 5',
    resource: 2
}, {
    start: '2026-10-23T14:00',
    end: '2026-10-23T17:00',
    title: 'Task 6',
    resource: 2
}, {
    start: '2026-10-23T12:00',
    end: '2026-10-23T15:00',
    title: 'Task 7',
    resource: 3
}, {
    start: '2026-10-23T17:00',
    end: '2026-10-23T20:00',
    title: 'Task 8',
    resource: 3
}, {
    start: '2026-10-23T08:00',
	end: '2026-10-23T11:30',
	title: 'Task 9',
	resource: 4
}, {
    start: '2026-10-23T12:00',
	end: '2026-10-23T14:00',
	title: 'Task 10',
	resource: 4
}, {
    start: '2026-10-23T10:00',
	end: '2026-10-23T13:00',
	title: 'Task 11',
	resource: 5
}, {
    start: '2026-10-23T14:00',
	end: '2026-10-23T16:00',
	title: 'Task 12',
	resource: 5
}, {
    start: '2026-10-23T16:30',
    end: '2026-10-23T19:00',
    title: 'Task 13',
    resource: 5
}, {
    start: '2026-10-24T11:00',
    end: '2026-10-24T14:00',
    title: 'Task 14',
    resource: 2
}, {
    start: '2026-10-24T16:00',
    end: '2026-10-24T20:00',
    title: 'Task 15',
    resource: 5
}]

function login() {
    var updatedTasks = myEvents.slice();
    var updatedResources = myResources.slice();
    var eventEdit = user.role != 'readonly';
    var task;
    var defaultColor;

    if (user.role === 'readonly') {
        for (var i = 0; i < updatedTasks.length; i++) {
            task = updatedTasks[i];
            // Disable editing for all events
            task.editable = false;
            // Make event colors uniform
            task.color = '#af2ec3';
        }
    }
    else if (user.role === 'limited') {
        defaultColor = '#af2424';
        for (var i = 0; i < updatedTasks.length; i++) {
            task = updatedTasks[i];

            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 (var i = 0; i < updatedResources.length; i++) {
            var res = updatedResources[i];

            if (res.id !== user.id) {
                // Disable event creation for other users
                res.eventCreation = false;
            }
        }
    }
                
    // Update events, resources and d&d options
    myCalendar.setOptions({
        data: updatedTasks,
        resources: updatedResources,
        clickToCreate: eventEdit,
        dragToCreate: eventEdit,
        dragToMove: eventEdit,
        dragToResize: eventEdit,
        eventDelete: eventEdit,
        extendDefaultEvent: function () {
            return {
                color: defaultColor,
            };
        },
    });
}
var myCalendar = mobiscroll.eventcalendar('my-calendar', {
    view: {
        timeline: {
            type: 'week',
            startTime: '08:00',
            endTime: '20:00',
        }
    },
    resources: myResources,
    data: myEvents
})
Implement role-based access in a Timeline: managers edit all tasks, employees edit their own, and clients have read-only access.

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.