Skip to content

Commit d8fcb9a

Browse files
committed
perf: Optimizes Amis component properties in table fields
1 parent 81b3f9f commit d8fcb9a

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

fastapi_amis_admin/admin/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ async def get_list_column(self, request: Request, modelfield: ModelField) -> Tab
679679
if await self.has_update_permission(request, None, None) and modelfield.name in model_fields( # type: ignore
680680
self.schema_update
681681
):
682+
if column.type == "switch":
683+
column.disabled = False
682684
column.quickEdit = await self.get_column_quick_edit(request, modelfield)
683685
return column
684686

fastapi_amis_admin/admin/parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def as_table_column(self, modelfield: ModelField, quick_edit: bool = False) -> T
102102
)
103103
column.quickEdit.update({"saveImmediately": True})
104104
if column.quickEdit.get("type") == "switch":
105+
column.disabled = False
105106
column.quickEdit.update({"mode": "inline"})
106107
return column
107108

@@ -190,6 +191,7 @@ def get_field_amis_table_column_type(self, type_: Type) -> dict:
190191
pass
191192
elif issubclass(type_, bool):
192193
kwargs["type"] = "switch"
194+
kwargs["disabled"] = True
193195
kwargs["filterable"] = {
194196
"options": [
195197
{"label": _("YES"), "value": True},
@@ -281,6 +283,9 @@ def get_field_amis_form_item_type(self, type_: Any, is_filter: bool, required: b
281283
kwargs["form"] = self.as_amis_form(type_, is_filter=is_filter).amis_dict()
282284
else:
283285
kwargs["type"] = "input-text"
286+
if kwargs.get("type") == "input-text":
287+
kwargs["clearable"] = True
288+
kwargs["clearValueOnEmpty"] = True
284289
return kwargs
285290

286291
def get_field_amis_extra(

0 commit comments

Comments
 (0)