Closed (fixed)
Project:
Commerce Point of Sale (POS)
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 Nov 2017 at 01:01 UTC
Updated:
26 Jun 2018 at 22:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
shabana.navas commentedAdded changes to composer.json so the jQuery.print library is automatically downloaded and added to the commerce_pos/web/libraries directory.
Comment #4
smccabe commentedWith receipts and labels both getting merged in, this patch will probably need updating.
Comment #5
travis-bradbury commentedThe labels issue actually added the library to commerce_pos so we just need to change the receipt module to use that one instead of its own.
Comment #6
smccabe commentedAll the stuff in the README.md in receipts should probably be moved to the commerce_pos README as well and just referenced from the receipt and labels readmes.
Comment #7
deepakaryan1988@tbradbury
I've rerolled the existing latest patch.
Please review it.
Comment #8
deepakaryan1988Comment #9
deepakaryan1988@smccabe I have moved the README.md stuff to commerce_pos root.
Please review that.
Comment #10
subhojit777Remove these whitespaces.
Then this should be part of the base module's libraries.yml isn't it.
Comment #11
alexpottRe #10.2 it is already there.
We should also be removing the same section from modules/contrib/commerce_pos/modules/receipt/README.md - we only need one set of instructions to maintain.
One thing that gives me pause is the the label and receipt sub modules both use the jQuery print library but the main module does not. Is it worth introducing a small bridge module that handles the jQuery print library? In my mind we should also have a hook_requirements implementation that checks to see if the library has been installed and puts an error on the requirements page if it has not been.
Comment #12
alexpottAnother thought is that it would be great to make the jQuery.receipt dependency optional and a progressive enhancement as this would make automated testing of receipts and labels much simpler and possible on DrupalCI.
Comment #13
deepakaryan1988I have written the hook_requirement to check the jQuery.print is there not.
Comment #14
travis-bradbury commentedThe required file is /libraries/jQuery.print/jQuery.print.js (see commerce_pos.libraries.yml) so we could check for that rather that just the jQuery.print directory.
hook_requirements()'s return value is used to indicate what's wrong, whether the requirement is installed, and a severity. That could be better than a message during install and could be used during the runtime phase too. See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...I think this should also be added to the changes in the previous patch rather than a new patch that only adds the requirements hook.
Comment #15
deepakaryan1988Hello @tbradbury
I have done as you suggested in your comment.
Please review it now.
Comment #16
smccabe commentedComment #17
travis-bradbury commentedThe issues with trailing whitespace mentioned in #10 are still there. Git points them out when applying the patch:
The hook_requirements implementation needs a bit of work.
From https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension... we know that
REQUIREMENT_ERRORprevents intall:I don't think we should prevent install. Let's make it a warning so the user knows the next step, but isn't prevented from installing just because they didn't place the js library in its home yet.
There's also no check during the runtime phase yet. Let's add that so the Drupal status page reports whether the dependency is there or not.
The label module also uses this library so the hook_requirements should probably go in the main module, not the receipt one. I suggest looking at whether either submodule is installed and only warning at runtime if either actually exists.
The patch needs to address Alex's feedback about removing the documentation from the receipt module's README so it's not in two places.
Comment #18
deepakaryan1988Hello @tbradbury,
I have addressed all your points in this patch.
Please review this and let me know if it needs further enhancements.
Comment #19
deepakaryan1988Comment #20
alexpottIs it worthwhile working out how we can do progressive enhancement here. I.e. have a module that adds the library and enhance the forms that can use it? Because atm we have hard fails that hard to discover why.
Comment #21
deepakaryan1988As discussed with @tbradbury, I have written hook_requirements in core module and moved content of README.md from commerce_receipt to commerce_pos.
Please review now.
Comment #23
smccabe commented@alexpott
I think so, I don't care about it to much for actual users, but it makes the tests either skip or break on a significant part of functionality. I fought a hard to debug issues because of that just last week.
Do you think a fallback to a specific print button for all jquery.print options?
Comment #24
deepakaryan1988My bad. Previous patch wasn't well created.
Here is the new one.
Comment #25
travis-bradbury commentedDeepak, there's feedback that is still not addressed from #17 - there's no checking of requirements during the
runtimephase so the dependency doesn't show on the status report page.Here's a hook_requirements implementation from the Drupal 7 version of this module for an example of checking requirements during the runtime phase.
That example brings to mind something else that could improve with this patch. As an error it says "jQuery.print library is not installed.". That doesn't tell the user what to do, it just says what is. In the D7 version's
commerce_pos_payment_requirementsit describes the state when everything is OK "Payment methods configured" but helps the user figure out what to do if something is wrong: "No payment methods configured. Enable Commerce POS Payments for default payment methods or !link".Comment #26
deepakaryan1988Hello Travis,
I have addressed the issue with this patch.
Comment #28
deepakaryan1988I am re-rolling the patch again as previous patch was based on earlier version, so that's why it failed to apply.
Comment #29
alexpottThere's also the problem that rather than making the jQuery print library a progressive enhancement we making things more dependent on it. I.e. if you install commere_pos but not the label or receipt modules then you're going to get an irrelevant warning.
Comment #30
travis-bradbury commentedI had in mind that we'd be checking for the receipt/labels modules in
commerce_pos_requirements()rather than make another module but now it doesn't seem like a great idea. There's already a third module that uses the print library and it's probably no good to have to remember to update the requirements hook every time something else finds a use for the library.I chatted with Deepak and we decided it'd be better to go with another module as a bridge for this as Alex suggested in #11.
Comment #31
deepakaryan1988Hello Travis,
Shortly, I'll be uploading the submodule which you have mentioned earlier.
Comment #32
deepakaryan1988Hello @tbradbury
Please see this patch and let me know if it needs further enhancement.
Comment #35
travis-bradbury commentedThe
hook_help()implementation looks like it was taken right from commerce_pos_label; it calls a function from that module.There's still references to
commerce_pos/jQuery.printin the report and label module. They would have to usecommerce_pos_print/jQuery.printnow.There shouldn't be any space between the two closing parentheses here.
I'm still not a fan of the description here because it doesn't tell the user what to do.
How about something like "To print receipts, labels, and reports you must install the jQuery.print library."? Typically descriptions also link to somewhere but since we don't have documentation to link to and there's no way to install it from the UI we can assume people will look into the README at that point.
The patch makes all the sub-modules depend on the new print one. Do modules like commerce_pos_receipt actually require the print library? If not, they should recommend the print module, not depend on it. At this point I'm not sure if they already require it and making it optional could be a future enhancement or if we need to leave the print module as optional right now.
Comment #36
jnrfred commentedThis patch addresses suggestions and issues from #35
Comment #37
jnrfred commentedPrevious patch failed to apply. Here's a new one
Comment #38
jnrfred commentedThis patch creates a new module
commerce_pos_printand updates the receipt, label, reports submodules to use the print library as requiredTest for PosReceiptTest.php passed locally. I was able to print an order as well.
Comment #40
jnrfred commentedRemoved the added dependency (
commerce_pos_print) for thecommerce_posmodule. I think since we have added dependencies for label and report sub-modules there's no need to add it to the main module.Comment #41
jnrfred commentedComment #43
jnrfred commentedI hope this patch fixes the failing test. :)
Comment #45
smccabe commentedComment #46
smccabe commentedPatch is still looking for commerce_pos_print module, causing tests to fail.
Comment #47
smccabe commentedFred, i think there are some files missing from this patch, the changes are there, but the commerce_pos_print module is missing.
Comment #48
jnrfred commentedThanks Shawn for pointing out the missing files. This patch includes the missing files (commerce_pos_print module).
Comment #50
smccabe commentedCleaned up a little naming and some phpcs issues, otherwise good to go!