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

Support patching select sorting function #4903

Merged
merged 5 commits into from
May 31, 2024

Conversation

WithoutPants
Copy link
Collaborator

Adds support for patching the select component sorting method:

  • GallerySelect.sort
  • MovieSelect.sort
  • PerformerSelect.sort
  • SceneSelect.sort
  • StudioSelect.sort
  • TagSelect.sort

I made a proof of concept plugin that changes the sorting methods to use the legacy sorting (by name). The code for it is below:

const PluginApi = window.PluginApi;

function noopSort(input, o) {
    return o;
}

PluginApi.patch.instead('TagSelect.sort', noopSort);
PluginApi.patch.instead('PerformerSelect.sort', noopSort);
PluginApi.patch.instead('MovieSelect.sort', noopSort);
PluginApi.patch.instead('GallerySelect.sort', noopSort);
PluginApi.patch.instead('StudioSelect.sort', noopSort);
PluginApi.patch.instead('SceneSelect.sort', noopSort);

And the yml file:

name: Select sort alphabetically
description: Overrides the default select sorting behavior to sort alphabetically
url: https://github.com/stashapp/CommunityScripts
version: 0.1
ui:
  javascript:
  - selectSort.js

@WithoutPants WithoutPants added the improvement Something needed tweaking. label May 31, 2024
@WithoutPants WithoutPants added this to the Version 0.26.0 milestone May 31, 2024
@WithoutPants WithoutPants merged commit 540e80c into stashapp:develop May 31, 2024
2 checks passed
halkeye pushed a commit to halkeye/stash that referenced this pull request Sep 1, 2024
* Fix return types for RegisterComponent and PatchFunction
* Add support for patching TagSelect.sort
* Add support for patching PerformerSelect.sort
* Patch other select component sort functions
* Document patchable functions/components
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Something needed tweaking.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant