1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
6 on('click', '[data-toggle-permission] input[type=checkbox]', function() {
8 var keys = ['data-permission-uuid',
9 'data-permission-name',
10 'data-permission-head',
11 'data-permission-tail'];
15 data[attr] = $(this).closest('[' + attr + ']').attr(attr);
16 if (data[attr] === undefined) {
17 console.log(["Error: no " + attr + " established here.", this]);
21 var is_checked = $(this).prop('checked');
27 data: {'link[tail_uuid]': data['data-permission-tail'],
28 'link[head_uuid]': data['data-permission-head'],
29 'link[link_class]': 'permission',
30 'link[name]': data['data-permission-name']},
32 fail(function(jqxhr, status, error) {
33 $(this).prop('checked', false);
35 done(function(data, status, jqxhr) {
36 $(this).attr('data-permission-uuid', data['uuid']);
39 $(this).prop('disabled', false);
43 $.ajax('/links/' + data['data-permission-uuid'],
46 data: {'_method': 'DELETE'},
48 fail(function(jqxhr, status, error) {
49 $(this).prop('checked', true);
51 done(function(data, status, jqxhr) {
52 $(this).attr('data-permission-uuid', 'x');
55 $(this).prop('disabled', false);
58 $(this).prop('disabled', true);