Fixed issue where table rules were not applied
This commit is contained in:
@@ -80,10 +80,10 @@ class DataGridFormattingEditor(DslEditor):
|
||||
cells_rules[cell_id].append(rule)
|
||||
elif isinstance(scope, TableScope):
|
||||
# Validate table name matches current grid
|
||||
if scope.table == self._parent._settings.name:
|
||||
if scope.table == self._parent.get_table_name():
|
||||
table_rules.append(rule)
|
||||
else:
|
||||
logger.warning(f"Table name '{scope.table}' does not match grid name '{self._parent._settings.name}', skipping rules")
|
||||
logger.warning(f"Table name '{scope.table}' does not match grid name '{self._parent.get_table_name()}', skipping rules")
|
||||
elif isinstance(scope, TablesScope):
|
||||
tables_rules.append(rule)
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ class TestFormattingEditorIntegration:
|
||||
"""Test that table rules are dispatched to DatagridState.table_format."""
|
||||
|
||||
dsl = '''
|
||||
table "products":
|
||||
table "app.products":
|
||||
style("info")
|
||||
'''
|
||||
editor.set_content(dsl)
|
||||
@@ -218,7 +218,7 @@ tables:
|
||||
tables:
|
||||
style(font_size="14px")
|
||||
|
||||
table "products":
|
||||
table "app.products":
|
||||
format.number(precision=2)
|
||||
|
||||
column amount:
|
||||
@@ -244,7 +244,7 @@ cell (amount, 1):
|
||||
"""Test that table_format is cleared when DSL changes."""
|
||||
# First set table rules
|
||||
dsl = '''
|
||||
table "products":
|
||||
table "app.products":
|
||||
style("info")
|
||||
'''
|
||||
editor.set_content(dsl)
|
||||
@@ -257,10 +257,10 @@ table "products":
|
||||
assert len(datagrid._state.table_format) == 0
|
||||
|
||||
@pytest.mark.parametrize("table_name,should_apply", [
|
||||
("products", True), # Correct name
|
||||
("app.products", True), # Correct name (namespace.name)
|
||||
("products", False), # Name only (namespace required)
|
||||
("PRODUCTS", False), # Case sensitive
|
||||
("product", False), # Partial match not allowed
|
||||
("app.products", False), # Namespace not included
|
||||
("other", False), # Completely wrong
|
||||
])
|
||||
def test_table_name_validation(self, datagrid, editor, table_name, should_apply):
|
||||
|
||||
Reference in New Issue
Block a user