Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

127-file multiselection action #208

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 111 additions & 1 deletion apps/files/css/files.scss
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ table th .columntitle.name {

table.multiselect th .columntitle.name {
margin-left: 0;
padding-left: 15px;
}

table th .sort-indicator {
Expand Down Expand Up @@ -340,7 +341,7 @@ table.multiselect thead th {

table.multiselect .column-name {
position: relative;
width: 9999px; /* when we use 100%, the styling breaks on mobile … table styling */
width: auto;
}
table.multiselect .column-mtime>a {
display: none;
Expand Down Expand Up @@ -1323,3 +1324,112 @@ table.dragshadow td.size {
margin: 0 12px;
}
}

/* Actions for selected files */
#headerSize .hidden {
display: none;
}

#headerDate .hidden {
display: none;
}

#headerSizeOpen .hidden {
display: none;
}

table.multiselect {
thead {
#selectedMenu {
width: 100%;
}
}
}

.multiselect {
.sort-indicator {
display: none !important;
}
}

#selectedActionLabel {
padding-right: 16px;
display: none;
a {
display: inline;
line-height: 50px;
padding: 16px 5px;
img {
position: relative;
vertical-align: text-bottom;
margin-bottom: -1px;
}
}
a.hidden {
display: none;
}
.actions-selected {
.icon-more {
display: inline-block;
vertical-align: middle;
}
}
}

#headerSizeCount .hidden {
display: none !important;
}

.selectedActions {
.filesSelectionMenu {
display: block !important;
ul {
li {
display: inline;
&.hidden {
display: none !important;
}
}
}
a {
.label {
padding-left: 8px;
padding-right: 19px;
}
&:hover {
.label {
text-decoration: underline;
}
}
}
}
}

#selectedActionsList {
width: 100% !important;
text-align: right !important;
opacity: unset;
.popovermenu {
right: -70px;
top: 45px;
}
}

#allLabel {
padding-top: 5px;
}

.item-cancel {
a {
.label {
color: #ff0000;
}
}
.icon-close {
filter: invert(18%) sepia(99%) saturate(7440%) hue-rotate(1deg) brightness(110%) contrast(115%);
}
}

.hidden-action{
display: none !important;
}
33 changes: 33 additions & 0 deletions apps/files/css/mobile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,37 @@ table.dragshadow {
table.multiselect th .columntitle.name {
margin-left: 0;
}

/* Actions for selected files */
table th #selectedActionLabel a {
padding: 17px 14px;
}

#allLabel {
display: none;
}

#selectedActionsList .filesSelectionMenu {
display: none !important;
}

#selectedActionsList .popovermenu {
right: -70px;
top: 25px;
}

#selectedActionLabel {
padding-right: 0px;
}

table th .columntitle.name {
margin-left: 0;
}
}

