|
1 | | -@(dataset: Dataset, currentFolder: Option[String], foldersList: List[Folder], folderHierarchy: List[Folder], filepage: Int, next: Boolean, fileList:List[File], fileComments: Map[UUID, Int], space: Option[String], filter: Option[String])(implicit user: Option[models.User]) |
| 1 | +@(dataset: Dataset, currentFolder: Option[String], foldersList: List[Folder], folderHierarchy: List[Folder], |
| 2 | + filepage: Int, next: Boolean, fileList:List[File], fileComments: Map[UUID, Int], space: Option[String], |
| 3 | + filter: Option[String])(implicit user: Option[models.User]) |
2 | 4 |
|
3 | 5 | <!-- Breadcrumbs --> |
4 | 6 | @if(folderHierarchy.length > 0 ) { |
|
27 | 29 | }); |
28 | 30 | }); |
29 | 31 | </script> |
30 | | - <!--label class="sortchoice" for="filename-filter">Filter:--> |
31 | | - <table width=100%""> |
32 | | - <td width="40%"> |
33 | | - <div class="input-group"> |
34 | | - <!-- TODO: Should the filter value reset when folder level changes? --> |
35 | | - <input type="text" class="form-horizontal form-control" id="filename-filter" placeholder="Search folder and file names..." |
36 | | - value="@filter.getOrElse("")" |
37 | | - onchange="getUpdatedFilesAndFolders()"> |
38 | | - <div class="input-group-btn"> |
39 | | - <button class="btn btn-default" onclick="getUpdatedFilesAndFolders()"> |
40 | | - <span class="glyphicon glyphicon-search"></span></button> |
41 | | - </div> |
42 | | - </div> |
43 | | - </td> |
44 | | - <td width="30%"> |
45 | | - <div id="filter-box-value"> |
46 | | - |
47 | | - @if(filter.getOrElse("")!="") { |
48 | | - Filtering by <b>@filter.get</b> |
49 | | - } |
| 32 | + |
| 33 | + <table width=100%""> |
| 34 | + <td width="30%"> |
| 35 | + <div class="input-group"> |
| 36 | + <!-- TODO: Should the filter value reset when folder level changes? --> |
| 37 | + <input type="text" class="form-horizontal form-control" id="filename-filter" placeholder="Search folder and file names..." |
| 38 | + value="@filter.getOrElse("")" |
| 39 | + onchange="getUpdatedFilesAndFolders()"> |
| 40 | + <div class="input-group-btn"> |
| 41 | + <button class="btn btn-default" onclick="getUpdatedFilesAndFolders()"> |
| 42 | + <span class="glyphicon glyphicon-search"></span></button> |
50 | 43 | </div> |
51 | | - </td> |
52 | | - <td width="30%"> |
53 | | - <label class="sortchoice" for="js-sort-single">Sort By: |
54 | | - <select class="js-sort-single"> |
55 | | - <option value="dateN">Newest</option> |
56 | | - <option value="dateO">Oldest</option> |
57 | | - <option value="titleA">Title (A-Z)</option> |
58 | | - <option value="titleZ">Title (Z-A)</option> |
59 | | - <option value="sizeL">Size (L)</option> |
60 | | - <option value="sizeS">Size (S)</option> |
61 | | - </select> |
62 | | - </td> |
63 | | - </table> |
| 44 | + </div> |
| 45 | + </td> |
| 46 | + <td width="20%"> |
| 47 | + <div id="filter-box-value"> |
| 48 | + |
| 49 | + @if(filter.getOrElse("")!="") { |
| 50 | + Filtering by <b>@filter.get</b> |
| 51 | + } |
| 52 | + </div> |
| 53 | + </td> |
| 54 | + <td width="20%" > |
| 55 | + <div id="selected-count-box"></div> |
| 56 | + </td> |
| 57 | + <td width="30%"> |
| 58 | + <label class="sortchoice" for="js-sort-single">Sort By: |
| 59 | + <select class="js-sort-single"> |
| 60 | + <option value="dateN">Newest</option> |
| 61 | + <option value="dateO">Oldest</option> |
| 62 | + <option value="titleA">Title (A-Z)</option> |
| 63 | + <option value="titleZ">Title (Z-A)</option> |
| 64 | + <option value="sizeL">Size (L)</option> |
| 65 | + <option value="sizeS">Size (S)</option> |
| 66 | + </select> |
| 67 | + </label> |
| 68 | + </td> |
| 69 | + </table> |
64 | 70 |
|
| 71 | + </div> |
| 72 | +} else { |
| 73 | + <!--Still want to show multiselect box even without sorting--> |
| 74 | + <div id="selected-count-box"></div> |
| 75 | +} |
65 | 76 |
|
| 77 | +<script type="text/javascript"> |
| 78 | + function updateSelectedFileCount() { |
| 79 | + var selected = $.cookie('[email protected]'); |
| 80 | + if (selected) { |
| 81 | + var fileUUIDs = selected.split(','); |
| 82 | + //$('#selected-count-box').html('Marked Files (<b>'+fileUUIDs.length+'</b>)') |
| 83 | + $('#selected-count-box').html('<div class="dropdown"><a href="#" class="dropdown-toggle" ' + |
| 84 | + 'data-toggle="dropdown" aria-expanded="false"> Marked Files (<b>'+fileUUIDs.length+'</b>)' + |
| 85 | + '<b class="caret"></b></a><ul class="dropdown-menu"><li>' + |
| 86 | + '<a onclick="deleteSelectedFiles();">Delete All</a></li></ul>' + |
| 87 | + '</div>') |
| 88 | + } else { |
| 89 | + $('#selected-count-box').html('Marked Files (<b>0</b>)') |
| 90 | + } |
| 91 | + } |
66 | 92 |
|
| 93 | + function deleteSelectedFiles() { |
| 94 | + console.log("Are you sure?"); |
| 95 | + confirmDeleteMarked('@dataset.id'); |
| 96 | + } |
67 | 97 |
|
68 | | - </label> |
69 | | - </div> |
70 | | -} |
| 98 | + $(document).ready(function() { |
| 99 | + $('.fileselect').click(function() { |
| 100 | + var file_id = $(this).data("id"); |
| 101 | + |
| 102 | + if ($("a[data-id='" + file_id + "'] span.glyphicon").hasClass('glyphicon-plus')) { |
| 103 | + // SELECT THE FILE |
| 104 | + // TODO: Add Clear All option |
| 105 | + var selected = $.cookie('[email protected]'); |
| 106 | + if (selected) { |
| 107 | + if (selected.indexOf(file_id) == -1) |
| 108 | + selected += ","+file_id; |
| 109 | + } else { |
| 110 | + selected = file_id; |
| 111 | + } |
| 112 | + $.cookie('[email protected]', selected); |
| 113 | + |
| 114 | + $("a[data-id='"+file_id+"'] span.glyphicon").removeClass('glyphicon-plus'); |
| 115 | + $("a[data-id='"+file_id+"'] span.glyphicon").addClass('glyphicon-ok'); |
| 116 | + updateSelectedFileCount(); |
| 117 | + } else { |
| 118 | + // DESELECT THE FILE |
| 119 | + var selected = $.cookie('[email protected]'); |
| 120 | + if (selected && selected.indexOf(file_id) > -1) { |
| 121 | + selected = selected.replace(file_id+',', '').replace(','+file_id, '').replace(file_id, ''); |
| 122 | + $.cookie('[email protected]', selected, {expires: 14}); |
| 123 | + } |
| 124 | + |
| 125 | + $("a[data-id='"+file_id+"'] span.glyphicon").removeClass('glyphicon-ok'); |
| 126 | + $("a[data-id='"+file_id+"'] span.glyphicon").addClass('glyphicon-plus'); |
| 127 | + updateSelectedFileCount(); |
| 128 | + // TODO: plain jquery cookies? logout could still see them. play uses key |
| 129 | + // TODO: show only marked files |
| 130 | + // TODO: Downloading selected files as Zip - look at downloading folders tasks |
| 131 | + // make separate tasks for my SIMPL task for a sprint with more granularity |
| 132 | + |
| 133 | + // TODO: convert selection datasets to a collection |
| 134 | + // TODO: Selections become Favorites |
| 135 | + // TODO: recently viewed list? |
| 136 | + } |
| 137 | + }); |
| 138 | + |
| 139 | + // Check cookie for any selected files in this dataset and update icons + toolbar |
| 140 | + var selected = $.cookie('[email protected]'); |
| 141 | + if (selected) { |
| 142 | + var fileUUIDs = selected.split(','); |
| 143 | + for (idx in fileUUIDs) { |
| 144 | + file_id = fileUUIDs[idx]; |
| 145 | + $("a[data-id='"+file_id+"'] span.glyphicon").removeClass('glyphicon-plus'); |
| 146 | + $("a[data-id='"+file_id+"'] span.glyphicon").addClass('glyphicon-ok'); |
| 147 | + } |
| 148 | + updateSelectedFileCount(); |
| 149 | + } |
| 150 | + }); |
| 151 | +</script> |
71 | 152 |
|
72 | 153 | <!-- Show message when the folder is empty --> |
73 | 154 | <div style="display: none" id="empty-folder-div"><h4> |
|
91 | 172 |
|
92 | 173 | <!-- Files list --> |
93 | 174 | @currentFolder match { |
94 | | - case None => { @files.grid(fileList, fileComments, dataset.id, space, ResourceRef(ResourceRef.dataset, dataset.id), dataset.folders.length > 0) } |
95 | | - case Some(s) => { @files.grid(fileList, fileComments, dataset.id, space, ResourceRef(ResourceRef.folder, UUID(s)), dataset.folders.length > 0)} |
| 175 | + case None => { |
| 176 | + @files.grid(fileList, fileComments, dataset.id, space, ResourceRef(ResourceRef.dataset, dataset.id), |
| 177 | + dataset.folders.length > 0) } |
| 178 | + case Some(s) => { |
| 179 | + @files.grid(fileList, fileComments, dataset.id, space, ResourceRef(ResourceRef.folder, UUID(s)), |
| 180 | + dataset.folders.length > 0) } |
96 | 181 | } |
97 | 182 |
|
98 | 183 | <div class="row"> |
|
0 commit comments