Added columns values in suggestion + fixed commands key conflicts bug

This commit is contained in:
2026-02-08 22:44:06 +01:00
parent d44e0a0c01
commit 0119f54f11
10 changed files with 127 additions and 15 deletions

View File

@@ -48,10 +48,13 @@ class Command:
# either there is no parameter (so one single instance of the command is enough)
# or the parameter is a kwargs (so the parameters are provided when the command is called)
if key is None:
if owner is not None and args is None: # args is not provided
key = f"{owner.get_full_id()}-{name}"
else:
key = f"{name}-{_compute_from_args()}"
key_parts = []
if owner is not None:
key_parts.append(f"{owner.get_full_id()}")
key_parts.append(name)
if args:
key_parts.append(_compute_from_args())
key = "-".join(key_parts)
else:
key = key.replace("#{args}", _compute_from_args())
if owner is not None:
@@ -122,6 +125,8 @@ class Command:
def execute(self, client_response: dict = None):
logger.debug(f"Executing command {self.name} with arguments {client_response=}")
if self._htmx_extra.get("hx-target", "").startswith("#tsm_"):
logger.warning(f" Command {self.name} needs a selection manager to work properly.")
with ObservableResultCollector(self._bindings) as collector:
kwargs = self._create_kwargs(self.default_kwargs,
client_response,
@@ -145,6 +150,10 @@ class Command:
and r.get("id", None) is not None):
r.attrs["hx-swap-oob"] = r.attrs.get("hx-swap-oob", "true")
if self._htmx_extra.get("hx-target", "").startswith("#tsm_"):
ret_debug = [f"<{r.tag} id={r.attrs.get('id', '')}/>" if r else "None" for r in all_ret]
logger.warning(f" {ret_debug=}")
return all_ret[0] if len(all_ret) == 1 else all_ret
def htmx(self, target: Optional[str] = "this", swap="outerHTML", trigger=None, auto_swap_oob=True):