fix: preserve custom field attributes during JSON import#18
fix: preserve custom field attributes during JSON import#18huongcodecb1992 wants to merge 7 commits into
Conversation
| 'columns', 'field_name', '_state', 'input_attributes', | ||
| 'multiple', 'fields', 'tab', 'validation', | ||
| 'custom_settings', '_callback', 'options', | ||
| ]; |
There was a problem hiding this comment.
Có cơ chế nào để kiểm tra được danh sách các key này là chính xác? Ko bị thừa, thiếu?
There was a problem hiding this comment.
List này được xây dựng bằng cách đọc code và trả lời câu hỏi: key nào trong $settings mà không có unparse_* method nào đọc qua $this->key?
Những key đó sẽ không bao giờ được auto-track → phải khai báo tường minh.
Ví dụ như:
fields, tab, validation, multiple, callback, columns... — không có method nào isset($this->fields) hay $this->tab → không được track → cần list
type, std, options — được access trong unparse_choice* → đã auto-track → thừa trong list nhưng không hại
Trong codebase: src/Parsers/Field.php — Parser là chiều ngược lại của Unparser, nó đọc và xử lý tất cả native keys. Nếu key nào Parser có handler nhưng Unparser chưa có → key đó chưa được auto-track → cần vào STRUCTURAL_KEYS. Hiện e đã lấy hết các key từ parser sang.
There was a problem hiding this comment.
E đã check phần code xử lý 1 số field trong phần Extensions chưa?
There was a problem hiding this comment.
E check rồi. a thử kiểm tra xem có còn thiếu field nào nữa không ạ
There was a problem hiding this comment.
VD key desc, input_desc chẳng hạn thì thế nào e?
|
Based on my review of the PR, here's my analysis: Code ReviewIssues Found1. Missing Keys in STRUCTURAL_KEYS (Medium Priority)Location: The Parser (
Without these keys, they'll be incorrectly moved to 2. No Test Coverage (High Priority)No tests exist for this functionality. This makes verification and regression detection impossible. 3. Unused Variable (Low Priority)Location: $custom = $this->custom_settings ?? [];This variable is declared but only used for null coalescing check. It appears leftover from earlier implementation. 4. Performance - O(n) Array Merge on Each Access (Low Priority)Location: $known = array_merge( $this->get_accessed_keys(), self::STRUCTURAL_KEYS );This runs on every unparse call, but since both arrays are small, it's acceptable. Positive Observations
Recommendations
private const STRUCTURAL_KEYS = [
// existing keys...
'desc', 'label_description', 'datalist_choices',
'inline', 'collapsible', 'select_all_none', 'field_type',
];
|

No description provided.