r1tsuu

payload plugin collections docs order

by r1tsuu
Admin customization
v3
3.0.0-beta.18

Overview

Summary generated from the README

Adds drag and drop re-ordering of documents in the list view for collections you choose. The order is stored in a docOrder field that you can sort by through the REST, Local and GraphQL APIs. Access to the save endpoint is configurable, and a setup script is provided for collections that already contain documents. Built for Payload 3.0 beta.

Features

  • Drag and drop document re-ordering in the admin
  • Enabled per collection through plugin config
  • Sort by docOrder in REST, Local API and GraphQL
  • Configurable access control for the save changes endpoint
  • Setup script for collections with existing documents

Use cases

  • Order pages or featured items manually for display on a front end
  • Let editors curate the sequence of documents without adding custom number fields

From the author

Plugin that adds an option to re-order collection documents with drag n drop

Installation

npm i monorepo

18

Stars

0

Forks

0

Open Issues

2 years ago

Last Updated

0

Weekly Downloads

v

npm Version

Dependencies

GitHub stars

180 since Sep 7

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

Trends appear after 7 days of data. Daily snapshots have not started yet.

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

Health Score

0/100Archived

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/759677117-root.svg)](https://payloaddirectory.dev/plugins/759677117-root)
HTML
<a href="https://payloaddirectory.dev/plugins/759677117-root"><img src="https://payloaddirectory.dev/badge/759677117-root.svg" alt="Payload Directory"></a>
Updated May 4, 2024Created Feb 19, 2024

README

Note!

This repository for 3.0 is deprecated and has been moved to https://github.com/r1tsuu/payload-enchants in order to keep all of my payload-related packages in 1 place. 2.0 branch

Payload Plugin Collections Docs Order for Payload 3.0

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

https://github.com/r1tsuu/payload-plugin-collections-docs-order/assets/64744993/2c13cdd9-f809-4c40-82c6-0b6f78997f74

Install

pnpm add @r1tsu/[email protected] In your payload.config.ts:

/// ....
import { collectionsDocsOrderPlugin } from '@r1tsu/payload-plugin-collections-docs-order';

export default buildConfig({
  // ...
  plugins: [
    collectionsDocsOrderPlugin({
      collections: [{ slug: 'pages' }], // The feature will be enabled only for collections that are in this array.,
      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
    }
  }

Script to setup for collections that had documents before installing the plugin

  1. Create folder named cli in your project's root
  2. Copy this file to the created folder and update collections array with your needs. https://gist.github.com/r1tsuu/047008be9800dfcbe371247d10ee6794
  3. Run the file like that: yarn ts-node --project ./tsconfig.server.json ./cli/pluginCollectionsDocsSetup.ts (It will run for a database that in your .env, also be sure to backup if this on production)

Similar plugins