fix: filtering capabilities, feat: improve enum i18n
This commit is contained in:
@@ -10,13 +10,20 @@ def add_filter_controls(
|
||||
keyboard_builder: InlineKeyboardBuilder,
|
||||
entity_descriptor: EntityDescriptor,
|
||||
filter: str = None,
|
||||
filtering_fields: list[str] = None,
|
||||
page: int = 1,
|
||||
):
|
||||
field_name_descriptor = entity_descriptor.fields_descriptors["name"]
|
||||
if field_name_descriptor.caption:
|
||||
caption = get_callable_str(field_name_descriptor.caption, field_name_descriptor)
|
||||
else:
|
||||
caption = field_name_descriptor.name
|
||||
caption = ", ".join(
|
||||
[
|
||||
get_callable_str(
|
||||
entity_descriptor.fields_descriptors[field_name].caption,
|
||||
entity_descriptor,
|
||||
)
|
||||
if entity_descriptor.fields_descriptors[field_name].caption
|
||||
else field_name
|
||||
for field_name in filtering_fields
|
||||
]
|
||||
)
|
||||
|
||||
keyboard_builder.row(
|
||||
InlineKeyboardButton(
|
||||
|
||||
@@ -263,6 +263,7 @@ async def render_entity_picker(
|
||||
keyboard_builder=keyboard_builder,
|
||||
entity_descriptor=type_.bot_entity_descriptor,
|
||||
filter=entity_filter,
|
||||
filtering_fields=form_list.filtering_fields,
|
||||
)
|
||||
|
||||
if is_list:
|
||||
|
||||
@@ -200,13 +200,14 @@ async def process_field_edit_callback(message: Message | CallbackQuery, **kwargs
|
||||
prev_form_name or "default", entity_descriptor.default_list
|
||||
)
|
||||
|
||||
for filt in prev_form_list.static_filters:
|
||||
if filt.value_type == "const":
|
||||
entity_data[filt.field_name] = filt.value
|
||||
elif len(prev_form_params) > filt.param_index:
|
||||
entity_data[filt.field_name] = prev_form_params[
|
||||
filt.param_index
|
||||
]
|
||||
if prev_form_list.static_filters:
|
||||
for filt in prev_form_list.static_filters:
|
||||
if filt.value_type == "const":
|
||||
entity_data[filt.field_name] = filt.value
|
||||
elif len(prev_form_params) > filt.param_index:
|
||||
entity_data[filt.field_name] = prev_form_params[
|
||||
filt.param_index
|
||||
]
|
||||
|
||||
if (
|
||||
callback_data.context
|
||||
@@ -298,6 +299,9 @@ async def process_field_edit_callback(message: Message | CallbackQuery, **kwargs
|
||||
|
||||
state_data.update(state_data)
|
||||
|
||||
clear_state(state_data=state_data)
|
||||
return await route_callback(message=message, back=False, **kwargs)
|
||||
|
||||
elif callback_data.context in [
|
||||
CommandContext.ENTITY_EDIT,
|
||||
CommandContext.ENTITY_FIELD_EDIT,
|
||||
|
||||
@@ -232,6 +232,7 @@ async def entity_list(
|
||||
keyboard_builder=keyboard_builder,
|
||||
entity_descriptor=entity_descriptor,
|
||||
filter=entity_filter,
|
||||
filtering_fields=form_list.filtering_fields,
|
||||
)
|
||||
|
||||
context = pop_navigation_context(navigation_stack)
|
||||
|
||||
Reference in New Issue
Block a user