The link for toggling the invitation new customer is missing. It uses also the contentToggler depending whether the session.request is open or closed. But on the div with the name "new-customer" setting the attribute hidden does not work. Why?
Debugging showed me that the document.getElementById('new-customer-form').innerText contains the expected fields like Vorname. Whereas document.getElementById('new-customer').innerText is empty. If I change the togglee from 'new-customer' to 'new-customer-form' the innerText is reverted. Why? Solved by creating a different onClick handler. Code works and looks like this
def new_customer_invite(model) togglee = 'new-customer-form' link = HtmlGrid::Link.new(:new_customer_invite, model, @session, self) script = " var element = document.getElementById('#{togglee}'); // console.log('new_customer_invite onclick second2: #{togglee} hidden '+ element.hidden); if (document.getElementById('#{togglee}').hidden) { document.getElementById('#{togglee}').hidden = false; } else { document.getElementById('#{togglee}').hidden = true; } " link.set_attribute("onclick", script) link end
Now I must show on how I can add a tooltip. To test it I go to http://virbac.bbmb.ngiger.ch/de/bbmb/increment_order/quantity%5B301365%5D/1 where "Contralac 20" shows a A-square the where the tooltip should show "Aktion: Aufgrund..", where "Aufgrund" is a link. Do I need dojo to create it or is it easier to create a simple javascript?
Replacing the dojo tooltip is much more work than the contenttoggler, because it would require CSS changes. Therefore investigating whether it is easy to port the dojo tooltip to the new dojo version.
But first I must fix lib/bbmb/html/view/current_order.rb, where we have also use the contenttoggler. This was easy to replace by our javascript approach.
Why does visiting http://virbac.bbmb.ngiger.ch/fr/bbmb/favorites/ throw the error NoMethodError undefined method `article_number' for nil:NilClass
? I am able to avoid this problem (which is present on virbac.bbmb.ch, too), but the resulting screen looks funny. I think it is an inconsistency in the database.
But the tooltip does not yet show up. Why? Must change the htmlgrid tooltip code. Created a small test_tooltip.html file and discovered that
<script type="text/javascript">require(['dojo','javascript/widget/ContentToggler']);</script>
works
<script type="text/javascript">require(['dojo', 'dijit/form/Button', 'dijit/Tooltip']);</script>
DOES NOT WORK. Why?
After fiddling around found, that <script type="text/javascript">require(["dojo/parser", "dijit/Tooltip"]);</script>
works. After changing lib/bbmb/virbac/html/view/current_order.rb to define DOJO_REQUIRE = ['dojo/parser', 'dijit/Tooltip']
the tooltips are displayed correctly, but with a different background color.
Pushed the commits:
Testing Kalkulieren. Clicking "With MwSt" gives in the javascript console the following output
calculator.js:5 Uncaught ReferenceError: dojo is not definedcalc @ calculator.js:5 onclick @ (index):13
But the calculated resulted after clicking on the button "Berechnen" show the correct results.
In doc/resources/javascript/calculator I find code like dojo.io.bind
, which I don't understand. Googling around found http://www.coderanch.com/t/617832/HTML-CSS-JavaScript/deciphering-Dojo-io-bind-code. Does this help me? not much.
The Javascript debugger for http://virbac.bbmb.ch/de/calculator/ showed that the dojo.io.bind is triggered by a POST request after dojo.js:2614 XHR finished loading:
I think I must completely rework the calculation and pack the with VAT, VAT-rate and factor into session parameters. Maybe https://dojotoolkit.org/documentation/tutorials/1.10/ajax/ helps me. Continue tomorrow.