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.

Get started with this example

Demo

Simulate logged in user
<script setup>
const user = {
  
  
  
}

const editEvents = ref(false)
const myDefaultEvent = ref(null)
const isToastOpen = ref(false)
const toastMessage = ref('')

const myView = {
  timeline: {
    type: 'week',
    startTime: '08:00',
    endTime: '20:00'
  }
}

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

const myResources = ref([{
  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
function login() {
  const newTasks = [...myEvents.value]
  const newResources = [...myResources.value]
  let defaultColor = ''

  if (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 (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 !== user.id) {      
        // Disable event creation for other users
        res.eventCreation = false
      }
    }
  }

  // Update events, resources and d&d options
  myEvents.value = newTasks
  myResources.value = newResources
  editEvents.value = user.role != 'readonly'
  myDefaultEvent.value = function () {
    return {
      color: defaultColor
    }
  }
}

login()
</script>

<template>
  <MbscEventcalendar 
    :view="myView"
    :data="myEvents"
    :resources="myResources"
    :clickToCreate="editEvents"
    :dragToCreate="editEvents"
    :dragToMove="editEvents"
    :dragToResize="editEvents"
    :eventDelete="editEvents"
    :extendDefaultEvent="myDefaultEvent" />
</template>
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.