Skip to main content

Documentation: SidebarTreeCalendar Component (English)

1. Overview

SidebarTreeCalendar is a powerful layout component that combines a hierarchical tree-based sidebar with the ResourceCalendarView. It is designed for scenarios where you need to filter calendar or timeline events based on a structured category, such as projects, departments, locations, or any other hierarchical data. When a user selects an item in the tree, the component automatically re-fetches the calendar data, applying the selected item’s ID as a filter.

2. Features

  • Dynamic Filtering: The calendar view is dynamically updated based on the selected node in the sidebar tree.
  • Collapsible Sidebar: The sidebar can be toggled to maximize the calendar viewing area.
  • Searchable Tree: Includes a search input to quickly find nodes within the tree.
  • Inherited Power: Leverages all the features of ResourceCalendarView, including its dual views, on-demand loading, and resource pagination.
  • Highly Configurable: All API endpoints, titles, and filter keys are customizable via props.
  • CRUD Events: Emits events for tree management (add, edit, delete), allowing the parent page to handle the logic (e.g., by opening modals).

3. Props

4. Pass-Through Props

This component automatically passes any unrecognized props (like dayLabels or rowHeight) directly down to the underlying ResourceCalendarView component. This allows you to customize the calendar’s appearance from the parent page.

5. Emitted Events

6. Backend API Requirements

  1. Tree API (nodesUrl):
  • Must be a POST endpoint that can accept a search term.
  • Should return an array of node objects, each with at least id, name, and an optional children array for nesting.
  1. Calendar/Resource APIs (eventsEndpoint, resourcesEndpoint):
  • Must be able to handle an additional query parameter based on the filterKey prop. For example, if filterKey is 'categoryId', your Laravel controller should check for request('categoryId') and add a where clause to the query.

7. Usage Example



Dokumentasi: Komponen SidebarTreeCalendar (Bahasa Indonesia)

1. Gambaran Umum

SidebarTreeCalendar adalah komponen tata letak (layout) yang menggabungkan sidebar berbasis pohon hierarkis dengan ResourceCalendarView. Komponen ini dirancang untuk skenario di mana Anda perlu menyaring (filter) event di kalender atau timeline berdasarkan kategori terstruktur, seperti proyek, departemen, lokasi, atau data hierarkis lainnya. Ketika pengguna memilih sebuah item di pohon, komponen akan secara otomatis mengambil ulang data kalender, dengan menerapkan ID item yang dipilih sebagai filter.

2. Fitur

  • Filter Dinamis: Tampilan kalender diperbarui secara dinamis berdasarkan node yang dipilih di sidebar.
  • Sidebar Lipat: Sidebar dapat disembunyikan untuk memaksimalkan area tampilan kalender.
  • Pohon yang Dapat Dicari: Menyertakan input pencarian untuk menemukan node di dalam pohon dengan cepat.
  • Mewarisi Kekuatan ResourceCalendarView: Memanfaatkan semua fitur dari ResourceCalendarView, termasuk tampilan ganda, pemuatan on-demand, dan paginasi resource.
  • Sangat Mudah Dikonfigurasi: Semua endpoint API, judul, dan kunci filter dapat disesuaikan melalui props.
  • Event CRUD: Memancarkan event untuk manajemen pohon (tambah, edit, hapus), memungkinkan halaman induk untuk menangani logika (misalnya, dengan membuka modal).

3. Props

4. Props Penerus (Pass-Through Props)

Komponen ini secara otomatis meneruskan props yang tidak dikenali (seperti dayLabels atau rowHeight) langsung ke komponen ResourceCalendarView di dalamnya. Ini memungkinkan Anda untuk menyesuaikan tampilan kalender dari halaman induk.

5. Event yang Di-emit

6. Kebutuhan API Backend

  1. API Pohon (nodesUrl):
  • Harus berupa endpoint POST yang dapat menerima istilah search.
  • Harus mengembalikan sebuah array objek node, masing-masing dengan setidaknya id, name, dan array children (opsional) untuk data bersarang.
  1. API Kalender/Resource (eventsEndpoint, resourcesEndpoint):
  • Harus dapat menangani parameter query tambahan berdasarkan prop filterKey. Contohnya, jika filterKey adalah 'categoryId', controller Laravel Anda harus memeriksa request('categoryId') dan menambahkan klausa where pada query.

7. Contoh Penggunaan