Fix "group into network" bug.

The "name" dialog pop up popped up after the nodes were already
grouped. We now ask the name first before grouping them in a network.

This fixes #316.