Merge branch '11341-arvput-resume-error'
[arvados.git] / apps / workbench / app / assets / javascripts / edit_collection.js
1 // On loading of a collection, enable the "lock" button and
2 // disable all file modification controls (upload, rename, delete)
3 $(document).
4     ready(function(event) {
5         $(".btn-collection-file-control").addClass("disabled");
6         $(".tab-pane-Upload").addClass("disabled");
7         $("#Upload-tab").attr("data-toggle", "disabled");
8     }).
9     on('click', '.lock-collection-btn', function(event) {
10         classes = $(event.target).attr('class')
11
12         if (classes.indexOf("fa-lock") != -1) {
13             // About to unlock; warn and get confirmation from user
14             if (confirm("Adding, renaming, and deleting files changes the portable data hash. Are you sure you want to unlock the collection?")) {
15                 $(".lock-collection-btn").removeClass("fa-lock");
16                 $(".lock-collection-btn").addClass("fa-unlock");
17                 $(".lock-collection-btn").attr("title", "Lock collection to prevent editing files");
18                 $(".btn-collection-file-control").removeClass("disabled");
19                 $(".tab-pane-Upload").removeClass("disabled");
20                 $("#Upload-tab").attr("data-toggle", "tab");
21             } else {
22                 // User clicked "no" and so do not unlock
23             }
24         } else {
25             // Lock it back
26             $(".lock-collection-btn").removeClass("fa-unlock");
27             $(".lock-collection-btn").addClass("fa-lock");
28             $(".lock-collection-btn").attr("title", "Unlock collection to edit files");
29             $(".btn-collection-file-control").addClass("disabled");
30             $(".tab-pane-Upload").addClass("disabled");
31             $("#Upload-tab").attr("data-toggle", "disabled");
32         }
33     });