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

Create a mixin for confirmation dialogs when working with long forms

オープン
#1,569 コメント 1 件 リアクション 0 件 担当者 1 名 @snewcomer が担当を希望しています GitHub で見る
Difficulty: Easy in progress Priority: Low Skill: Ember.js
主要言語
JavaScript
スター
120
フォーク
75
PR マージ指標
30日以内にマージされた PR はありません

説明

# 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();
}
}
})
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。