Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eng 22484 ability to select multiple line items in a single click during refund #374

Conversation

grana-equinix
Copy link
Contributor

Fix #368

  • Adds two methods onClickInvoiceItemsSelectAll and checkSelectAllCheckboxStatus to handle click events on selecting the checkbox.
  • onClickInvoiceItemsSelectAll - will trigger when the select-all is checked and unchecked
  • checkSelectAllCheckboxStatus - will trigger when line items are checked and unchecked
  • New UI - Demo
Screenshot 2023-09-04 at 5 42 34 PM - Old UI: Screenshot 2023-09-04 at 7 59 17 PM

<div class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<input type="checkbox" id="selectall">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: how about using camelCase for new checkbox identifier?

(there are two naming styles exist for id in this file:

  1. snake like for div_refund_amount
  2. camel like for invoiceItems )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice suggestion we have renamed the selectall to selectAll.

*/
var onClickInvoiceItemsSelectAll = function(event){
var isChecked = false;
if ($(this).is(':checked')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we have this function specifically for selectAll (as it is reflected in its name), I think we can directly check by id like:
var isChecked = $('#selectAll').prop('checked');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have changed $(this).is(':checked') to $('#selectAll').prop('checked'); as $('#selectAll') make more sense here.

/*
* Attach handler onClickInvoiceItemsSelectAll for selectall checkbox
*/
$('input').filter(function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is only one Select All checkbox (pls correct if I am wrong) with known id (selectall or selectAll), can we use it directly like
$('#selectAll').click(onClickInvoiceItemsSelectAll);?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out we have update the event binding to $('#selectAll').click(onClickInvoiceItemsSelectAll);

$('input').filter(function() { return this.id.match(/tf_adj_/) }).each(function() {
var textFieldId = this.id;
var checkboxId = textToCheckboxId(this.id);
if(checkboxId && textFieldId){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking textFieldId might be redundant as there is a check of textToCheckboxId(textFieldId)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textFieldId is removed

var checkboxId = textToCheckboxId(this.id);
if(checkboxId && textFieldId){
$("#" + checkboxId).prop('checked', isChecked);
$("#" + textFieldId).prop('readonly', isChecked);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess to not to create new jQuery object repeatedly we can catch the object like
var textField = $(this); in the beginning of the function as use it like

textField.prop('readonly', isChecked);
        if (!isChecked) {
            textField.attr('value', textField.attr('originalValue'));
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you pushed it? Because I still see the old way of creating jQuery objects


/*
* When clicking checkbox for each item, disable amount and recompute total refund amount
* When clicking checkbox for each item, disable amount, check select all status and recompute total refund amount
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check Select All status or clicking on Select all

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link

@vlaskhilkevich vlaskhilkevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@pierre pierre merged commit 171992e into killbill:master Sep 11, 2023
5 checks passed
@grana-equinix grana-equinix deleted the ENG-22484-Ability-to-select-multiple-line-items-in-a-single-click-during-refund branch September 14, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to select all on refund form
4 participants