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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/* ------------------------------------------------------------------------
* Anmeldeverfahren und -sets
* ------------------------------------------------------------------------ */
import { $gettext } from './gettext';
const Admission = {
/**
* All registered rule types with their corresponding Vue components
*/
availableRules: {
ConditionalAdmission: 'ConditionalAdmission.vue',
CourseMemberAdmission: 'CourseMemberAdmission.vue',
LimitedAdmission: 'LimitedAdmission.vue',
LockedAdmission: 'LockedAdmission.vue',
ParticipantRestrictedAdmission: 'ParticipantRestrictedAdmission.vue',
PasswordAdmission: 'PasswordAdmission.vue',
PreferentialAdmission: 'PreferentialAdmission.vue',
TermsAdmission: 'TermsAdmission.vue',
TimedAdmission: 'TimedAdmission.vue'
},
getCourses: function(targetUrl) {
var courseFilter = $('input[name="course_filter"]').val();
if (courseFilter === '') {
courseFilter = '%%%';
}
var data = {
'courses[]': _.map($('#courselist input:checked'), 'id'),
course_filter: courseFilter,
semester: $('select[name="semester"]').val(),
'institutes[]': $.merge(
_.map($('input[name="institutes[]"]:hidden'), 'value'),
_.map($('input[name="institutes[]"]:checked'), 'value')
)
};
let loading = $gettext('Wird geladen');
$('#instcourses').empty();
$('<img/>', {
src: STUDIP.ASSETS_URL + 'images/loading-indicator.svg',
style: 'vertical-align: middle; width: 64px; height: 64px',
}).appendTo('#instcourses');
$('#instcourses').append(loading);
$('#instcourses').load(targetUrl, data);
return false;
},
updateInstitutes: function(elementId, instURL, courseURL, mode) {
if (elementId !== '') {
var query = '';
$('.institute').each(function() {
query += '&institutes[]=' + this.value;
});
switch (mode) {
case 'delete':
$('#' + elementId).remove();
break;
case 'add':
query += '&institutes[]=' + elementId;
$.post(instURL, query, function(data) {
$('#institutes').html(data);
});
break;
}
$('#instcourses :checked').each(function() {
query += '&courses[]=' + this.value;
});
this.getCourses(courseURL);
Admission.toggleNotSavedAlert();
}
},
checkUncheckAll: function(inputName, mode) {
switch (mode) {
case 'check':
$('input[name*="' + inputName + '"]').each(function() {
$(this).prop('checked', true);
});
break;
case 'uncheck':
$('input[name*="' + inputName + '"]').each(function() {
$(this).prop('checked', false);
});
break;
case 'invert':
$('input[name*="' + inputName + '"]').each(function() {
$(this).prop('checked', !$(this).prop('checked'));
});
break;
}
return false;
},
toggleNotSavedAlert: function() {
$('.hidden-alert').show();
}
};
export default Admission;
|