From 0f9da691854d3fba6cd76765600706f53e9ef77f Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 12 Sep 2017 10:32:40 +0200 Subject: [PATCH] Show if a pad has been renamed in the drive --- www/drive/file.less | 16 +++++++++++++++- www/drive/main.js | 28 +++++++++++++++++++++------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/www/drive/file.less b/www/drive/file.less index 46aadaf77..42019501f 100644 --- a/www/drive/file.less +++ b/www/drive/file.less @@ -495,6 +495,15 @@ span { width: 100%; margin-top: 5px; } + .state { + position: absolute; + top: 3px; + right: 3px; + .fa { + margin:0; + font-size: 18px; + } + } } .listElement { display: none; @@ -566,7 +575,12 @@ span { overflow: hidden; white-space: nowrap; box-sizing: border-box; - &.icon { + &.state { + .fa:not(:last-child) { + margin-right: 5px; + } + } + &.icon, &.state { width: 30px; } &.type, &.atime, &.ctime { diff --git a/www/drive/main.js b/www/drive/main.js index 22ae766a4..f415ad49e 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -176,6 +176,8 @@ define([ var $backupIcon = $('', {"class": "fa fa-life-ring"}); var $searchIcon = $('', {"class": "fa fa-search searchIcon"}); var $addIcon = $('', {"class": "fa fa-plus"}); + var $renamedIcon = $('', {"class": "fa fa-flag"}); + var $readonlyIcon = $('', {"class": "fa fa-eye"}); var history = { isHistoryMode: false, @@ -1119,19 +1121,27 @@ define([ var data = filesOp.getFileData(element); if (!data) { return void logError("No data for the file", element); } + var hrefData = Cryptpad.parsePadUrl(data.href); + var $state = $('', {'class': 'state'}); + if (hrefData.hashData && hrefData.hashData.mode === 'view') { + var $ro = $readonlyIcon.clone().appendTo($state); + $ro.attr('title', Messages.readonly); + } + if (data.filename && data.filename !== data.title) { + var $renamed = $renamedIcon.clone().appendTo($state); + $renamed.attr('title', "TODO: you've set a custom name for this pad. Its shared title is:\n{0}"); + } + var name = filesOp.getTitle(element); // The element with the class '.name' is underlined when the 'li' is hovered var $name = $('', {'class': 'name'}).text(name); $span.html(''); $span.append($name); + $span.append($state); - var hrefData = Cryptpad.parsePadUrl(data.href); var type = Messages.type[hrefData.type] || hrefData.type; var $type = $('', {'class': 'type listElement'}).text(type); - if (hrefData.hashData && hrefData.hashData.mode === 'view') { - $type.append(' (' + Messages.readonly+ ')'); - } var $adate = $('', {'class': 'atime listElement'}).text(getDate(data.atime)); var $cdate = $('', {'class': 'ctime listElement'}).text(getDate(data.ctime)); $span.append($type); @@ -1147,9 +1157,10 @@ define([ var sf = filesOp.hasSubfolder(element); var files = filesOp.hasFile(element); var $name = $('', {'class': 'name'}).text(key); + var $state = $('', {'class': 'state'}); var $subfolders = $('', {'class': 'folders listElement'}).text(sf); var $files = $('', {'class': 'files listElement'}).text(files); - $span.append($name).append($subfolders).append($files); + $span.append($name).append($state).append($subfolders).append($files); }; // This is duplicated in cryptpad-common, it should be unified @@ -1542,9 +1553,11 @@ define([ //var $fohElement = $('', {'class': 'element'}).appendTo($folderHeader); var $fhIcon = $('', {'class': 'icon'}); var $name = $('', {'class': 'name foldername clickable'}).text(Messages.fm_folderName).click(onSortByClick); + var $state = $('', {'class': 'state'}); var $subfolders = $('', {'class': 'folders listElement'}).text(Messages.fm_numberOfFolders); var $files = $('', {'class': 'files listElement'}).text(Messages.fm_numberOfFiles); - $fohElement.append($fhIcon).append($name).append($subfolders).append($files); + $fohElement.append($fhIcon).append($name).append($state) + .append($subfolders).append($files); addFolderSortIcon($fohElement); return $fohElement; }; @@ -1566,11 +1579,12 @@ define([ //var $fihElement = $('', {'class': 'element'}).appendTo($fileHeader); var $fhIcon = $('', {'class': 'icon'}); var $fhName = $('', {'class': 'name filename clickable'}).text(Messages.fm_fileName).click(onSortByClick); + var $fhState = $('', {'class': 'state'}); var $fhType = $('', {'class': 'type clickable'}).text(Messages.fm_type).click(onSortByClick); var $fhAdate = $('', {'class': 'atime clickable'}).text(Messages.fm_lastAccess).click(onSortByClick); var $fhCdate = $('', {'class': 'ctime clickable'}).text(Messages.fm_creation).click(onSortByClick); // If displayTitle is false, it means the "name" is the title, so do not display the "name" header - $fihElement.append($fhIcon).append($fhName).append($fhType); + $fihElement.append($fhIcon).append($fhName).append($fhState).append($fhType); if (!isWorkgroup()) { $fihElement.append($fhAdate).append($fhCdate); }