@media only screen and (max-width: 440px) {
#selectedActionsList .popovermenu {
right: -85px;
top: 20px;
}
}
6 changes: 6 additions & 0 deletions apps/files/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
iconClass: 'icon-tag',
order: 100,
},
{
name: 'cancel',
displayName: t('files', 'Cancel'),
iconClass: 'icon-close',
order: 101,
},
],
sorting: {
mode: $('#defaultFileSorting').val() === 'basename'
Expand Down
121 changes: 119 additions & 2 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@

this.$el.on('show', this._onResize);

this.resizeFileActionMenu = _.debounce(_.bind(this.resizeFileActionMenu, this), 250);
$(window).resize(this.resizeFileActionMenu);

// reload files list on share accept
$('body').on('OCA.Notification.Action', function(eventObject) {
if (eventObject.notification.app === 'files_sharing' && eventObject.action.type === 'POST') {
Expand Down Expand Up @@ -561,6 +564,9 @@
case 'tags':
this._onClickTagSelected(ev);
break;
case 'cancel':
this._onClickCancelSelected(ev);
break;
}
},
/**
Expand Down Expand Up @@ -677,6 +683,7 @@
* @param {boolean} [show=true] whether to open the sidebar if it was closed
*/
_updateDetailsView: function(fileName, show) {
this.resizeFileActionMenu();
if (!(OCA.Files && OCA.Files.Sidebar)) {
console.error('No sidebar available');
return;
Expand Down Expand Up @@ -1177,6 +1184,17 @@
});
},

/**
* Event handler for when deselecting all selected files
*/
_onClickCancelSelected: function(ev) {
this._selectedFiles = {};
this._selectionSummary.clear();
$('#filestable input').prop('checked', false);
this.$fileList.find('td.selection > .selectCheckBox:visible').closest('tr').toggleClass('selected', false);
this.updateSelectionSummary();
},

_onClickDocument: function(ev) {
if(!$(ev.target).closest('#editor_container').length) {
this._inputView.setValues([]);
Expand Down Expand Up @@ -1501,6 +1519,12 @@
this.fileMultiSelectMenu.render();
this.$el.find('.selectedActions .filesSelectMenu').remove();
this.$el.find('.selectedActions').append(this.fileMultiSelectMenu.$el);
this.fileMultipleSelectionMenu = new OCA.Files.FileMultipleSelectionMenu(this.multiSelectMenuItems.sort(function(a, b) {
return a.order - b.order
}));
this.fileMultipleSelectionMenu.render();
this.$el.find('.selectedActions .filesSelectionMenu').remove();
this.$el.find('.selectedActions').append(this.fileMultipleSelectionMenu.$el);
},

/**
Expand Down Expand Up @@ -3444,7 +3468,7 @@
/**
* Update UI based on the current selection
*/
updateSelectionSummary: function() {
updateSelectionSummary: function() {
var summary = this._selectionSummary.summary;
var selection;

Expand All @@ -3455,10 +3479,22 @@
this.$el.find('.column-mtime a>span:first').text(t('files','Modified'));
this.$el.find('table').removeClass('multiselect');
this.$el.find('.selectedActions').addClass('hidden');
this.$el.find('#headerSize').removeClass('hidden');
this.$el.find('#headerDate').removeClass('hidden');
this.$el.find('#headerSizeCount').addClass('hidden');
this.$el.find('.headerSizeOpen').addClass('hidden');
this.$el.find('#selectedActionLabel').css('display','none');
}
else {
this.$el.find('.selectedActions').removeClass('hidden');
this.$el.find('.column-size a>span:first').text(OC.Util.humanFileSize(summary.totalSize));
this.$el.find('#headerSize').addClass('hidden');
this.$el.find('#headerDate').addClass('hidden');
this.$el.find('#headerSizeCount').removeClass('hidden');
this.$el.find('.headerSizeOpen').removeClass('hidden');
this.$el.find('#selectedActionsList').removeClass('menu-center');
this.$el.find('#headerSizeCount').text(OC.Util.humanFileSize(summary.totalSize));
this.fileMultipleSelectionMenu.show(this);
this.resizeFileActionMenu();

var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs);
var fileInfo = n('files', '%n file', '%n files', summary.totalFiles);
Expand Down Expand Up @@ -3498,6 +3534,87 @@
this.fileMultiSelectMenu.toggleItemVisibility('copyMove', false);
}
}

if (this.fileMultipleSelectionMenu) {
this.fileMultipleSelectionMenu.toggleItemVisibility('download', this.isSelectedDownloadable());
this.fileMultipleSelectionMenu.toggleItemVisibility('delete', this.isSelectedDeletable());
this.fileMultipleSelectionMenu.toggleItemVisibility('copyMove', this.isSelectedCopiable());
if (this.isSelectedCopiable()) {
if (this.isSelectedMovable()) {
this.fileMultipleSelectionMenu.updateItemText('copyMove', t('files', 'Move or copy'));
} else {
this.fileMultipleSelectionMenu.updateItemText('copyMove', t('files', 'Copy'));
}
} else {
this.fileMultipleSelectionMenu.toggleItemVisibility('copyMove', false);
}
}
}
},

/**
* Show or hide file action menu based on the current selection
*/
resizeFileActionMenu: function() {
const appList = this.$el.find('.filesSelectionMenu ul li:not(.hidden-action)');
const appListWidth = 179;
const checkWidth = Math.ceil(this.$el.find('#headerSelection').outerWidth());
const headerNameWidth = Math.ceil(this.$el.find('#headerName').outerWidth());
const actionWidth = Math.ceil(this.$el.find('#selectedActionLabel').outerWidth());
const allLabelWidth = Math.ceil(this.$el.find('#allLabel').not('#allLabel:hidden').outerWidth());
let headerWidth = Math.ceil(this.$el.find('#filestable thead').outerWidth());

if($('#app-sidebar-vue').length>0){
headerWidth = headerWidth - Math.ceil($('#app-sidebar-vue').outerWidth());
}

var availableWidth;
if(!allLabelWidth){
availableWidth = headerWidth - (checkWidth + headerNameWidth);
}
else{
availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth);
}

let appCount = Math.floor((availableWidth / appListWidth));

if(appCount < appList.length) {

if(!allLabelWidth){
availableWidth = headerWidth - (checkWidth + headerNameWidth + actionWidth);
}
else{
availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth + actionWidth);
}
appCount = Math.floor((availableWidth / appListWidth));
}

var summary = this._selectionSummary.summary;
if (summary.totalFiles === 0 && summary.totalDirs === 0) {
this.$el.find('#selectedActionLabel').css('display','none');
}
else{
if(appCount < appList.length) {
this.$el.find('#selectedActionLabel').css('display','block');
}
else if(appCount == appList.length){
this.$el.find('#selectedActionLabel').css('display','none');
}
else if (!isFinite(appCount))
{
this.$el.find('#selectedActionLabel').css('display','block');
}
else if(appCount > appList.length){
this.$el.find('#selectedActionLabel').css('display','none');
}
}

for (let k = 0; k < appList.length; k++) {
if (k < appCount) {
$(appList[k]).removeClass('hidden');
} else {
$(appList[k]).addClass('hidden');
}
}
},

Expand Down
Loading