I have a plugin that does a REST API call wrapped in an ajax construct: jQuery.ajax({ rest api stuff }).done(function() ...).fail(function() ...); Rapidly clicking Save (while the ajax is triggered by the Change event) lets the plugin shortly show an error before the form submits. Which is obviously undesirable. If we would replace this in addbiblio.tt: var onOption = function () { - return Check(); + if ( $('.plugin-blocks-submit').length==0 ) return Check(); } We can conditionally and temporarily block submittal. When the change event of the plugin fires, I add class plugin-no-submit to the html element involved. In the done and fail functions I remove the class again from the element. This effectively works. While several other approaches in addbiblio failed. (Removing the event handler is just too late.) This is a one-liner that will do the job. On bug 34860 I will still submit a ISBN/ISSN plugin using this class that will demonstrate its use. In the meantime this is a harmless check.
Actually, is it better move the condition to function Check itself.
Created attachment 157226 [details] [review] Bug 35062: Add class plugin-blocks-submit in addbiblio Adding this condition in Check() allows you to prevent form submittal during e.g. an ajax call in a framework plugin. The plugin adds and removes the class on the corresponding html element during processing. Test plan: Since we do not have a plugin using this class yet, nothing changes now. Verify that you can still click Save in addbiblio while using standard plugins. In other words: no change in behavior. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 157873 [details] [review] Bug 35062: Add class plugin-blocks-submit in addbiblio Adding this condition in Check() allows you to prevent form submittal during e.g. an ajax call in a framework plugin. The plugin adds and removes the class on the corresponding html element during processing. Test plan: Since we do not have a plugin using this class yet, nothing changes now. Verify that you can still click Save in addbiblio while using standard plugins. In other words: no change in behavior. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: David Nind <david@davidnind.com>
(In reply to David Nind from comment #3) > Signed-off-by: David Nind <david@davidnind.com> Thanks!
Created attachment 160936 [details] [review] Bug 35062: Add class plugin-blocks-submit in addbiblio Adding this condition in Check() allows you to prevent form submittal during e.g. an ajax call in a framework plugin. The plugin adds and removes the class on the corresponding html element during processing. Test plan: Since we do not have a plugin using this class yet, nothing changes now. Verify that you can still click Save in addbiblio while using standard plugins. In other words: no change in behavior. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Pushed for 24.05! Well done everyone, thank you!
Not backported to 23.11.x
Architecture change, nothing to add/edit in the Koha manual.