Skip to content

Commit 449007c

Browse files
committed
fix: added translations in confirm modal and fixed ui bug
1 parent 3ddf9d1 commit 449007c

8 files changed

Lines changed: 40 additions & 26 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3332,7 +3332,7 @@ Quick reference for all `sbadmin_` prefixed class attributes available in `SBAdm
33323332
| `sbadmin_list_reorder_field` | str | Field name for drag-and-drop row reordering |
33333333
| `sbadmin_xlsx_options` | dict | Excel export configuration options |
33343334
| `sbadmin_table_history_enabled` | bool | Enable/disable table state history (default: `True`) |
3335-
| `sbadmin_list_sticky_footer` | bool \| None | Stick pagination footer to viewport bottom on scroll. On desktop, adds a synced horizontal scrollbar above it that mirrors the table's horizontal scroll. `None` (default) falls back to `SBAdminRoleConfiguration.default_list_sticky_footer`; explicit `True`/`False` overrides the global setting. |
3335+
| `sbadmin_list_sticky_header_and_footer` | bool \| None | Enable sticky Tabulator column header together with sticky pagination footer and synced horizontal scrollbar. `None` falls back to `SBAdminRoleConfiguration.default_list_sticky_header_and_footer`; explicit `True`/`False` overrides the global setting. |
33363336

33373337
### Detail/Change View Attributes (SBAdmin)
33383338

src/django_smartbase_admin/engine/admin_base_view.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class SBAdminBaseListView(SBAdminBaseView):
317317
sbadmin_list_history_enabled = True
318318
sbadmin_list_reorder_field = None
319319
sbadmin_nested: dict | None = None
320-
sbadmin_list_sticky_footer = None
320+
sbadmin_list_sticky_header_and_footer = None
321321
search_field_placeholder = _("Search...")
322322
filters_version = None
323323
sbadmin_actions_initialized = False
@@ -489,14 +489,16 @@ def has_add_permission(self, request, obj=None) -> bool:
489489
return False
490490
return super().has_add_permission(request)
491491

492-
def get_sbadmin_list_sticky_footer(self, request) -> bool:
493-
if self.sbadmin_list_sticky_footer is not None:
494-
return self.sbadmin_list_sticky_footer
495-
return request.request_data.configuration.default_list_sticky_footer
492+
def get_sbadmin_list_sticky_header_and_footer(self, request) -> bool:
493+
if self.sbadmin_list_sticky_header_and_footer is not None:
494+
return self.sbadmin_list_sticky_header_and_footer
495+
return request.request_data.configuration.default_list_sticky_header_and_footer
496496

497497
def get_tabulator_definition(self, request) -> dict[str, Any]:
498498
view_id = self.get_id()
499-
sticky_footer = self.get_sbadmin_list_sticky_footer(request)
499+
sticky_header_and_footer = self.get_sbadmin_list_sticky_header_and_footer(
500+
request
501+
)
500502
tabulator_definition = {
501503
"viewId": view_id,
502504
"advancedFilterId": f"{view_id}" + "-advanced-filter",
@@ -515,7 +517,7 @@ def get_tabulator_definition(self, request) -> dict[str, Any]:
515517
"tableInitialSort": self.get_list_initial_order(request),
516518
"tableInitialPageSize": self.get_list_per_page(request),
517519
"tableHistoryEnabled": self.sbadmin_table_history_enabled,
518-
"stickyFooter": sticky_footer,
520+
"stickyHeaderAndFooter": sticky_header_and_footer,
519521
# used to initialize all columns with these values
520522
"defaultColumnData": {},
521523
"locale": request.LANGUAGE_CODE,
@@ -560,8 +562,8 @@ def get_tabulator_definition(self, request) -> dict[str, Any]:
560562
request=request,
561563
definition=tabulator_definition,
562564
)
563-
if sticky_footer:
564-
tabulator_definition["modules"].append("stickyFooterModule")
565+
if sticky_header_and_footer:
566+
tabulator_definition["modules"].append("stickyHeaderAndFooterModule")
565567
return tabulator_definition
566568

567569
def _get_sbadmin_list_actions(self, request) -> list[SBAdminCustomAction] | list:
@@ -785,9 +787,11 @@ def get_all_config(self, request) -> dict[str, Any]:
785787
if not list_filter:
786788
return all_config
787789
list_fields = self.get_sbadmin_list_display(request) or []
788-
list_fields = self.init_fields_cache(
790+
initialized_fields = self.init_fields_cache(
789791
list_fields, request.request_data.configuration
790792
)
793+
if initialized_fields is not None:
794+
list_fields = initialized_fields
791795
base_filter = {
792796
getattr(field, "filter_field", field): ""
793797
for field in list_fields

src/django_smartbase_admin/engine/configuration.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class SBAdminRoleConfiguration(metaclass=Singleton):
192192
# ``plugins/base.py`` for the protocol. Each plugin hook is expected
193193
# to self-guard based on admin config (e.g. ``sbadmin_nested``).
194194
plugins: list = []
195-
default_list_sticky_footer = False
195+
default_list_sticky_header_and_footer = False
196196

197197
def __init__(
198198
self,
@@ -205,7 +205,7 @@ def __init__(
205205
login_view_class=None,
206206
admin_title=None,
207207
plugins=None,
208-
default_list_sticky_footer=None,
208+
default_list_sticky_header_and_footer=None,
209209
) -> None:
210210
super().__init__()
211211
self.default_view = default_view or self.default_view or []
@@ -221,8 +221,10 @@ def __init__(
221221
# Copy the class-level list to avoid accidental cross-instance
222222
# mutation when subclasses assign ``plugins = [...]``.
223223
self.plugins = list(plugins if plugins is not None else self.plugins)
224-
if default_list_sticky_footer is not None:
225-
self.default_list_sticky_footer = default_list_sticky_footer
224+
if default_list_sticky_header_and_footer is not None:
225+
self.default_list_sticky_header_and_footer = (
226+
default_list_sticky_header_and_footer
227+
)
226228

227229
def init_registered_views(self):
228230
registered_views = []

src/django_smartbase_admin/static/sb_admin/src/css/_tabulator.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.tabulator {
22
position: relative;
33
text-align: left;
4-
overflow: hidden;
4+
overflow: visible;
55
transform: translateZ(0);
66
@apply text-14;
77
}
@@ -28,6 +28,12 @@
2828
@apply border-b border-dark-200 bg-dark-50 text-dark-600;
2929
}
3030

31+
.tabulator.tabulator--sticky-header-and-footer .tabulator-header {
32+
position: sticky;
33+
top: 0;
34+
z-index: 10;
35+
}
36+
3137
.tabulator .tabulator-header.tabulator-header-hidden {
3238
display: none;
3339
}

src/django_smartbase_admin/static/sb_admin/src/js/table.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {MovableColumnsModule} from "./table_modules/movable_columns_module"
1010
import {DataEditModule} from "./table_modules/data_edit_module"
1111
import {FullTextSearchModule} from "./table_modules/full_text_search_module"
1212
import { HeaderTabsModule } from "./table_modules/header_tabs_module"
13-
import { StickyFooterModule } from "./table_modules/sticky_footer_module"
13+
import { StickyHeaderAndFooterModule } from "./table_modules/sticky_header_and_footer_module"
1414
import { SBAjaxParamsTabulatorModifier } from "./sb_ajax_params_tabulator_modifier"
1515

1616

@@ -381,5 +381,5 @@ window.SBAdminTableModulesClass = {
381381
'dataEditModule': DataEditModule,
382382
'fullTextSearchModule': FullTextSearchModule,
383383
'headerTabsModule': HeaderTabsModule,
384-
'stickyFooterModule': StickyFooterModule,
384+
'stickyHeaderAndFooterModule': StickyHeaderAndFooterModule,
385385
}

src/django_smartbase_admin/static/sb_admin/src/js/table_modules/sticky_footer_module.js renamed to src/django_smartbase_admin/static/sb_admin/src/js/table_modules/sticky_header_and_footer_module.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import { SBAdminTableModule } from "./base_module"
22

33

4-
export class StickyFooterModule extends SBAdminTableModule {
4+
export class StickyHeaderAndFooterModule extends SBAdminTableModule {
55

66
afterInit() {
7+
const tableEl = this.table.tabulator.element
8+
tableEl.classList.add("tabulator--sticky-header-and-footer")
9+
710
const scrollbar = document.querySelector(
811
`[data-sticky-scrollbar="${this.table.viewId}"]`
912
)
1013
if (!scrollbar) {
11-
console.warn(`[StickyFooterModule] sticky scrollbar element missing for viewId: ${this.table.viewId}`)
14+
console.warn(`[StickyHeaderAndFooterModule] sticky scrollbar element missing for viewId: ${this.table.viewId}`)
1215
return
1316
}
1417
const spacer = scrollbar.firstElementChild
15-
const tableEl = this.table.tabulator.element
1618
const tableholder = tableEl.querySelector(".tabulator-tableholder")
1719
if (!tableholder || !spacer) {
18-
console.warn(`[StickyFooterModule] tableholder or spacer missing for viewId: ${this.table.viewId}`)
20+
console.warn(`[StickyHeaderAndFooterModule] tableholder or spacer missing for viewId: ${this.table.viewId}`)
1921
return
2022
}
2123

src/django_smartbase_admin/templates/sb_admin/actions/list.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ <h1 class="text-24 md:text-30 text-dark-900 font-bold font-heading line-clamp-1
105105
<div id="{{ view_id }}-table" class="list-view-table"></div>
106106
{% endblock %}
107107
{% block tabulator_custom_footer %}
108-
<div class="tabulator-custom-footer{% if content_context.tabulator_definition.stickyFooter %} tabulator-custom-footer--sticky{% endif %}">
109-
{% if content_context.tabulator_definition.stickyFooter %}
110-
<div class="tabulator-sticky-scrollbar max-lg:hidden" data-sticky-scrollbar="{{ view_id }}">
108+
<div class="tabulator-custom-footer{% if content_context.tabulator_definition.stickyHeaderAndFooter %} tabulator-custom-footer--sticky{% endif %}">
109+
{% if content_context.tabulator_definition.stickyHeaderAndFooter %}
110+
<div class="tabulator-sticky-scrollbar" data-sticky-scrollbar="{{ view_id }}">
111111
<div class="tabulator-sticky-scrollbar__spacer"></div>
112112
</div>
113113
{% endif %}

src/django_smartbase_admin/templates/sb_admin/actions/partials/tabulator_header_v1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@
3838
{% endwith %}
3939
{% endblock %}
4040
{% include 'sb_admin/actions/partials/selected_rows_actions.html' %}
41-
</div>
41+
</div>

0 commit comments

Comments
 (0)