VeiaG

payload docs reorder

by VeiaG
Admin customization
v3
^3.28.1

Overview

Summary generated from the README

Adds drag-and-drop reordering of documents in selected collections and stores the position in a docOrder field. Front-end queries sort by docOrder through REST, Local API or GraphQL. It is configured in the plugins array with a list of collection slugs and an optional access function for the save endpoint. The plugin is deprecated in favor of Payload's built-in orderable option and targets Payload 3.28.1 and above.

Features

  • Drag-and-drop ordering of documents in collection lists
  • Stores order in a docOrder field usable as a sort key
  • Works with REST, Local API and GraphQL sorting
  • Optional initializeDocOrder to set values on existing documents
  • Configurable access function for the save-changes endpoint

Use cases

  • Order featured posts or products manually in the admin and query them by docOrder
  • Add manual ordering to a collection that already has existing documents

From the author

Docs-reorder plugin for PayloadCMS 3.0

Installation

npm i @veiag/payload-docs-reorder

4

Stars

0

Forks

0

Open Issues

1 years ago

Last Updated

11

Weekly Downloads

v1.0.2

npm Version

60.7 KB

Unpacked Size

1

Dependencies

GitHub stars

40 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 20264
Dec 5, 20264
Dec 4, 20264
Dec 3, 20264
Dec 2, 20264
Dec 1, 20264
Nov 30, 20264
Nov 29, 20264
Nov 28, 20264
Nov 27, 20264
Nov 26, 20264
Nov 25, 20264
Nov 24, 20264
Nov 23, 20264
Nov 22, 20264
Nov 21, 20264
Nov 20, 20264
Nov 19, 20264
Nov 18, 20264
Nov 17, 20264
Nov 16, 20264
Nov 15, 20264
Nov 14, 20264
Nov 13, 20264
Nov 12, 20264
Nov 11, 20264
Nov 10, 20264
Nov 9, 20264
Nov 8, 20264
Nov 7, 20264
Nov 6, 20264
Nov 5, 20264
Nov 4, 20264
Nov 3, 20264
Nov 2, 20264
Nov 1, 20264
Oct 31, 20264
Oct 30, 20264
Oct 29, 20264
Oct 28, 20264
Oct 27, 20264
Oct 26, 20264
Oct 25, 20264
Oct 24, 20264
Oct 23, 20264
Oct 22, 20264
Oct 21, 20264
Oct 20, 20264
Oct 19, 20264
Oct 18, 20264
Oct 17, 20264
Oct 16, 20264
Oct 15, 20264
Oct 14, 20264
Oct 13, 20264
Oct 12, 20264
Oct 11, 20264
Oct 10, 20264
Oct 9, 20264
Oct 8, 20264
Oct 7, 20264
Oct 6, 20264
Oct 5, 20264
Oct 4, 20264
Oct 3, 20264
Oct 2, 20264
Oct 1, 20264
Sep 30, 20264
Sep 29, 20264
Sep 28, 20264
Sep 27, 20264
Sep 26, 20264
Sep 25, 20264
Sep 24, 20264
Sep 23, 20264
Sep 22, 20264
Sep 21, 20264
Sep 20, 20264
Sep 19, 20264
Sep 18, 20264
Sep 17, 20264
Sep 16, 20264
Sep 15, 20264
Sep 14, 20264
Sep 13, 20264
Sep 12, 20264
Sep 11, 20264
Sep 10, 20264
Sep 9, 20264
Sep 8, 20264
Sep 7, 20264
npm weekly downloads

