mantisbt-plugins / Snippets

Define snippets of text that can be easily pasted into text fields
MIT License
8 stars 12 forks source link

Order created snippets #34

Closed sandyjmh closed 6 years ago

sandyjmh commented 6 years ago

Have snippets ordered alphabetically to allow easier navigation. Or provide alternate way to manage snippets (grouping, categories with expand/collapse options perhaps).

dregad commented 6 years ago

As far as I can tell, Snippets are ordered alphabetically[1]...

dregad commented 6 years ago

Ah sorry, I guess you meant in the selection list snippet_list

dregad commented 6 years ago

In fact I think this is a bug, caused by the fact that the PHP associative array generated by the route_data() method (and before conversion to REST API in v2.2.0, by the xmlhttprequest_plugin_snippets() function) is converted to a JSON Object (i.e. an unordered collection) and not an Array.

Consequently, when the Snippets list is processed by the JavaScript to build the <select>, the entries are listed in ascending order of the snippet's ID instead of retaining the list's alphanumeric order.