1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 $(document).on('shown.bs.modal', '#add-group-modal', function(event) {
6 // Disable the submit button on modal loading
7 $submit = $('#add-group-submit');
8 $submit.prop('disabled', true);
10 $('input[type=text]', event.target).val('');
11 $('#add-group-error', event.target).hide();
12 }).on('input propertychange', '#group_name_input', function(event) {
13 group_name = $(event.target).val();
14 $submit = $('#add-group-submit');
15 $submit.prop('disabled', (group_name === null || group_name === ""));
16 }).on('submit', '#add-group-form', function(event) {
17 var $form = $(event.target),
18 $submit = $(':submit', $form),
19 $error = $('#add-group-error', $form),
20 group_name = $('input[name="group_name_input"]', $form).val();
22 $submit.prop('disabled', true);
28 data: {group: {name: group_name, group_class: 'role'}},
30 done(function(data, status, jqxhr) {
33 fail(function(jqxhr, status, error) {
34 var errlist = jqxhr.responseJSON.errors;
36 if (Array.isArray(errlist)) {
37 errmsg = errlist.join();
39 errmsg = ("The server returned an error when creating " +
40 "this group (status " + jqxhr.status +
41 ": " + errlist + ").");
45 $submit.prop('disabled', false);