Skip to main content

English Documentation

1. Vue Component: SelectAdvancedDialog.vue

This is a highly configurable and advanced selection component. It presents as a simple text input but can open a feature-rich modal dialog for searching, browsing, and selecting items from a server-side data source. It supports both single and multiple selection modes, as well as tree-like data structures with lazy loading.

Key Features

  • Modal Dialog: Provides a large, user-friendly interface for selecting items, complete with search and pagination.
  • Single & Multi-Select: Can be configured to allow selecting one or multiple items.
  • Read-only vs. Editable:
  • In readonly mode (default), it acts as a pure item selector. Clicking the input opens the modal.
  • When readonly is false, it functions as a combo-box, allowing the user to either type a free-text value or select a structured item from the modal.
  • Server-Side Data: Fetches options asynchronously from a specified API endpoint, making it suitable for large datasets.
  • Tree View & Lazy Loading: Can display hierarchical data and efficiently load child nodes on demand.

Props


Events


Usage Example


2. Laravel Backend Controller

The provided ChartOfAccountController.php (and its superclass AdminController.php) serves as the backend data provider for the SelectAdvancedDialog component. It exposes an endpoint that the component’s url prop can point to.

Relationship with SelectAdvancedDialog.vue

The postGetOptionTree method (inherited from AdminController and used by ChartOfAccountController) is designed to respond to the component’s data requests.
  • The url prop in the Vue component should point to the route that executes this method (e.g., /wcp/fat2/chart-of-account/get-option-tree).
  • The method handles search, pagination, and lazy-loading requests initiated by the component.

Key Configuration Properties in ChartOfAccountController

The behavior of the generic data-fetching methods in AdminController is configured by setting specific properties in the child controller’s constructor. For ChartOfAccountController, these are:

Data Endpoint Analysis (postGetOptionTree)

  • Request: The endpoint expects a POST request with an optional JSON body containing:
  • search (string): The search term from the modal’s input.
  • page (integer): The requested page number for pagination.
  • limit (integer): The number of items per page.
  • parentId (string/int): The ID of the parent node when lazy-loading children.
  • Response: The response is a standard Laravel paginated JSON object that the Vue component is built to understand.

Dokumentasi Bahasa Indonesia

1. Komponen Vue: SelectAdvancedDialog.vue

Ini adalah komponen seleksi yang canggih dan sangat dapat dikonfigurasi. Komponen ini tampil sebagai input teks sederhana namun dapat membuka dialog modal yang kaya fitur untuk mencari, menelusuri, dan memilih item dari sumber data di sisi server. Komponen ini mendukung mode seleksi tunggal dan ganda, serta struktur data berbentuk pohon (tree) dengan lazy loading.

Fitur Utama

  • Dialog Modal: Menyediakan antarmuka yang besar dan ramah pengguna untuk memilih item, lengkap dengan pencarian dan paginasi.
  • Seleksi Tunggal & Ganda: Dapat dikonfigurasi untuk memungkinkan pemilihan satu atau beberapa item.
  • Read-only vs. Editable:
  • Dalam mode readonly (default), komponen ini berfungsi sebagai pemilih item murni. Mengklik input akan membuka modal.
  • Ketika readonly diatur ke false, komponen ini berfungsi sebagai combo-box, memungkinkan pengguna untuk mengetik nilai teks bebas atau memilih item terstruktur dari modal.
  • Data dari Server: Mengambil opsi secara asinkron dari endpoint API yang ditentukan, sehingga cocok untuk dataset yang sangat besar.
  • Tampilan Pohon & Lazy Loading: Dapat menampilkan data hierarkis dan memuat child node secara efisien sesuai permintaan.

Props


Events


Contoh Penggunaan


2. Controller Backend Laravel

Controller ChartOfAccountController.php (dan superclass-nya AdminController.php) yang disediakan berfungsi sebagai penyedia data backend untuk komponen SelectAdvancedDialog. Controller ini mengekspos sebuah endpoint yang dapat dituju oleh prop url dari komponen.

Hubungan dengan SelectAdvancedDialog.vue

Metode postGetOptionTree (diwarisi dari AdminController dan digunakan oleh ChartOfAccountController) dirancang untuk merespons permintaan data dari komponen.
  • Prop url di komponen Vue harus menunjuk ke route yang mengeksekusi metode ini (misalnya, /wcp/fat2/chart-of-account/get-option-tree).
  • Metode ini menangani permintaan pencarian, paginasi, dan lazy-loading yang diinisiasi oleh komponen.

Properti Konfigurasi Utama di ChartOfAccountController

Perilaku metode pengambilan data generik di AdminController dikonfigurasi dengan mengatur properti spesifik di dalam constructor controller turunan. Untuk ChartOfAccountController, properti-properti ini adalah:

Analisis Endpoint Data (postGetOptionTree)

  • Request: Endpoint ini mengharapkan permintaan POST dengan body JSON opsional yang berisi:
  • search (string): Kata kunci pencarian dari input di modal.
  • page (integer): Nomor halaman yang diminta untuk paginasi.
  • limit (integer): Jumlah item per halaman.
  • parentId (string/int): ID dari node induk saat melakukan lazy-loading turunan.
  • Response: Respons yang diberikan adalah objek JSON terpaginasi standar dari Laravel yang sudah dirancang untuk dipahami oleh komponen Vue.