12+4 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202612
Dec 5, 202614
Dec 4, 20269
Dec 3, 20265
Dec 2, 20265
Dec 1, 20266
Nov 30, 20266
Nov 29, 20269
Nov 28, 20267
Nov 27, 20266
Nov 26, 20266
Nov 25, 20266
Nov 24, 20267
Nov 23, 20267
Nov 22, 20265
Nov 21, 20265
Nov 20, 20268
Nov 19, 20268
Nov 18, 202615
Nov 17, 202613
Nov 16, 202614
Nov 15, 202612
Nov 14, 202612
Nov 13, 20269
Nov 12, 20269
Nov 11, 20261
Nov 10, 20262
Nov 9, 20265
Nov 8, 20265
Nov 7, 202611
Nov 6, 202611
Nov 5, 202612
Nov 4, 202612
Nov 3, 202611
Nov 2, 20268
Nov 1, 202613
Oct 31, 20267
Oct 30, 20268
Oct 29, 20267
Oct 28, 20267
Oct 27, 20267
Oct 26, 20267
Oct 25, 20263
Oct 24, 20269
Oct 23, 20268
Oct 22, 202610
Oct 21, 202610
Oct 20, 202610
Oct 19, 20269
Oct 18, 20269
Oct 17, 20264
Oct 16, 20266
Oct 15, 20264
Oct 14, 20266
Oct 13, 20266
Oct 12, 20266
Oct 11, 20266
Oct 10, 20265
Oct 9, 20263
Oct 8, 20263
Oct 7, 20263
Oct 6, 20263
Oct 5, 20263
Oct 4, 20262
Oct 3, 20262
Oct 2, 20264
Oct 1, 20264
Sep 30, 20262
Sep 29, 20262
Sep 28, 20262
Sep 27, 20262
Sep 26, 20265
Sep 25, 20264
Sep 24, 20264
Sep 23, 20264
Sep 22, 20265
Sep 21, 20268
Sep 20, 20268
Sep 19, 20266
Sep 18, 202613
Sep 17, 202613
Sep 16, 202614
Sep 15, 202613
Sep 14, 202613
Sep 13, 202613
Sep 12, 202613
Sep 11, 20269
Sep 10, 20269
Sep 9, 20268
Sep 8, 202610
Sep 7, 20268

Each point is npm's rolling 7-day download count.

Health Score

31/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/952123617-root.svg)](https://payloaddirectory.dev/plugins/952123617-root)
HTML
<a href="https://payloaddirectory.dev/plugins/952123617-root"><img src="https://payloaddirectory.dev/badge/952123617-root.svg" alt="Payload Directory"></a>
Updated Apr 18, 2025Created Mar 20, 2025Published Mar 20, 2025

README

[!CAUTION] This plugin is deprecated, due to a new feature added to Payload - orderable

Docs reorder plugin for Payload 3 (^3.28.1)

This plugin has all of the features (and most of the code) of the original plugin by r1tsuu, but with some improvements and made compatible with latest Payload version. (3.28.1)

Install

npm i @veiag/payload-docs-reorder

About

Adds an option to re-order collection documents with drag n drop (almost like array/blocks items). Then on your front end you can query documents with applied sort by docOrder field.

Video

In your payload.config.ts:

/// ....
import { docsReorder } from '@veiag/payload-docs-reorder';

export default buildConfig({
  // ...
  plugins: [
    docsReorder({
      collections: {
        posts: true, //Slug of the collection
      },
      // Needed to initialize values of docOrder field in collection documents.
      // Only needed once per collection. 
      // (Run payload once (NOT in dev mode) with this option enabled , and more if you add new collection)
      initializeDocOrder: true,

      access: ({ req, data }) => {
        // Optional, configure access for `saveChanges` endpoint, default: Boolean(req.user)
        return req.user?.collection === 'admins';
      },
    }),
  ],
});

Querying with applied plugin's sort.

REST:

fetch('http://localhost:3000/api/examples?sort=docOrder').then((res) => res.json());

Local API:

payload.find({ collection: 'examples', sort: 'docOrder' });

GraphQL:

query {
  Examples(sort: "docOrder") {
    docs {
      title
    }
  }

Setup for collections that had documents before installing the plugin

The plugin uses the onInit function to initialize the docOrder field. However, it is not recommended to use this in development mode. It will trigger the afterChange hook, which in my case attempts to call revalidateTag and results in an error when building the admin panel: "Route /admin/[[...segments]] used 'revalidatePath' during render which is unsupported."

Running next start in production mode will not trigger the error, because pages are prerendered and the revalidateTag function is not called.

Issues

If you have any issues, please open an issue on this repository.

Similar plugins