Summary: | Automatic linking in guided reports | ||
---|---|---|---|
Product: | Koha | Reporter: | Owen Leonard <oleonard> |
Component: | Reports | Assignee: | Bugs List <koha-bugs> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | 1joynelson, bdaeuber, david, dcook, fridolin.somers, jonathan.druart, kyle, lisettepalouse+koha, martin.renvoize, nick, nugged |
Version: | Main | Keywords: | Manual |
Hardware: | All | ||
OS: | All | ||
See Also: | https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29679 | ||
Change sponsored?: | --- | Patch complexity: | Small patch |
Documentation contact: | Ben Daeuber | Documentation submission: | https://gitlab.com/koha-community/koha-manual/-/merge_requests/770 |
Text to go in the release notes: |
This patch adds a feature to automatically link certain database columns in report results. If your report returns itemnumber, biblionumber, cardnumber, or borrowernumber, that cell in the report will contain a menu:
- borrowernumber: View, edit, check out
- cardnumber: Check out
- itemnumber: View, edit
- biblionumber: View, edit
A link at the top of the report results will toggle the new menus on and off in case you don't want to see the menus. Your choice will persist until you log out.
The feature works with column name placeholders, so if you want the table column to be a human readable label you can still get automatic linking, for example: [[items.itemnumber|Item number]]
|
Version(s) released in: |
22.05.00
|
Circulation function: | |||
Bug Depends on: | 26458, 26473 | ||
Bug Blocks: | |||
Attachments: |
Screenshot of proposed implementation
Bug 5697: Automatic linking in guided reports Bug 5697: Automatic linking in guided reports Bug 5697: Automatic linking in guided reports Bug 5697: (follow-up) Save the user's choice to show or hide auto-links Bug 5697: Automatic linking in guided reports Bug 5697: (follow-up) Save the user's choice to show or hide auto-links Bug 5697: Consolidate nodes construction and fix translation issue testing performance on a report with many rows Bug 5697: Automatic linking in guided reports Bug 5697: Automatic linking in guided reports Bug 5697: Automatic linking in guided reports |
Description
Owen Leonard
2011-02-04 20:28:55 UTC
Created attachment 110075 [details]
Screenshot of proposed implementation
I propose a solution that would automatically generate a dropdown menu for each result in itemnumber, biblionumber, cardnumber, and borrowernumber columns. Each menu would contain "View" and "Edit" options. The card number column would link to the checkout page.
Seems sensible and useful to me, although I'm not really a user of the guided reports. Created attachment 110668 [details] [review] Bug 5697: Automatic linking in guided reports This patch modifies the output of reports so that if certain columns are returned the data in the colums automatically offer menus of actions: - borrowernumber: View, edit, check out - cardnumber: Check out - itemnumber: View, edit - biblionumber: View, edit Like the menu of batch operations, this functionality is available only if the column is returned with its original name (e.g. biblionumber, not "biblionumber AS `Biblio number`). To test, apply the patch and run a report which will return examples of each kind of data. I used: SELECT biblio.biblionumber , biblio.title, items.itemnumber, items.itemcallnumber, items.barcode, borrowers.firstname, borrowers.surname, borrowers.borrowernumber, borrowers.cardnumber FROM issues LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber LEFT JOIN items ON issues.itemnumber=items.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber ORDER BY RAND() LIMIT 50 When the report runs you should see that the data in each affected column is displayed as a link, each of which should trigger the correct menu. Test each case to confirm that the correct page is opened. Test the "toggle data menus" control. Clicking it should hide and show the menus in the report results. Created attachment 110697 [details] [review] Bug 5697: Automatic linking in guided reports This patch modifies the output of reports so that if certain columns are returned the data in the colums automatically offer menus of actions: - borrowernumber: View, edit, check out - cardnumber: Check out - itemnumber: View, edit - biblionumber: View, edit Like the menu of batch operations, this functionality is available only if the column is returned with its original name (e.g. biblionumber, not "biblionumber AS `Biblio number`). To test, apply the patch and run a report which will return examples of each kind of data. I used: SELECT biblio.biblionumber , biblio.title, items.itemnumber, items.itemcallnumber, items.barcode, borrowers.firstname, borrowers.surname, borrowers.borrowernumber, borrowers.cardnumber FROM issues LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber LEFT JOIN items ON issues.itemnumber=items.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber ORDER BY RAND() LIMIT 50 When the report runs you should see that the data in each affected column is displayed as a link, each of which should trigger the correct menu. Test each case to confirm that the correct page is opened. Test the "toggle data menus" control. Clicking it should hide and show the menus in the report results. Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com> Worked swimmingly. We were glad that it didn't download as links but still gave the option for links in the browser. This will be very helpful. Lisette (and Koha-US Bug-a-palooza stream) I think the feature is super nice, but there is a big issue for me as it will currently only work on the English column names. We usually never leave them like that and always translate using "itemnumber AS Exemplarnummer" or similar. Could we imagine adding the columnname to the table heading as a class and use this for triggering the links? I think we are also missing checks on permissions - so Edit item will show, if you don't have the permission to edit. For batch edit features we found a solution here: Bug 23390 - Add placeholder syntax for column names What i used for testing: SELECT i.itemnumber, i.itemnumber as Exemplarnummber, [[i.itemnumber| itemnumber for batch]], CONCAT('<a href=\"/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=', i.biblionumber, '&itemnumber=', i.itemnumber, '#edititem', '\">', i.itemnumber, '</a>' ) AS "itemnumber as edit link" FROM items i (In reply to Katrin Fischer from comment #6) > For batch edit features we found a solution here: > Bug 23390 - Add placeholder syntax for column names Thanks Katrin I wasn't aware that a solution was in place for this issue and batch edit features. I'll see if I can work with that. I wonder if we could use SQL::Translator to translate the SQL into a JSON data structure that could be rendered by TT. I don't know enough about the module but *maybe* it has support for getting column names before they're aliased? Probably not but you never know? Created attachment 117096 [details] [review] Bug 5697: Automatic linking in guided reports This patch modifies the output of reports so that if certain columns are returned the data in the colums automatically offer menus of actions: - borrowernumber: View, edit, check out - cardnumber: Check out - itemnumber: View, edit - biblionumber: View, edit Like the menu of batch operations, this functionality is available only if the column is returned with its original name (e.g. biblionumber, not "biblionumber AS `Biblio number`). To test, apply the patch and run a report which will return examples of each kind of data. I used: SELECT biblio.biblionumber , biblio.title, items.itemnumber, items.itemcallnumber, items.barcode, borrowers.firstname, borrowers.surname, borrowers.borrowernumber, borrowers.cardnumber FROM issues LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber LEFT JOIN items ON issues.itemnumber=items.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber ORDER BY RAND() LIMIT 50 When the report runs you should see that the data in each affected column is displayed as a link, each of which should trigger the correct menu. Test each case to confirm that the correct page is opened. Test the "toggle data menus" control. Clicking it should hide and show the menus in the report results. Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com> (In reply to Katrin Fischer from comment #6) > I think the feature is super nice, but there is a big issue for me as it > will currently only work on the English column names. I hadn't tested it with the new placeholder system, but after rebasing the patch and looking again my tests were successful, with one glitch: If there is a space inside the column name placeholder it won't work. So the SQL you tried: SELECT i.itemnumber, i.itemnumber as Exemplarnummber, [[i.itemnumber| itemnumber for batch]], CONCAT('<a href=\"/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=', i.biblionumber, '&itemnumber=', i.itemnumber, '#edititem', '\">', i.itemnumber, '</a>' ) AS "itemnumber as edit link" FROM items i "[[i.itemnumber| itemnumber for batch]]" has a space before "itemnumber for batch." With that space removed it works as expected. I think this must be considered a bug in the placeholder parsing, since this query will fail to trigger the expected batch item modification menu: SELECT i.itemnumber AS ' itemnumber for batch' FROM items i (In reply to Owen Leonard from comment #11) > I think this must be > considered a bug in the placeholder parsing I have filed Bug 27824 I feel like it would be nice if the "toggle data menus" setting would be kept between multiple runs of the report or when paging, changing the number of results displayed etc. I think it would also make it a little more accessible to change the text and not just the icon. Maybe "Show data menus" / "Hide data menus"? Really small complaints, I think this is really nice :) Owen, what do you think?
> I think it would also make it a little more accessible to change the text
> and not just the icon. Maybe "Show data menus" / "Hide data menus"?
Just realized - the hide/show is how the SQL button on the same page works as well!
Created attachment 117755 [details] [review] Bug 5697: (follow-up) Save the user's choice to show or hide auto-links This patch adds local storage of the user's selection when they click the "Show/hide data menus" control. The selection persists until the user logs out. To test, apply the patch and run an SQL report which will return borrowernumber, cardnumber, itemnumber, or biblionumber. - When the results display, confirm that these numbers are shown with the auto-link menu. - Click the "Hide data menus" link. The text should change to "Show data menus" and the menus should disappear. - Navigate away from the page and re-run the report. - The menus should be automatically hidden in the results. - Log out of the staff client, return to saved reports, and run the report again. - The auto-link menus should appear. Created attachment 117765 [details] [review] Bug 5697: Automatic linking in guided reports This patch modifies the output of reports so that if certain columns are returned the data in the colums automatically offer menus of actions: - borrowernumber: View, edit, check out - cardnumber: Check out - itemnumber: View, edit - biblionumber: View, edit Like the menu of batch operations, this functionality is available only if the column is returned with its original name (e.g. biblionumber, not "biblionumber AS `Biblio number`). To test, apply the patch and run a report which will return examples of each kind of data. I used: SELECT biblio.biblionumber , biblio.title, items.itemnumber, items.itemcallnumber, items.barcode, borrowers.firstname, borrowers.surname, borrowers.borrowernumber, borrowers.cardnumber FROM issues LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber LEFT JOIN items ON issues.itemnumber=items.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber ORDER BY RAND() LIMIT 50 When the report runs you should see that the data in each affected column is displayed as a link, each of which should trigger the correct menu. Test each case to confirm that the correct page is opened. Test the "toggle data menus" control. Clicking it should hide and show the menus in the report results. Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Created attachment 117766 [details] [review] Bug 5697: (follow-up) Save the user's choice to show or hide auto-links This patch adds local storage of the user's selection when they click the "Show/hide data menus" control. The selection persists until the user logs out. To test, apply the patch and run an SQL report which will return borrowernumber, cardnumber, itemnumber, or biblionumber. - When the results display, confirm that these numbers are shown with the auto-link menu. - Click the "Hide data menus" link. The text should change to "Show data menus" and the menus should disappear. - Navigate away from the page and re-run the report. - The menus should be automatically hidden in the results. - Log out of the staff client, return to saved reports, and run the report again. - The auto-link menus should appear. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Thx for the follow-up - love this even more now! Please remember to add text for the release notes! Why opening in a new window? (target="_blank") Let's teach people middle-click exists! :D Created attachment 117988 [details] [review] Bug 5697: Consolidate nodes construction and fix translation issue The way the buttons were created was not nice as it was a full HTML node built with a JS string, on a single line. I first tried to split the line and then realized but could put in a function and reuse. Then noticed that the button's text was not translatable. I ended up with this patch. I don't know if it's more readable, but at least it seems a bit more robust and maintainable in the long term. Would you agree with this patch, Owen? Hum, should we expect an impact on perfs with this last patch? Martin, Nick, can you have a look at the last patch please? (In reply to Jonathan Druart from comment #20) > Why opening in a new window? (target="_blank") > Let's teach people middle-click exists! :D We always add target="_blank" because we don't want them to rerun the more complicated queries a lot of times because they don't know about the middle click or forget about it. I would prefer it opening in a new tab by default in this case! if you middle click it anyway, that would not hurt. Created attachment 118022 [details]
testing performance on a report with many rows
It looks like the initial patch almost doubles the time to load the page fully, and the final patch add about the same
I don't know how typical this many results is, and I really love the concept here, so I am not sure if this is a concern
I wonder how the performance would be affected if we built the links in the template instead of with a render function and then just hid/displayed with JS? Created attachment 127484 [details] [review] Bug 5697: Automatic linking in guided reports This patch modifies the output of reports so that if certain columns are returned the data in the colums automatically offer menus of actions: - borrowernumber: View, edit, check out - cardnumber: Check out - itemnumber: View, edit - biblionumber: View, edit Like the menu of batch operations, this functionality is available only if the column is returned with its original name (e.g. biblionumber or [[biblionumber|Biblio number]] but not "biblionumber AS `Biblio number`). To test, apply the patch and run a report which will return examples of each kind of data. I used: SELECT biblio.biblionumber , biblio.title, items.itemnumber, items.itemcallnumber, items.barcode, borrowers.firstname, borrowers.surname, borrowers.borrowernumber, borrowers.cardnumber FROM issues LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber LEFT JOIN items ON issues.itemnumber=items.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber ORDER BY RAND() LIMIT 50 When the report runs you should see that the data in each affected column is displayed as a link, each of which should trigger the correct menu. Test each case to confirm that the correct page is opened. Test the "toggle data menus" control. Clicking it should hide and show the menus in the report results. The selection persists until the user logs out. Created attachment 128252 [details] [review] Bug 5697: Automatic linking in guided reports This patch modifies the output of reports so that if certain columns are returned the data in the colums automatically offer menus of actions: - borrowernumber: View, edit, check out - cardnumber: Check out - itemnumber: View, edit - biblionumber: View, edit Like the menu of batch operations, this functionality is available only if the column is returned with its original name (e.g. biblionumber or [[biblionumber|Biblio number]] but not "biblionumber AS `Biblio number`). To test, apply the patch and run a report which will return examples of each kind of data. I used: SELECT biblio.biblionumber , biblio.title, items.itemnumber, items.itemcallnumber, items.barcode, borrowers.firstname, borrowers.surname, borrowers.borrowernumber, borrowers.cardnumber FROM issues LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber LEFT JOIN items ON issues.itemnumber=items.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber ORDER BY RAND() LIMIT 50 When the report runs you should see that the data in each affected column is displayed as a link, each of which should trigger the correct menu. Test each case to confirm that the correct page is opened. Test the "toggle data menus" control. Clicking it should hide and show the menus in the report results. The selection persists until the user logs out. Signed-off-by: David Nind <david@davidnind.com> Created attachment 128277 [details] [review] Bug 5697: Automatic linking in guided reports This patch modifies the output of reports so that if certain columns are returned the data in the colums automatically offer menus of actions: - borrowernumber: View, edit, check out - cardnumber: Check out - itemnumber: View, edit - biblionumber: View, edit Like the menu of batch operations, this functionality is available only if the column is returned with its original name (e.g. biblionumber or [[biblionumber|Biblio number]] but not "biblionumber AS `Biblio number`). To test, apply the patch and run a report which will return examples of each kind of data. I used: SELECT biblio.biblionumber , biblio.title, items.itemnumber, items.itemcallnumber, items.barcode, borrowers.firstname, borrowers.surname, borrowers.borrowernumber, borrowers.cardnumber FROM issues LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber LEFT JOIN items ON issues.itemnumber=items.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber ORDER BY RAND() LIMIT 50 When the report runs you should see that the data in each affected column is displayed as a link, each of which should trigger the correct menu. Test each case to confirm that the correct page is opened. Test the "toggle data menus" control. Clicking it should hide and show the menus in the report results. The selection persists until the user logs out. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Looks really great :D I'm testing for push to master Pushed to master for 22.05, thanks to everybody involved [U+1F984] *** Bug 22535 has been marked as a duplicate of this bug. *** Reopening to document. See https://gitlab.com/koha-community/koha-manual/-/merge_requests/770 for the merge request. |