12479: Syntax error fixed.
[arvados.git] / apps / workbench / app / assets / javascripts / edit_collection.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 // On loading of a collection, enable the "lock" button and
6 // disable all file modification controls (upload, rename, delete)
7 $(document).
8     ready(function(event) {
9         $(".btn-collection-file-control").addClass("disabled");
10         $(".btn-collection-rename-file-span").attr("title", "Unlock collection to rename file");
11         $(".btn-collection-remove-file-span").attr("title", "Unlock collection to remove file");
12         $(".btn-remove-selected-files").attr("title", "Unlock collection to remove selected files");
13         $(".tab-pane-Upload").addClass("disabled");
14         $(".tab-pane-Upload").attr("title", "Unlock collection to upload files");
15         $("#Upload-tab").attr("data-toggle", "disabled");
16     }).
17     on('click', '.lock-collection-btn', function(event) {
18         classes = $(event.target).attr('class')
19
20         if (classes.indexOf("fa-lock") != -1) {
21             // About to unlock; warn and get confirmation from user
22             if (confirm("Adding, renaming, and deleting files changes the portable data hash. Are you sure you want to unlock the collection?")) {
23                 $(".lock-collection-btn").removeClass("fa-lock");
24                 $(".lock-collection-btn").addClass("fa-unlock");
25                 $(".lock-collection-btn").attr("title", "Lock collection to prevent editing files");
26                 $(".btn-collection-rename-file-span").attr("title", "");
27                 $(".btn-collection-remove-file-span").attr("title", "");
28                 $(".btn-collection-file-control").removeClass("disabled");
29                 $(".btn-remove-selected-files").attr("title", "");
30                 $(".tab-pane-Upload").removeClass("disabled");
31                 $(".tab-pane-Upload").attr("data-original-title", "");
32                 $("#Upload-tab").attr("data-toggle", "tab");
33             } else {
34                 // User clicked "no" and so do not unlock
35             }
36         } else {
37             // Lock it back
38             $(".lock-collection-btn").removeClass("fa-unlock");
39             $(".lock-collection-btn").addClass("fa-lock");
40             $(".lock-collection-btn").attr("title", "Unlock collection to edit files");
41             $(".btn-collection-rename-file-span").attr("title", "Unlock collection to rename file");
42             $(".btn-collection-remove-file-span").attr("title", "Unlock collection to remove file");
43             $(".btn-collection-file-control").addClass("disabled");
44             $(".btn-remove-selected-files").attr("title", "Unlock collection to remove selected files");
45             $(".tab-pane-Upload").addClass("disabled");
46             $(".tab-pane-Upload").attr("data-original-title", "Unlock collection to upload files");
47             $("#Upload-tab").attr("data-toggle", "disabled");
48         }
49     });