1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
7 on('click', '.collection-tag-save, .collection-tag-cancel', function(event) {
8 $('.edit-collection-tags').removeClass('disabled');
9 $('#edit-collection-tags').attr("title", "Edit tags");
10 $('.collection-tag-add').addClass('hide');
11 $('.collection-tag-remove').addClass('hide');
12 $('.collection-tag-save').addClass('hide');
13 $('.collection-tag-cancel').addClass('hide');
14 $('.collection-tag-field').prop("contenteditable", false);
16 on('click', '.edit-collection-tags', function(event) {
17 $('.edit-collection-tags').addClass('disabled');
18 $('#edit-collection-tags').attr("title", "");
19 $('.collection-tag-add').removeClass('hide');
20 $('.collection-tag-remove').removeClass('hide');
21 $('.collection-tag-save').removeClass('hide');
22 $('.collection-tag-cancel').removeClass('hide');
23 $('.collection-tag-field').prop("contenteditable", true);
24 $('div').remove('.collection-tags-status-label');
26 on('click', '.collection-tag-save', function(event) {
30 var $tags = $(".collection-tags-table");
31 $tags.find('tr').each(function (i, el) {
32 var $tds = $(this).find('td');
33 var $key = $tds.eq(1).text();
34 if ($key && $key.trim().length > 0) {
36 tag_data[$key.trim()] = $tds.eq(2).text().trim();
41 if (has_tags == false) {
42 to_send = {tag_data: "empty"}
44 to_send = {tag_data: tag_data}
47 $.ajax($(location).attr('pathname')+'/save_tags', {
50 }).success(function(data, status, jqxhr) {
51 $('.collection-tags-status').append('<div class="collection-tags-status-label alert alert-success"><p class="contain-align-left">Saved successfully.</p></div>');
52 }).fail(function(jqxhr, status, error) {
53 $('.collection-tags-status').append('<div class="collection-tags-status-label alert alert-danger"><p class="contain-align-left">We are sorry. There was an error saving tags. Please try again.</p></div>');
56 on('click', '.collection-tag-cancel', function(event) {
57 $.ajax($(location).attr('pathname')+'/tags', {
61 on('click', '.collection-tag-remove', function(event) {
62 $(this).parents('tr').detach();
64 on('click', '.collection-tag-add', function(event) {
65 var $collection_tags = $(this).closest('.collection-tags-container');
66 var $clone = $collection_tags.find('tr.hide').clone(true).removeClass('hide');
67 $collection_tags.find('table').append($clone);
69 on('keypress', '.collection-tag-field', function(event){
70 return event.which != 13;