Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving Card's List using API leads to random sorting compared to Move Card dialogue where it ends up on top #5399

Open
C0rn3j opened this issue May 4, 2024 · 2 comments

Comments

@C0rn3j
Copy link
Contributor

C0rn3j commented May 4, 2024

Moving card across lists using UI makes sure it remains on top by default:

/** Move Card Dialog */
(class extends DialogWithBoardSwimlaneList {
  getDialogOptions() {
    const ret = ReactiveCache.getCurrentUser().getMoveAndCopyDialogOptions();
    return ret;
  }
  setDone(boardId, swimlaneId, listId, options) {
    ReactiveCache.getCurrentUser().setMoveAndCopyDialogOption(this.currentBoardId, options);
    const card = this.data();
    const minOrder = card.getMinSort(listId, swimlaneId); // < ---
    card.move(boardId, swimlaneId, listId, minOrder - 1); // < --- 
  }
}).register('moveCardPopup');

but in the card.edit() API, this is not done, so the card ends up being moved to a somewhat random spot in the list:

      if (req.body.listId) {
        const newParamListId = req.body.listId;
        Cards.direct.update(
          {
            _id: paramCardId,
            listId: paramListId,
            boardId: paramBoardId,
            archived: false,
          },
          {
            $set: {
              listId: newParamListId,
            },
          },
        );
        updated = true;

        const card = ReactiveCache.getCard(paramCardId);
        cardMove(
          req.body.authorId,
          card,
          {
            fieldName: 'listId',
          },
          paramListId,
        );
      }

copyCard() does such a sort:

      const sort = card.getSort(listId, swimlaneId, insertAtTop);
      if (insertAtTop) {
        card.sort = sort - 1;
      } else
      {
        card.sort = sort + 1;
      }

I am not sure what's correct here, but how about allowing two special values 'top' and 'bottom',
defaulting to top if [sort] isn't passed, otherwise just use numeric [sort] value if it is passed?

@xet7
Copy link
Member

xet7 commented May 4, 2024

@mfilser

What would be correct way to do this?

@mfilser
Copy link
Contributor

mfilser commented May 4, 2024

@xet7
I suggest to use the same code in API than using in the GUI, and futhermore, in each API call. It make's no sense to have different behaviour / code in API compared to GUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants