Reorder maps

NimrodYanai
NimrodYanai

I sometimes find myself replacing maps, or want to put maps further up or down the list, but they are currently automatically ordered by the order I uploaded them.

I need a way to order the maps.

This can be done in two ways:


  1. Add a "map number" field to the map create and edit pages that will be the order of the maps.

  2. Allow dragging the maps into the order I want to put them it. If you use this option, it's also important to have a "pin" option so you don't accidentally drag the maps when scrolling the page.

 

Thank you :D

Comments

  • thaen
    thaen
    Posts: 1,090

    Makes sense.  I'll add it to the Feature Request list.  Thanks!

    Obsidian Portal Developer

  • NimrodYanai
    NimrodYanai
    Posts: 107

    Thanks!

  • NimrodYanai
    NimrodYanai
    Posts: 107

    Any news on this?

  • vadercomplex
    vadercomplex
    Posts: 92

     Hey @nimrodyanai! I've asked the team for an update. :~) 

    Obsidian Portal Support Druid | [email protected]

  • thaen
    thaen
    Posts: 1,090

    @NimrodYanai, thanks for checking!

    This request is on the list, but it hasn't had any work done on it.

    If we get some interest from other members, then it would be more likely to get worked on.

    In the mean time, this is something you could do on your Campaign with Custom JavaScript. (Side Note: the Custom JavaScript Accept/Reject UX has been improved significantly.)

    I'm thinking something like the top solution here, but instead of the sort looking at the text, you'd have an array of the map names ordered the way you want them in your code, and then in the sort, you'd order by the index of the name in the array.

    https://stackoverflow.com/questions/1134976/how-may-i-sort-a-list-alphabetically-using-jquery

     

    Obsidian Portal Developer

  • thaen
    thaen
    Posts: 1,090

    @NimrodYanai,

    I just used ChatGPT to get about 90% of the way to a working Custom JavaScript solution for this, and then tweaked it to get the rest of the way. Here's the code:


    $(function() {
    var mapNamesOrder = [
    "Map 1",
    "Map 2",
    "Map 3",
    "Map 4"
    ];

    // Function to sort map entries by name
    function sortMapsByName() {
    var $mapList = $('.campaign-map-index #map-thumbnails');
    var $mapEntries = $mapList.children('.map-entry');

    $mapEntries.sort(function(a, b) {
    var nameAIndex = mapNamesOrder.indexOf($(a).find('.map-name a').text());
    var nameBIndex = mapNamesOrder.indexOf($(b).find('.map-name a').text());

    if (nameAIndex == -1) { return 1; }
    if (nameBIndex == -1) { return -1; }

    return nameAIndex - nameBIndex;
    });

    $mapList.empty().append($mapEntries);
    }

    // Call the sort function when needed
    sortMapsByName();
    });

    In the mapNamesOrder array, you replace the "Map 1", "Map 2", etc with your map names in the order that you want them to appear on the page. Any that aren't in the mapNamesOrder list, will just sort to the bottom of the page in no particular order.

    Let me know if that works for you or not.

    Obsidian Portal Developer

Sign In or Register to comment.

June 2024
The Planewalker’s Guild

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions