Refactor pagination logic in admin ads list keyboard
- Updated the pagination row to only display when multiple pages are available, improving the user interface for ad navigation. - Enhanced the inline keyboard structure for better clarity and usability in the admin panel's ads management section.
This commit is contained in:
@@ -148,30 +148,31 @@ def get_ads_list_keyboard(
|
|||||||
callback_data=f"admin_ads:card:{c.ad_campaign_id}:{current_page}",
|
callback_data=f"admin_ads:card:{c.ad_campaign_id}:{current_page}",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Pagination row
|
# Pagination row (only when needed)
|
||||||
row = []
|
if total_pages > 1:
|
||||||
if current_page > 0:
|
row = []
|
||||||
|
if current_page > 0:
|
||||||
|
row.append(
|
||||||
|
InlineKeyboardButton(
|
||||||
|
text="⬅️ " + _("prev_page_button", default="Prev"),
|
||||||
|
callback_data=f"admin_ads:page:{current_page - 1}",
|
||||||
|
)
|
||||||
|
)
|
||||||
row.append(
|
row.append(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="⬅️ " + _("prev_page_button", default="Prev"),
|
text=f"{current_page + 1}/{total_pages}",
|
||||||
callback_data=f"admin_ads:page:{current_page - 1}",
|
callback_data="ads_page_display",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
row.append(
|
if current_page < total_pages - 1:
|
||||||
InlineKeyboardButton(
|
row.append(
|
||||||
text=f"{current_page + 1}/{total_pages}",
|
InlineKeyboardButton(
|
||||||
callback_data="ads_page_display",
|
text=_("next_page_button", default="Next") + " ➡️",
|
||||||
)
|
callback_data=f"admin_ads:page:{current_page + 1}",
|
||||||
)
|
)
|
||||||
if current_page < total_pages - 1:
|
|
||||||
row.append(
|
|
||||||
InlineKeyboardButton(
|
|
||||||
text=_("next_page_button", default="Next") + " ➡️",
|
|
||||||
callback_data=f"admin_ads:page:{current_page + 1}",
|
|
||||||
)
|
)
|
||||||
)
|
if row:
|
||||||
if row:
|
builder.row(*row)
|
||||||
builder.row(*row)
|
|
||||||
|
|
||||||
builder.button(text=_(key="admin_ads_create_button", default="➕ Создать кампанию"),
|
builder.button(text=_(key="admin_ads_create_button", default="➕ Создать кампанию"),
|
||||||
callback_data="admin_action:ads_create")
|
callback_data="admin_action:ads_create")
|
||||||
|
|||||||
Reference in New Issue
Block a user