code-corps / code-corps/code-corps-ember

Create a mixin for confirmation dialogs when working with long forms

Abierto
#1,569 1 comentario 0 reacciones 1 asignado Reclamado por @snewcomer Ver en GitHub
Difficulty: Easy in progress Priority: Low Skill: Ember.js
Lenguaje dominante
JavaScript
Estrellas
120
Forks
75
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

# Problem

We have a number of places where we ask a user to confirm before leaving the page. We could write a mixin to help clean up this logic.

```js
export default Ember.Mixin.extend({;
modelName: null,
message: 'You will lose any unsaved information if you leave this page. Are you sure?',

actions: {
willTransition() {
let modelName = get(this, 'modelName');
if (isPresent(modelName)) {
let model = get(this, modelName);
if (get(modelName, 'isNew') {
this._confirmTransition(transition, model);
}
} else {
this._confirmTransition(transition);
}
}
},

_confirmTransition(transition, model) {
let message = get(this, 'message');
if (window.confirm(message)) {
if isPresent(model) {
model.destroyRecord();
}
} else {
transition.abort();
}
}
})
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.