add visibility delegates for fields in edit form
Some checks failed
Build Docs / changes (push) Failing after 2s
Build Docs / build-docs (push) Has been skipped
Build Docs / deploy-docs (push) Has been skipped

This commit is contained in:
Alexander Kalinovsky
2025-04-22 20:30:33 +07:00
parent a3357a2924
commit a134194852
14 changed files with 270 additions and 112 deletions

View File

@@ -31,7 +31,7 @@ class FieldEditButton:
@dataclass
class CommandButton:
command: ContextData | Callable[[ContextData, Any], ContextData] | str
command: ContextData | Callable[["BotEntity", "BotContext"], ContextData] | str
caption: str | LazyProxy | Callable[["BotEntity", "BotContext"], str] | None = None
visibility: Callable[["BotEntity", "BotContext"], bool] | None = None
@@ -113,6 +113,12 @@ class _BaseFieldDescriptor:
is_visible: (
bool | Callable[["FieldDescriptor", "BotEntity", "BotContext"], bool] | None
) = None
is_visible_in_edit_form: (
bool
| Callable[["FieldDescriptor", Union["BotEntity", Any], "BotContext"], bool]
| None
) = None
validator: Callable[[Any, "BotContext"], Union[bool, str]] | None = None
localizable: bool = False
bool_false_value: str | LazyProxy = "no"
bool_true_value: str | LazyProxy = "yes"
@@ -219,6 +225,7 @@ class CommandCallbackContext[UT: UserBase]:
db_session: AsyncSession
user: UT
app: "QBotApp"
app_state: State
state_data: dict[str, Any]
state: FSMContext
form_data: dict[str, Any]