@@ -19,7 +19,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
19
19
{
20
20
name : 'Title' ,
21
21
valuePath : 'title' ,
22
- extraValuePaths : [ 'event' , 'isLocked' ] ,
22
+ extraValuePaths : [ 'id' , ' event', 'isLocked' ] ,
23
23
isSortable : true ,
24
24
headerComponent : 'tables/headers/sort' ,
25
25
cellComponent : 'ui-table/cell/events/view/sessions/cell-session-title' ,
@@ -114,15 +114,18 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
114
114
@action
115
115
async deleteSession ( session_id ) {
116
116
this . set ( 'isLoading' , true ) ;
117
- try {
118
- let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
119
- await session . destroyRecord ( ) ;
120
- this . notify . success ( this . l10n . t ( 'Session has been deleted successfully.' ) ) ;
121
- } catch ( e ) {
122
- console . warn ( e ) ;
123
- this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
124
- }
125
- this . set ( 'isLoading' , false ) ;
117
+ let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
118
+ session . destroyRecord ( )
119
+ . then ( ( ) => {
120
+ this . notify . success ( this . l10n . t ( 'Session has been deleted successfully.' ) ) ;
121
+ this . refreshModel . bind ( this ) ( ) ;
122
+ } )
123
+ . catch ( ( ) => {
124
+ this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
125
+ } )
126
+ . finally ( ( ) => {
127
+ this . set ( 'isLoading' , false ) ;
128
+ } ) ;
126
129
}
127
130
128
131
@action
@@ -136,130 +139,161 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
136
139
}
137
140
138
141
@action
139
- async lockSession ( session_id ) {
140
- try {
141
- let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
142
- session . set ( 'isLocked' , true ) ;
143
- this . set ( 'isLoading' , true ) ;
144
- await session . save ( ) ;
145
- this . notify . success ( this . l10n . t ( 'Session has been locked successfully.' ) ) ;
146
- } catch ( error ) {
147
- this . notify . error ( this . l10n . t ( error . message ) ) ;
148
- }
149
- this . send ( 'refreshRoute' ) ;
150
- this . set ( 'isLoading' , false ) ;
142
+ lockSession ( session_id ) {
143
+ let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
144
+ session . set ( 'isLocked' , true ) ;
145
+ this . set ( 'isLoading' , true ) ;
146
+ session . save ( )
147
+ . then ( ( ) => {
148
+ this . notify . success ( this . l10n . t ( 'Session has been locked successfully.' ) ) ;
149
+ this . refreshModel . bind ( this ) ( ) ;
150
+ } )
151
+ . catch ( ( ) => {
152
+ this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
153
+ } )
154
+ . finally ( ( ) => {
155
+ this . set ( 'isLoading' , false ) ;
156
+ } ) ;
151
157
}
152
158
153
159
@action
154
- async unlockSession ( session_id ) {
155
- try {
156
- let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
157
- session . set ( 'isLocked' , false ) ;
158
- this . set ( 'isLoading' , true ) ;
159
- await session . save ( ) ;
160
- this . notify . success ( this . l10n . t ( 'Session has been unlocked successfully.' ) ) ;
161
- } catch ( error ) {
162
- this . notify . error ( this . l10n . t ( error . message ) ) ;
163
- }
164
- this . send ( 'refreshRoute' ) ;
165
- this . set ( 'isLoading' , false ) ;
160
+ unlockSession ( session_id ) {
161
+ let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
162
+ session . set ( 'isLocked' , false ) ;
163
+ this . set ( 'isLoading' , true ) ;
164
+ session . save ( )
165
+ . then ( ( ) => {
166
+ this . notify . success ( this . l10n . t ( 'Session has been unlocked successfully.' ) ) ;
167
+ this . refreshModel . bind ( this ) ( ) ;
168
+ } )
169
+ . catch ( ( ) => {
170
+ this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
171
+ } )
172
+ . finally ( ( ) => {
173
+ this . set ( 'isLoading' , false ) ;
174
+ } ) ;
166
175
}
167
176
168
177
@action
169
- async acceptProposal ( session_id , sendEmail ) {
170
- try {
171
- let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
172
- session . setProperties ( {
173
- sendEmail,
174
- 'state' : 'accepted' ,
175
- 'isMailSent' : sendEmail
178
+ acceptProposal ( session_id , sendEmail ) {
179
+ let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
180
+ session . setProperties ( {
181
+ sendEmail,
182
+ 'state' : 'accepted' ,
183
+ 'isMailSent' : sendEmail
184
+ } ) ;
185
+ this . set ( 'isLoading' , true ) ;
186
+ session . save ( )
187
+ . then ( ( ) => {
188
+ sendEmail ? this . notify . success ( this . l10n . t ( 'Session has been accepted and speaker has been notified via email.' ) )
189
+ : this . notify . success ( this . l10n . t ( 'Session has been accepted' ) ) ;
190
+ this . refreshModel . bind ( this ) ( ) ;
191
+ } )
192
+ . catch ( ( ) => {
193
+ this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
194
+ } )
195
+ . finally ( ( ) => {
196
+ this . set ( 'isLoading' , false ) ;
176
197
} ) ;
177
- this . set ( 'isLoading' , true ) ;
178
- await session . save ( ) ;
179
- sendEmail ? this . notify . success ( this . l10n . t ( 'Session has been accepted and speaker has been notified via email.' ) )
180
- : this . notify . success ( this . l10n . t ( 'Session has been accepted' ) ) ;
181
- } catch ( error ) {
182
- this . notify . error ( this . l10n . t ( error . message ) ) ;
183
- }
184
- this . send ( 'refreshRoute' ) ;
185
- this . set ( 'isLoading' , false ) ;
186
198
}
187
199
188
200
@action
189
- async confirmProposal ( session_id , sendEmail ) {
190
- try {
191
- let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
192
- session . setProperties ( {
193
- sendEmail,
194
- 'state' : 'confirmed' ,
195
- 'isMailSent' : sendEmail
201
+ confirmProposal ( session_id , sendEmail ) {
202
+ let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
203
+ session . setProperties ( {
204
+ sendEmail,
205
+ 'state' : 'confirmed' ,
206
+ 'isMailSent' : sendEmail
207
+ } ) ;
208
+ this . set ( 'isLoading' , true ) ;
209
+ session . save ( )
210
+ . then ( ( ) => {
211
+ sendEmail ? this . notify . success ( this . l10n . t ( 'Session has been confirmed and speaker has been notified via email.' ) )
212
+ : this . notify . success ( this . l10n . t ( 'Session has been confirmed' ) ) ;
213
+ this . refreshModel . bind ( this ) ( ) ;
214
+ } )
215
+ . catch ( ( ) => {
216
+ this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
217
+ } )
218
+ . finally ( ( ) => {
219
+ this . set ( 'isLoading' , false ) ;
196
220
} ) ;
197
- this . set ( 'isLoading' , true ) ;
198
- await session . save ( ) ;
199
- sendEmail ? this . notify . success ( this . l10n . t ( 'Session has been confirmed and speaker has been notified via email.' ) )
200
- : this . notify . success ( this . l10n . t ( 'Session has been confirmed' ) ) ;
201
- } catch ( error ) {
202
- this . notify . error ( this . l10n . t ( error . message ) ) ;
203
- }
204
- this . send ( 'refreshRoute' ) ;
205
- this . set ( 'isLoading' , false ) ;
206
221
}
207
222
208
223
@action
209
- async rejectProposal ( session_id , sendEmail ) {
210
- try {
211
- let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
212
- session . setProperties ( {
213
- sendEmail,
214
- 'state' : 'rejected' ,
215
- 'isMailSent' : sendEmail
224
+ rejectProposal ( session_id , sendEmail ) {
225
+ let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
226
+ session . setProperties ( {
227
+ sendEmail,
228
+ 'state' : 'rejected' ,
229
+ 'isMailSent' : sendEmail
230
+ } ) ;
231
+ this . set ( 'isLoading' , true ) ;
232
+ session . save ( )
233
+ . then ( ( ) => {
234
+ sendEmail ? this . notify . success ( this . l10n . t ( 'Session has been rejected and speaker has been notified via email.' ) )
235
+ : this . notify . success ( this . l10n . t ( 'Session has been rejected' ) ) ;
236
+ this . refreshModel . bind ( this ) ( ) ;
237
+ } )
238
+ . catch ( ( ) => {
239
+ this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
240
+ } )
241
+ . finally ( ( ) => {
242
+ this . set ( 'isLoading' , false ) ;
216
243
} ) ;
217
- this . set ( 'isLoading' , true ) ;
218
- await session . save ( ) ;
219
- sendEmail ? this . notify . success ( this . l10n . t ( 'Session has been rejected and speaker has been notified via email.' ) )
220
- : this . notify . success ( this . l10n . t ( 'Session has been rejected' ) ) ;
221
- } catch ( error ) {
222
- this . notify . error ( this . l10n . t ( error . message ) ) ;
223
- }
224
- this . send ( 'refreshRoute' ) ;
225
- this . set ( 'isLoading' , false ) ;
226
244
}
227
245
228
246
@action
229
- async updateRating ( rating , feedback ) {
230
- try {
231
- this . set ( 'isLoading' , true ) ;
232
- if ( rating ) {
233
- feedback . set ( 'rating' , rating ) ;
234
- await feedback . save ( ) ;
235
- } else {
236
- await feedback . destroyRecord ( ) ;
237
- }
238
- this . notify . success ( this . l10n . t ( 'Session feedback has been updated successfully.' ) ) ;
239
- } catch ( error ) {
240
- this . notify . error ( this . l10n . t ( error . message ) ) ;
247
+ updateRating ( rating , feedback ) {
248
+ this . set ( 'isLoading' , true ) ;
249
+ if ( rating ) {
250
+ feedback . set ( 'rating' , rating ) ;
251
+ feedback . save ( )
252
+ . then ( ( ) => {
253
+ this . notify . success ( this . l10n . t ( 'Session feedback has been updated successfully.' ) ) ;
254
+ this . refreshModel . bind ( this ) ( ) ;
255
+ } )
256
+ . catch ( ( ) => {
257
+ this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
258
+ } )
259
+ . finally ( ( ) => {
260
+ this . set ( 'isLoading' , false ) ;
261
+ } ) ;
262
+ } else {
263
+ feedback . destroyRecord ( )
264
+ . then ( ( ) => {
265
+ this . notify . success ( this . l10n . t ( 'Session feedback has been updated successfully.' ) ) ;
266
+ this . refreshModel . bind ( this ) ( ) ;
267
+ } )
268
+ . catch ( ( ) => {
269
+ this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
270
+ } )
271
+ . finally ( ( ) => {
272
+ this . set ( 'isLoading' , false ) ;
273
+ } ) ;
241
274
}
242
- this . send ( 'refreshRoute' ) ;
243
- this . set ( 'isLoading' , false ) ;
244
275
}
245
276
246
277
@action
247
- async addRating ( rating , session_id ) {
248
- try {
249
- let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
250
- this . set ( 'isLoading' , true ) ;
251
- let feedback = await this . store . createRecord ( 'feedback' , {
252
- rating,
253
- session,
254
- comment : '' ,
255
- user : this . authManager . currentUser
278
+ addRating ( rating , session_id ) {
279
+ let session = this . store . peekRecord ( 'session' , session_id , { backgroundReload : false } ) ;
280
+ this . set ( 'isLoading' , true ) ;
281
+ let feedback = this . store . createRecord ( 'feedback' , {
282
+ rating,
283
+ session,
284
+ comment : '' ,
285
+ user : this . authManager . currentUser
286
+ } ) ;
287
+ feedback . save ( )
288
+ . then ( ( ) => {
289
+ this . notify . success ( this . l10n . t ( 'Session feedback has been created successfully.' ) ) ;
290
+ this . refreshModel . bind ( this ) ( ) ;
291
+ } )
292
+ . catch ( ( ) => {
293
+ this . notify . error ( this . l10n . t ( 'An unexpected error has occurred.' ) ) ;
294
+ } )
295
+ . finally ( ( ) => {
296
+ this . set ( 'isLoading' , false ) ;
256
297
} ) ;
257
- await feedback . save ( ) ;
258
- this . notify . success ( this . l10n . t ( 'Session feedback has been created successfully.' ) ) ;
259
- } catch ( error ) {
260
- this . notify . error ( this . l10n . t ( error . message ) ) ;
261
- }
262
- this . send ( 'refreshRoute' ) ;
263
- this . set ( 'isLoading' , false ) ;
264
298
}
265
299
}
0 commit comments