Giao diện
FAQ
Schema trả về thiếu children?
Nguyên nhân: getJsonSchema build tree từ closure table. Nếu uiSchemaTreePath thiếu record cho một cặp ancestor-descendant, child node sẽ không xuất hiện.
Giải pháp:
- Kiểm tra
uiSchemaTreePathcó đủ records không:SELECT * FROM uiSchemaTreePath WHERE ancestor = '<parent-uid>'. - Nếu thiếu, dùng
inserthoặcinsertAdjacentđể re-attach child. - Gọi
clearCachesau khi sửa data trực tiếp.
insertAdjacent với position nào cho đúng?
| Position | Kết quả | Ví dụ |
|---|---|---|
beforeBegin | Trước node tham chiếu (cùng level) | Thêm column trước column "Tên" |
afterBegin | Đầu children của node | Thêm block đầu tiên trong Grid |
beforeEnd | Cuối children của node | Thêm block cuối cùng trong Grid |
afterEnd | Sau node tham chiếu (cùng level) | Thêm column sau column "Tên" |
Nếu nhầm beforeBegin/afterEnd (cùng parent) với afterBegin/beforeEnd (thành child), schema sẽ nằm sai level trong cây.
ServerHook không chạy khi xóa collection?
Hook onCollectionDestroy chỉ trigger khi:
- Schema node có record trong
uiSchemaServerHooksvớitype = 'onCollectionDestroy'vàcollection = '<tên collection>'. - Collection bị xóa qua API chuẩn (trigger afterDestroy).
Kiểm tra: SELECT * FROM uiSchemaServerHooks WHERE type = 'onCollectionDestroy' AND collection = '<tên>'.
Template tạo xong nhưng không thấy trong danh sách?
uiSchemaTemplates:list filter theo componentName nếu có query param. Kiểm tra:
- Template đã lưu thành công:
SELECT * FROM uiSchemaTemplates WHERE key = '<key>'. componentNamecó khớp filter client đang gửi không.uidFK trỏ đúng schema gốc (schema gốc phải tồn tại).
Button hiển thị cho role không mong muốn?
Button visibility kiểm soát qua uiButtonSchemasRoles:
- Nếu button schema có records trong bảng junction → chỉ role trong danh sách mới thấy.
- Nếu không có record nào → tất cả role đều thấy (default visible).
Để ẩn button khỏi role cụ thể: đảm bảo junction chỉ chứa role được phép.
clearAncestor khác remove thế nào?
| Action | Node | Descendants | Closure paths |
|---|---|---|---|
remove | Xóa | Xóa cascade | Xóa |
clearAncestor | Giữ | Giữ | Xóa ancestor links (node trở thành root riêng) |
Dùng clearAncestor khi muốn detach node tạm thời (VD: move sang cây khác sau). Dùng remove khi muốn xóa vĩnh viễn.
Sửa schema trực tiếp trong DB có an toàn không?
Không khuyến khích. Nếu bắt buộc:
- Sửa
uiSchemas.schemaJSON — đảm bảo format hợp lệ. - Phải gọi
clearCachesau khi sửa (cache không tự invalidate). - Không sửa
uiSchemaTreePaththủ công — closure table rất dễ inconsistent. - ServerHooks sẽ không trigger khi sửa trực tiếp DB.