-
Notifications
You must be signed in to change notification settings - Fork 79
/
plot-create.js
43 lines (38 loc) · 1.23 KB
/
plot-create.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default Controller.extend({
flashMessages: service(),
gameApi: service(),
session: service(),
title: '',
summary: '',
description: '',
storyteller: null,
resetOnExit: function() {
this.set('title', '');
this.set('summary', '');
this.set('description', '');
this.set('storyteller', null);
},
actions: {
storytellerChanged(storyteller) {
this.set('storyteller', storyteller);
},
save: function() {
let api = this.get('gameApi');
api.requestOne('createPlot', {
title: this.get('title'),
summary: this.get('summary'),
storyteller_id: this.get('storyteller.id'),
description: this.get('description')}, null)
.then( (response) => {
if (response.error) {
return;
}
this.transitionToRoute('plot',
response.id);
this.get('flashMessages').success('Plot created!');
});
}
}
});