change 'module bay' sorting to be alphabetical when installing module
NetBox version
v4.4.7
Feature type
Change to existing functionality
Proposed functionality
Currently when installing a module, the sorting in the 'module bay' dropdown appears to be by module id. Can we get this changed to be alphabetical?
Use case
When installing a module, let's suppose you created 3 modules called "fan1", "fan2", "fan3". Then you create 2 modules called "psu1", and "psu2".
Now let's say you did an oopsie and actually need 4 fan modules. So you go back and add 1 more fan module "fan4".
Now when you go to install modules, the drop down selector for "module bay" has "fan4" at the bottom of the list. Rather than having fan1, fan2, fan3, fan4, psu1, psu2 ... it actually is listed as fan1, fan2, fan3, psu1, psu2, fan4.
For devices with lots of modules, it can be confusing for users.
I'll add, that this seems to only be an issue if you manually create modules on a device after the device has been created from a device type. It seems during the device creation process, modules are created in alphabetical order, so they would naturally be alphabetical in the dropdown. But if you create modules after the fact, the alphabetical sorting is disrupted.
So now you end up with instances where maybe on some devices it IS alphabetical (by nature of device id's having been created that way), and other devices where it ISN'T, causing even further confusion.
Database changes
none
External dependencies
none
Honestly, I would consider this to be a bug, because it used to sort alphabetically before nested modules were introduced. Just as a note for anyone trying to fix this, making the below change helps by allowing a rebuild to work properly, but is not fully sufficient to correct the issue, as a number of operations still seem to put the tree in an inconsistent state. One of the most frustrating is a bulk rename. There is also a related bug when adopting components while adding a module where module bays are bulk updated and thus end up in an inconsistent state due to their save() method not being called.
class ModuleBay(ModularComponentModel, TrackingModelMixin, MPTTModel):
...
class MPTTMeta:
- order_insertion_by = ('module',)
+ order_insertion_by = ('module', 'name')
Whatever can be done to cut down on the number of manual MPTT rebuilds would be fantastic.
Agree that this is more of a bug, as the presented ordering of available bays does not match reasonable expectations.