1- import Controller from '@ember/controller ' ;
1+ import EditController from 'amber-ui/controllers/application/edit ' ;
22// eslint-disable-next-line ember/no-computed-properties-in-native-classes
33import { computed } from '@ember/object' ;
44import { inject as service } from '@ember/service' ;
55import { ActivityCategories } from 'amber-ui/constants' ;
66import { tracked } from '@glimmer/tracking' ;
77
8- export default class ActivitiesIcalController extends Controller {
8+ export default class ActivitiesIcalController extends EditController {
99 @service session ;
10-
1110 @tracked activityCategoryOptions ;
1211
1312 constructor ( ) {
@@ -24,22 +23,21 @@ export default class ActivitiesIcalController extends Controller {
2423
25242625 get categoriesParams ( ) {
27- const selected = this . activityCategoryOptions
26+ return this . activityCategoryOptions
2827 . filter ( ( category ) => category . checked )
2928 . map ( ( category ) => category . value ) ;
30- return `categories=${ selected . join ( ',' ) } ` ;
3129 }
3230
3331 get iCalBase ( ) {
3432 return `/ical/activities?key=${ this . session . currentUser . icalSecretKey } &user_id=${ this . session . currentUser . id } ` ;
3533 }
3634
3735 get iCalURL ( ) {
38- return `${ window . location . origin } ${ this . iCalBase } & ${ this . categoriesParams } ` ;
36+ return `${ window . location . origin } ${ this . iCalBase } ` ;
3937 }
4038
4139 get webcalURL ( ) {
42- return `webcal://${ window . location . host } ${ this . iCalBase } & ${ this . categoriesParams } ` ;
40+ return `webcal://${ window . location . host } ${ this . iCalBase } ` ;
4341 }
4442
4543 _activityCategoryToOption ( activityCategory ) {
@@ -49,4 +47,23 @@ export default class ActivitiesIcalController extends Controller {
4947 checked : true ,
5048 } ;
5149 }
50+
51+ saveCategories = ( ) => {
52+ const { currentUser } = this . session ;
53+ const selectedCategories = this . categoriesParams ;
54+
55+ currentUser . set ( 'icalCategories' , selectedCategories ) ;
56+
57+ return currentUser
58+ . save ( )
59+ . then ( ( ) => {
60+ this . flashNotice . sendSuccess ( 'Categorieën succesvol opgeslagen!' ) ;
61+ } )
62+ . catch ( ( error ) => {
63+ this . flashNotice . sendError (
64+ 'Er ging iets fout bij het opslaan van je categorieën.'
65+ ) ;
66+ console . error ( 'Failed to save categories:' , error ) ;
67+ } ) ;
68+ } ;
5269}
0 commit comments