Problem/Motivation

The "Remove one" button makes it difficult to manage denominations in the form. Instead, there should be a remove button for each denomination, that way if you need to remove one that's higher up in the list you don't need to remove and re-add all the others that come after it.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

rakesh.gectcr created an issue. See original summary.

TylerMarshall’s picture

Also issue related, would probably get solved in this, but if you Add a denomination, but want to remove it, you can't because it doesn't exist.

TylerMarshall’s picture

Assigned: Unassigned » TylerMarshall
pbrown063’s picture

StatusFileSize
new3.02 KB

Where I am at sofar with this patch:

- Moved the 'Remove' button into the array
- Fiddled with the 'removeCallback' (with little success)

What needs to be done:

- Determine how to extract the index number from $form['denominations'] on button click
- Use that number to delete the entry in the CurrencyDenominationsList

TylerMarshall’s picture

I think we will need to rebuild the way the denominations Add works, to also use a more OOO approach. This would let use use proper ajax commands. Have a WIP

rakesh.gectcr’s picture

IMHO, There is not much Difference about the Form APIs works in Drupal 7 and Drupal 8

pbrown063’s picture

StatusFileSize
new3.28 KB
new3.37 KB

Updated patch with diff files.

Where I have it in this state:

- Indexed each 'remove' button and gave it a unique value
- removeCallback now modifies the $form directly

What needs to be done:

- The changes that I am making to the form directly are being overwritten on a rebuild
- And that override needs to be prevented or utilised with these changes.

shabana.navas’s picture

StatusFileSize
new134.99 KB

Just tested this and you're right, the values are getting overwritten/lost. There's also an issue where when we click on 'Add one more' the remove button's label title changes to 'Remove Array'. The first thing is

$default_label = [];

should be

$default_label = '';

I checked it further and $denom is coming up empty after that ajax call so trying to retrieve this:

$default_label = $denom[$i]['label'];

comes up empty.

shabana.navas’s picture

Status: Active » Needs work
shabana.navas’s picture

StatusFileSize
new4.83 KB

A couple of changes to the earlier patch which fixes the issue with the Remove button coming up with empty denominations whenever the 'Add one more' button was clicked.

shabana.navas’s picture

Status: Needs work » Needs review
StatusFileSize
new40.74 KB

A fully working and more refined way to add/remove denominations.

shabana.navas’s picture

StatusFileSize
new5.52 KB

Oops posted wrong patch earlier.

shabana.navas’s picture

rakesh.gectcr’s picture

Status: Needs review » Needs work

Well the patch perfectly fine, Need a small change on
'#value' => t('Remove') . " " . $default_label,
We should not concatenate strings to translatable strings
Its hould be in following way
'#value' => t('Remove @default_label', ['@default_label' => $default_label]),

rakesh.gectcr’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new5.54 KB
new674 bytes

Thanks to all for the above patches. I am adding a quick patch for above one.

So I am moving into RTBC.

rakesh.gectcr’s picture

Status: Reviewed & tested by the community » Needs review

I will move to RTBC, ones the test get pass.

The last submitted patch, 7: 2906918-7.diff, failed testing. View results

TylerMarshall’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!

TylerMarshall’s picture

Status: Reviewed & tested by the community » Needs review

Er testing updated for me to not passed. Will check that first.

smccabe’s picture

Status: Needs review » Reviewed & tested by the community

@Tyler_Marshall, the test failure was just on the interdiff triggering testing, the actual patch passed correctly.

  • smccabe committed 3874436 on 8.x-2.x authored by pbrown063
    Issue #2906918 by shabana.navas, pbrown063, rakesh.gectcr: The "Remove...
smccabe’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.