AkaBlas / akalisten

0 stars 0 forks source link

Improve JS Robustness #11

Open Bibo-Joshi opened 1 day ago

Bibo-Joshi commented 1 day ago

https://github.com/AkaBlas/akalisten/blob/00f1eba2971ac936152d7044600f7ba5523297b8/akalisten/templates/lotsude/script.j2#L77

The logic of how the name highlightning is working currently on comparing the display name. I would suspect that it's a tad more reliable to base this on the user id. This is already available at

https://github.com/AkaBlas/akalisten/blob/00f1eba2971ac936152d7044600f7ba5523297b8/akalisten/api_types/polls.py#L97-L103

and we can add it to the class

https://github.com/AkaBlas/akalisten/blob/00f1eba2971ac936152d7044600f7ba5523297b8/akalisten/polls.py#L200-L202

so that it's directly availble in the jinja template, e.g. at this line in the "hinrich" template:

https://github.com/AkaBlas/akalisten/blob/00f1eba2971ac936152d7044600f7ba5523297b8/akalisten/templates/hinrich/index.j2#L63-L65

Instead of adding a *, I would imagine that we can then set a flag and the user id on the html element. The JS logic can then be simplified to (caution, ugly pseudo code)

on hover:
    if not this_element.has_flag:
         return
    elements = select_all(this_element.userID)
    for element in elements:
        element.hover()

What do you think @fscholdei ?

fscholdei commented 1 day ago

If you can provide me that ID, the rest can certainly be implemented.

The following does not seem to be enough in user class:

@property
def id(self) -> str:
    return self.id
Bibo-Joshi commented 15 hours ago

Commit https://github.com/AkaBlas/akalisten/commit/63b146dee043c025c3397595c27066e23e1748a3 adds User.id and shows how to use it in the template :)

fscholdei commented 1 hour ago

With 676a2bb7 I have replaced the display name with id for highlighting comparison. Can we also give the categories an id?