|
376 | 376 |
|
377 | 377 | this.$el.on('show', this._onResize); |
378 | 378 |
|
| 379 | + this.resizeFileActionMenu = _.debounce(_.bind(this.resizeFileActionMenu, this), 250); |
| 380 | + $(window).resize(this.resizeFileActionMenu); |
| 381 | + |
379 | 382 | // reload files list on share accept |
380 | 383 | $('body').on('OCA.Notification.Action', function(eventObject) { |
381 | 384 | if (eventObject.notification.app === 'files_sharing' && eventObject.action.type === 'POST') { |
|
561 | 564 | case 'tags': |
562 | 565 | this._onClickTagSelected(ev); |
563 | 566 | break; |
| 567 | + case 'cancel': |
| 568 | + this._onClickCancelSelected(ev); |
| 569 | + break; |
564 | 570 | } |
565 | 571 | }, |
566 | 572 | /** |
|
677 | 683 | * @param {boolean} [show=true] whether to open the sidebar if it was closed |
678 | 684 | */ |
679 | 685 | _updateDetailsView: function(fileName, show) { |
| 686 | + this.resizeFileActionMenu(); |
680 | 687 | if (!(OCA.Files && OCA.Files.Sidebar)) { |
681 | 688 | console.error('No sidebar available'); |
682 | 689 | return; |
|
1177 | 1184 | }); |
1178 | 1185 | }, |
1179 | 1186 |
|
| 1187 | + /** |
| 1188 | + * Event handler for when deselecting all selected files |
| 1189 | + */ |
| 1190 | + _onClickCancelSelected: function(ev) { |
| 1191 | + this._selectedFiles = {}; |
| 1192 | + this._selectionSummary.clear(); |
| 1193 | + $('.files-filestable input').prop('checked', false); |
| 1194 | + this.$fileList.find('td.selection > .selectCheckBox:visible').closest('tr').toggleClass('selected', false); |
| 1195 | + this.updateSelectionSummary(); |
| 1196 | + }, |
| 1197 | + |
1180 | 1198 | _onClickDocument: function(ev) { |
1181 | 1199 | if(!$(ev.target).closest('#editor_container').length) { |
1182 | 1200 | this._inputView.setValues([]); |
|
1501 | 1519 | this.fileMultiSelectMenu.render(); |
1502 | 1520 | this.$el.find('.selectedActions .filesSelectMenu').remove(); |
1503 | 1521 | this.$el.find('.selectedActions').append(this.fileMultiSelectMenu.$el); |
| 1522 | + this.fileMultipleSelectionMenu = new OCA.Files.FileMultipleSelectionMenu(this.multiSelectMenuItems.sort(function(a, b) { |
| 1523 | + return a.order - b.order |
| 1524 | + })); |
| 1525 | + this.fileMultipleSelectionMenu.render(); |
| 1526 | + this.$el.find('.selectedActions .filesSelectionMenu').remove(); |
| 1527 | + this.$el.find('.selectedActions').append(this.fileMultipleSelectionMenu.$el); |
1504 | 1528 | }, |
1505 | 1529 |
|
1506 | 1530 | /** |
|
3455 | 3479 | this.$el.find('.column-mtime a>span:first').text(t('files','Modified')); |
3456 | 3480 | this.$el.find('table').removeClass('multiselect'); |
3457 | 3481 | this.$el.find('.selectedActions').addClass('hidden'); |
| 3482 | + this.$el.find('.column-size').removeClass('hidden'); |
| 3483 | + this.$el.find('.column-mtime').removeClass('hidden'); |
| 3484 | + this.$el.find('.column-size-count').addClass('hidden'); |
| 3485 | + this.$el.find('.column-size-open').addClass('hidden'); |
| 3486 | + this.$el.find('#selectedActionLabel').css('display','none'); |
3458 | 3487 | } |
3459 | 3488 | else { |
3460 | 3489 | this.$el.find('.selectedActions').removeClass('hidden'); |
3461 | | - this.$el.find('.column-size a>span:first').text(OC.Util.humanFileSize(summary.totalSize)); |
| 3490 | + this.$el.find('.column-size').addClass('hidden'); |
| 3491 | + this.$el.find('.column-mtime').addClass('hidden'); |
| 3492 | + this.$el.find('.column-size-count').removeClass('hidden'); |
| 3493 | + this.$el.find('.column-size-open').removeClass('hidden'); |
| 3494 | + this.$el.find('#selectedActionsList').removeClass('menu-center'); |
| 3495 | + this.$el.find('.column-size-count').text(OC.Util.humanFileSize(summary.totalSize)); |
| 3496 | + this.fileMultipleSelectionMenu.show(this); |
| 3497 | + this.resizeFileActionMenu(); |
3462 | 3498 |
|
3463 | 3499 | var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs); |
3464 | 3500 | var fileInfo = n('files', '%n file', '%n files', summary.totalFiles); |
|
3498 | 3534 | this.fileMultiSelectMenu.toggleItemVisibility('copyMove', false); |
3499 | 3535 | } |
3500 | 3536 | } |
| 3537 | + |
| 3538 | + if (this.fileMultipleSelectionMenu) { |
| 3539 | + this.fileMultipleSelectionMenu.toggleItemVisibility('download', this.isSelectedDownloadable()); |
| 3540 | + this.fileMultipleSelectionMenu.toggleItemVisibility('delete', this.isSelectedDeletable()); |
| 3541 | + this.fileMultipleSelectionMenu.toggleItemVisibility('copyMove', this.isSelectedCopiable()); |
| 3542 | + if (this.isSelectedCopiable()) { |
| 3543 | + if (this.isSelectedMovable()) { |
| 3544 | + this.fileMultipleSelectionMenu.updateItemText('copyMove', t('files', 'Move or copy')); |
| 3545 | + } else { |
| 3546 | + this.fileMultipleSelectionMenu.updateItemText('copyMove', t('files', 'Copy')); |
| 3547 | + } |
| 3548 | + } else { |
| 3549 | + this.fileMultipleSelectionMenu.toggleItemVisibility('copyMove', false); |
| 3550 | + } |
| 3551 | + } |
| 3552 | + } |
| 3553 | + }, |
| 3554 | + |
| 3555 | + /** |
| 3556 | + * Show or hide file action menu based on the current selection |
| 3557 | + */ |
| 3558 | + resizeFileActionMenu: function() { |
| 3559 | + const appList = this.$el.find('.filesSelectionMenu ul li:not(.hidden-action)'); |
| 3560 | + const appListWidth = 179; |
| 3561 | + const checkWidth = Math.ceil(this.$el.find('.column-selection').outerWidth()); |
| 3562 | + const headerNameWidth = Math.ceil(this.$el.find('.column-name').outerWidth()); |
| 3563 | + const actionWidth = Math.ceil(this.$el.find('#selectedActionLabel').outerWidth()); |
| 3564 | + const allLabelWidth = Math.ceil(this.$el.find('#allLabel').not('#allLabel:hidden').outerWidth()); |
| 3565 | + let headerWidth = Math.ceil(this.$el.find('.files-filestable thead').outerWidth()); |
| 3566 | + |
| 3567 | + if($('#app-sidebar-vue').length>0){ |
| 3568 | + headerWidth = headerWidth - Math.ceil($('#app-sidebar-vue').outerWidth()); |
| 3569 | + } |
| 3570 | + |
| 3571 | + var availableWidth; |
| 3572 | + if(!allLabelWidth){ |
| 3573 | + availableWidth = headerWidth - (checkWidth + headerNameWidth); |
| 3574 | + } |
| 3575 | + else{ |
| 3576 | + availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth); |
| 3577 | + } |
| 3578 | + |
| 3579 | + let appCount = Math.floor((availableWidth / appListWidth)); |
| 3580 | + |
| 3581 | + if(appCount < appList.length) { |
| 3582 | + |
| 3583 | + if(!allLabelWidth){ |
| 3584 | + availableWidth = headerWidth - (checkWidth + headerNameWidth + actionWidth); |
| 3585 | + } |
| 3586 | + else{ |
| 3587 | + availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth + actionWidth); |
| 3588 | + } |
| 3589 | + appCount = Math.floor((availableWidth / appListWidth)); |
| 3590 | + } |
| 3591 | + |
| 3592 | + var summary = this._selectionSummary.summary; |
| 3593 | + if (summary.totalFiles === 0 && summary.totalDirs === 0) { |
| 3594 | + this.$el.find('#selectedActionLabel').css('display','none'); |
| 3595 | + } |
| 3596 | + else{ |
| 3597 | + if(appCount < appList.length) { |
| 3598 | + this.$el.find('#selectedActionLabel').css('display','block'); |
| 3599 | + } |
| 3600 | + else if(appCount == appList.length){ |
| 3601 | + this.$el.find('#selectedActionLabel').css('display','none'); |
| 3602 | + } |
| 3603 | + else if (!isFinite(appCount)) |
| 3604 | + { |
| 3605 | + this.$el.find('#selectedActionLabel').css('display','block'); |
| 3606 | + } |
| 3607 | + else if(appCount > appList.length){ |
| 3608 | + this.$el.find('#selectedActionLabel').css('display','none'); |
| 3609 | + } |
| 3610 | + } |
| 3611 | + |
| 3612 | + for (let k = 0; k < appList.length; k++) { |
| 3613 | + if (k < appCount) { |
| 3614 | + $(appList[k]).removeClass('hidden'); |
| 3615 | + } else { |
| 3616 | + $(appList[k]).addClass('hidden'); |
| 3617 | + } |
3501 | 3618 | } |
3502 | 3619 | }, |
3503 | 3620 |
|
|
0 commit comments