# keystone-list-prepend

> add prepend method to keystone.List() to unshift the given fields into the list

Latest version **1.0.1** (published 2018-12-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install keystone-list-prepend
pnpm add keystone-list-prepend
yarn add keystone-list-prepend
bun add keystone-list-prepend
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-12-18 |
| First published | 2018-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | laurens@goedideemedia.nl |
| Maintainers | laurenskling |
| Keywords | keystone, keystoneJS |

## Links

- npm: https://www.npmjs.com/package/keystone-list-prepend
- Repository: https://github.com/laurenskling/keystone-list-prepend
- Homepage: https://github.com/laurenskling/keystone-list-prepend#readme
- Issues: https://github.com/laurenskling/keystone-list-prepend/issues
- npm.io page: https://npm.io/package/keystone-list-prepend

## Recent versions

- 1.0.1 (latest) — 2018-12-18
- 1.0.0 — 2018-12-18

## README

# keystone-list-prepend

This is a rewrite of https://github.com/keystonejs/keystone/blob/master/lib/list/add.js

instead of `push`ing fields to the end of the List, it `unshift`s them to the beginning.


## why?
If you inherit from a List and add fields into it, they'll always end up at the end of the screen in the admin UI.
Mostly, you are inheriting from a List because it has some default fields. You don't want these fields on top in your admin UI, but you want the List specific fields first. By unshifting, you can add fields to the top of the page.

## How to use

This package injects a function on the List prototype in keystone. Use it like `.add`, e.g.:
```
const MyList = keystone.List('MyList');
MyList.prepend({
  newField: {
    type: String
  }
});
MyList.register();
```
This feature makes the most sense with `inherits`:
```
const BaseList = keystone.List('BaseList');
BaseList.add({
  name: {
    type: String
  },
  originalField: {
    type: String
  }
});
BaseList.register();

const MyList = keystone.List('MyList', {
  inherits: BaseList,
});
MyList.prepend({
  topField: {
    type: String,
  }
});
MyList.register();
```

`topField` will now be shown before `originalField` in the admin UI.

## installation

This package will register itself onto the prototype of the given keystone instance. Just require (or import) it and pass it `keystone`:
```
const keystone = require('keystone');
require('keystone-list-prepend')(keystone);
```

---
_Source: https://npm.io/package/keystone-list-prepend · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
