for-loop fix removes 'undefined' from reset dialog. See #12301 (rebased onto dev_5_0)



This is the same as gh-2560 but rebased onto dev_5_0.

----

Fixes https://trac.openmicroscopy.org.uk/ome/ticket/12301

To test:
 - open full image viewer, click "Edit" channels then "Reset".
 - Dialog should only have 2 buttons: OK & Cancel.