# ember-ds-inline-edit

> EmberJS addon for editing DS.models inline

Latest version **0.4.2** (published 2017-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-ds-inline-edit
pnpm add ember-ds-inline-edit
yarn add ember-ds-inline-edit
bun add ember-ds-inline-edit
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2017-08-23 |
| First published | 2016-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.12.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Ilias Deros |
| Maintainers | iliasderos |
| Keywords | ember-addon |

## Links

- npm: https://www.npmjs.com/package/ember-ds-inline-edit
- Repository: https://github.com/IliasDeros/ember-ds-inline-edit
- Homepage: https://github.com/IliasDeros/ember-ds-inline-edit#readme
- Issues: https://github.com/IliasDeros/ember-ds-inline-edit/issues
- npm.io page: https://npm.io/package/ember-ds-inline-edit

## Dependencies (2)

- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) 6.8.1
- [ember-cli-htmlbars](https://npm.io/package/ember-cli-htmlbars.md) 1.3.4

## Recent versions

- 0.4.2 (latest) — 2017-08-23
- 0.4.1 — 2017-08-14
- 0.4.0 — 2017-08-14
- 0.3.9 — 2017-08-04
- 0.3.8 — 2017-08-04
- 0.3.7 — 2017-08-04
- 0.3.6 — 2017-08-04
- 0.3.5 — 2017-08-04
- 0.3.4 — 2017-08-03
- 0.3.3 — 2017-08-03
- 0.3.2 — 2017-07-06
- 0.3.1 — 2017-04-17
- 0.3.0 — 2017-04-17
- 0.2.0 — 2017-02-07
- 0.1.1 — 2016-12-28
- … 1 more at https://npm.io/package/ember-ds-inline-edit/versions

## README

Edit an ember DS.model inline by clicking on it to toggle editor.
Click outside or press escape to rollback change and cancel edit.

inspired by [ember-inline-edit](https://github.com/swastik/ember-inline-edit)

![Inline Edit Demo](https://github.com/IliasDeros/ember-ds-inline-edit/raw/master/demo.gif)

## Installation

`ember install ember-ds-inline-edit`

## Usage

Use the `ds-inline-edit` component and provide it a model with the property to edit/display.

```handlebars
  {{ds-inline-edit
    model=model
    prop='name'
    customUpdate=(action updateModelName)
    onError=(action send 'onError')
    onUpdate=(action send 'onUpdate')
  }}
```

Customize input template using `#ds-inline-edit` :

```handlebars
  {{#ds-inline-edit model=person prop='age' as |age|}}
    {{input type="number" class="form-control" value=age}}
  {{/ds-inline-edit}}
```

#### Ember Data Integration

By default, this plugin relies on a strict usage of Ember Data. An automatic model update is sent upon confirming edit. This behavior can be overriden by passing in a _customUpdate_ action :
`customUpdate(value, model, prop)`

If the `prop` is an object, the default display is the following property of the model :
`displayName` > `name` > `id`

Only the property identified through `prop` is updated, the rest of the model remains
uncommited.

When an update is successful, the `onUpdate` function is called with the updated model.

#### Extending this plugin

Feel free to extend `ds-inline-edit` using the following code :

```
// app/pods/components/ds-inline-edit
import DsInlineEdit from 'ds-inline-edit/components/ds-inline-edit'
export default DsInlineEdit.extend({})
```

You can override the following functions :
`onEditSuccess()` - Called when the model is updated successfully
`onEditError(error)` - Called on update failure (due to error from network or customUpdate)

#### Keyboard Support

Hit `enter` to confirm changes.
Hit `esc` or click outside the component to discard the changes.

#### Error Handling
When an error occurs, an `onError` action is executed.

---
_Source: https://npm.io/package/ember-ds-inline-edit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
