-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathcuration.js
More file actions
36 lines (32 loc) · 1.02 KB
/
curation.js
File metadata and controls
36 lines (32 loc) · 1.02 KB
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
const Curation = {
applyParam: function (select, param) {
const value = select.value;
const url = new URL(window.location.href);
if (!value) {
url.searchParams.delete(param);
} else {
url.searchParams.set(param, value);
}
window.location.replace(url.toString());
},
curateUser: function (e) {
e.preventDefault();
const url = $(this).parents('.curate-user-buttons').data('actionUrl');
const panel = $(this).parents('.curate-user');
panel.fadeOut('fast');
$.ajax({
url: url,
method: 'PUT',
dataType: 'script',
data: { user: { role_id: $(this).data('roleId') } }
}).fail(function (e) {
panel.show();
console.error(e);
alert('An error occurred while attempting to curate the user.');
});
return false;
},
init: function () {
$('.curate-user-buttons .btn').click(Curation.curateUser);
}
}