ember-ds-inline-edit
Advanced tools
Comparing version 0.3.8 to 0.3.9
@@ -66,10 +66,22 @@ import Ember from 'ember' | ||
onEditSuccess(){ | ||
this._super(...arguments) | ||
this.onUpdate && this.onUpdate(...arguments) | ||
}, | ||
onEditError(error, previousValue){ | ||
this._super(...arguments) | ||
const prop = this.get('prop') | ||
this.set(`model.${prop}`, previousValue) | ||
this.onError ? this.onError(...arguments) : console.error(error) | ||
}, | ||
actions: { | ||
confirmEdit(){ | ||
const model = this.get('model') | ||
const prop = this.get('prop') | ||
const { model, prop, value } = this.getProperties('model', 'prop', 'value') | ||
const previousValue = model.get(prop) | ||
this.set('isEditing', false) | ||
model.set(prop, this.get('value')) | ||
model.set(prop, value) | ||
@@ -87,7 +99,4 @@ // only update the currently edited value | ||
return model.save() | ||
.then(updatedModel => this.onUpdate && this.onUpdate(updatedModel)) | ||
.catch(error => Ember.run(() => { | ||
model.set(prop, previousValue) | ||
this.onError ? this.onError(error) : console.error(error) | ||
})) | ||
.then(updatedModel => this.onEditSuccess(updatedModel)) | ||
.catch(error => this.onEditError(error, previousValue)) | ||
.finally(() => { | ||
@@ -94,0 +103,0 @@ Object.keys(modifiedAttrs).forEach(a => { |
{ | ||
"name": "ember-ds-inline-edit", | ||
"version": "0.3.8", | ||
"version": "0.3.9", | ||
"bugs": { | ||
@@ -5,0 +5,0 @@ "url": "https://github.com/IliasDeros/ember-ds-inline-edit/issues" |
@@ -46,2 +46,14 @@ Edit an ember DS.model inline by clicking on it to toggle editor. | ||
#### 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 `onEditSuccess` and `onEditError` functions for custom logic on all updates. | ||
#### Keyboard Support | ||
@@ -48,0 +60,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49180
102
64