Skip to content

Commit c3149de

Browse files
authored
Cleaning the categories for alpha agenda (#885)
* first version * Remove catogories from ical link * Trying to save the categories locally * add genootschapen * edit message * fix lint * use flash notifications for success and error * fix lint
1 parent 165d4bd commit c3149de

File tree

5 files changed

+40
-21
lines changed

5 files changed

+40
-21
lines changed

app/constants.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ const ActivityCategories = [
2323
'Algemeen',
2424
'Sociëteit',
2525
'Vorming',
26-
'Dinsdagkring',
27-
'Woensdagkring',
26+
'Kring',
2827
'ChOOSE',
2928
'IFES',
3029
'OZON',
3130
'Disputen',
32-
'Kiemgroepen',
31+
'Genootschapen',
3332
'Huizen',
3433
'Extern',
3534
'Eerstejaars',
36-
'Curiositates',
3735
];
3836

3937
const OpenQuestionTypes = ['text', 'textarea', 'number'];

app/controllers/activities/ical.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
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
33
import { computed } from '@ember/object';
44
import { inject as service } from '@ember/service';
55
import { ActivityCategories } from 'amber-ui/constants';
66
import { 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

2524
@computed('[email protected]')
2625
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
}

app/models/user.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default class User extends Model {
4545
// Security properties
4646
@attr otpRequired;
4747
@attr icalSecretKey;
48+
@attr icalCategories;
4849
@attr password;
4950

5051
// Technical properties

app/templates/activities/ical.hbs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
<div class='card-body'>
88
<div class='alert alert-info'>
99
<p>
10-
Als je de agenda's die je wilt volgen wilt aanpassen, dien je eerst
11-
in je agenda-programma je oude Alpha-agenda te verwijderen voordat
12-
je de nieuwe agenda-url toevoegt.
10+
Als je de agenda's die je wilt volgen wilt aanpassen, update die automatisch
11+
de bestaande agenda's in je agenda-applicatie.
1312
</p>
1413
<p class="mb-0">
1514
Hoe je de agenda in Google Calendar importeert staat
1615
<a href='https://support.google.com/calendar/answer/37100'>hier</a>
1716
uitgelegd.
1817
</p>
1918
</div>
19+
2020
<form class='row' id='activityCategoryForm'>
21-
{{#each activityCategoryOptions as |opt|}}
21+
{{#each this.activityCategoryOptions as |opt|}}
2222
<div class='col-sm-12 col-md-3'>
2323
<div class='form-check'>
2424
<Input
@@ -34,6 +34,11 @@
3434
</div>
3535
</div>
3636
{{/each}}
37+
<div class="col-12 mt-3">
38+
<button type="button" class="btn btn-primary" {{on "click" this.saveCategories}}>
39+
Opslaan
40+
</button>
41+
</div>
3742
</form>
3843

3944
<hr />
@@ -51,8 +56,8 @@
5156
anderen.
5257
</b>
5358
</div>
54-
<p><a href='{{webcalURL}}'><code>{{iCalURL}}</code></a> </p>
59+
<p><a href='{{this.webcalURL}}'><code>{{this.iCalURL}}</code></a></p>
5560
</div>
5661
</div>
5762
</div>
58-
</div>
63+
</div>

mirage/factories/activity.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ export default Factory.extend({
1616
'algemeen',
1717
'sociëteit',
1818
'vorming',
19-
'dinsdagkring',
20-
'woensdagkring',
19+
'kring',
2120
'choose',
2221
'ifes',
2322
'ozon',
2423
'disputen',
25-
'kiemgroepen',
24+
'genootschapen',
2625
'huizen',
2726
'extern',
28-
'curiositates',
2927
]),
3028

3129
afterCreate(activity, server) {

0 commit comments

Comments
 (0)