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

NMC-127 - File action button behaviour for different viewport #28834

Closed
wants to merge 11 commits into from
99 changes: 91 additions & 8 deletions apps/files/css/files.scss
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ table th .columntitle.name {

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

table th .sort-indicator {
Expand Down Expand Up @@ -311,9 +312,9 @@ table th.column-last, table td.column-last {
top: 94px;
}

#app-content-recent,
#app-content-favorites,
#app-content-shareoverview,
#app-content-recent,
#app-content-favorites,
#app-content-shareoverview,
#app-content-sharingout,
#app-content-sharingin,
#app-content-sharinglinks,
Expand All @@ -333,7 +334,7 @@ table.multiselect thead th {

table.multiselect #headerName {
position: relative;
width: 9999px; /* when we use 100%, the styling breaks on mobile … table styling */
width: auto;
}
table.multiselect #modified {
display: none;
Expand Down Expand Up @@ -721,7 +722,7 @@ a.action > img {
.summary {
color: var(--color-text-maxcontrast);
/* add whitespace to bottom of files list to correctly show dropdowns */
$action-menu-items-count: 7; // list view has currently max 7 items in its action menu
$action-menu-items-count: 7; // list view has currently max 7 items in its action menu
height: 44px * ($action-menu-items-count + 0.5); // 0.5 is added to show some whitespace below
}
#filestable .filesummary {
Expand Down Expand Up @@ -859,7 +860,7 @@ table.dragshadow td.size {
overflow: auto;
min-width: 160px;
height: 54px;

&:not(.hidden) {
display: flex;
}
Expand Down Expand Up @@ -911,11 +912,9 @@ table.dragshadow td.size {
/* HEADER and MULTISELECT */
thead {
tr {
display: block;
border-bottom: 1px solid var(--color-border);
background-color: var(--color-main-background-translucent);
th {
width: auto;
border: none;
}
}
Expand Down Expand Up @@ -1238,3 +1237,87 @@ table.dragshadow td.size {
}
}

/* 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;
}
}
}
}

#selectedActionsList {
width: 100% !important;
text-align: right !important;
opacity: unset;
.popovermenu {
right: -70px;
top: 45px;
}
}
29 changes: 29 additions & 0 deletions apps/files/css/mobile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,33 @@ 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;
}
}

@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 @@ -119,6 +119,12 @@
iconClass: 'icon-tag',
order: 100,
},
{
name: 'cancel',
displayName: 'Cancel',
iconClass: 'icon-close',
order: 101,
},
],
sorting: {
mode: $('#defaultFileSorting').val(),
Expand Down
69 changes: 68 additions & 1 deletion apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@

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

$('#selectedActionLabel').css('display','none');
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 @@ -558,6 +562,9 @@
case 'tags':
this._onClickTagSelected(ev);
break;
case 'cancel':
this._onClickCancelSelected(ev);
break;
}
},
/**
Expand Down Expand Up @@ -1191,6 +1198,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 @@ -1511,6 +1529,11 @@
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').append(this.fileMultipleSelectionMenu.$el);
},

/**
Expand Down Expand Up @@ -3431,10 +3454,25 @@
this.$el.find('#modified 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');
$('#selectedActionLabel').css('display','none');
}
else {
this.$el.find('.selectedActions').removeClass('hidden');
this.$el.find('#headerSize 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');
if (window.matchMedia('(max-width: 480px)').matches) {
$('#selectedActionLabel').css('display','block');
}
this.resizeFileActionMenu();
this.$el.find('#headerSizeCount').text(OC.Util.humanFileSize(summary.totalSize));
this.fileMultipleSelectionMenu.show(this);

var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs);
var fileInfo = n('files', '%n file', '%n files', summary.totalFiles);
Expand Down Expand Up @@ -3477,6 +3515,35 @@
}
},

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

let availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth);
let appCount = Math.floor((availableWidth / $(appList).width()));

if(appCount < appList.length) {
$('#selectedActionLabel').css('display','block');
availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth + actionWidth);
appCount = Math.floor((availableWidth / $(appList).width()));
}

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

/**
* Check whether all selected files are copiable
*/
Expand Down
Loading