Bug 40421

Summary: Logged in info should be data-attributes instead and text
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: Staff interfaceAssignee: Eric Garcia <cubingguy714>
Status: Pushed to stable --- QA Contact: Emily Lamancusa (emlam) <emily.lamancusa>
Severity: normal    
Priority: P5 - low CC: emily.lamancusa, gmcharlt
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Trivial patch Documentation contact:
Documentation submission: Text to go in the release notes:
This patch adds HTML data-attributes to some hidden content in the staff interface. This makes it easier to retrieve context about the logged in user with CSS or JavaScript.
Version(s) released in:
25.11.00,25.05.02
Circulation function:
Attachments: Bug 40421: Make HTML elements data attributes
Bug 40421: Make HTML elements data attributes
Bug 40421: Make HTML elements data attributes

Description Lucas Gass (lukeg) 2025-07-16 18:01:44 UTC
We have these in the HTML on the staff interface:

loggedinusername
loggedincategorycode
logged-in-branch-code

Instead of display that info as text in the HTML element we should use data-attributes. 

One big benefit to using data-attributes would be that these could then be selectable with CSS.
Comment 1 Eric Garcia 2025-07-17 17:05:52 UTC
Created attachment 184237 [details] [review]
Bug 40421: Make HTML elements data attributes

Test Plan:
1. Apply patch
2. In Staff Interface inspect element and notice HTML has data attributes
Comment 2 Lucas Gass (lukeg) 2025-07-17 17:13:05 UTC
Thanks Eric, this is great. The reason I wanted this is because, with this patch, I can now write CSS like this for example:

body:has(span[data-logged-in-branch-code="CPL"]) {
	background: red;
}

body:has(span[data-logged-in-branch-code="MPL"]) {
	background: blue;
}

Now, without JS, I can change the background color per branch.
Comment 3 Lucas Gass (lukeg) 2025-07-17 17:16:50 UTC
Created attachment 184239 [details] [review]
Bug 40421: Make HTML elements data attributes

Test Plan:
1. Apply patch
2. In Staff Interface inspect element and notice HTML has data attributes

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 4 Lucas Gass (lukeg) 2025-07-17 17:18:44 UTC
I changed the bug title because this should not replace the text we currently have, that would break too many customization. 

It should go along with the text, which is what Eric did.
Comment 5 Emily Lamancusa (emlam) 2025-07-18 13:41:32 UTC
Created attachment 184378 [details] [review]
Bug 40421: Make HTML elements data attributes

Test Plan:
1. Apply patch
2. In Staff Interface inspect element and notice HTML has data attributes

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 6 Lucas Gass (lukeg) 2025-07-18 17:13:03 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 7 Paul Derscheid 2025-07-24 08:21:45 UTC
Nice work everyone!

Pushed to 25.05.x