Skip to content

Commit 5682d30

Browse files
committed
Add grid toggle for every files view
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent 54a30a4 commit 5682d30

File tree

19 files changed

+78
-17
lines changed

19 files changed

+78
-17
lines changed

apps/files/css/files.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
position: relative;
5656
width: 100%;
5757
min-width: 250px;
58+
// hide table if emptycontent is not hidden
59+
#emptycontent:not(.hidden) ~ & {
60+
display: none;
61+
}
5862
}
5963

6064
/* fit app list view heights */
@@ -982,6 +986,9 @@ table.dragshadow td.size {
982986
margin: 0;
983987
padding: 22px;
984988
opacity: .5;
989+
position: fixed;
990+
right: 0;
991+
z-index: 100;
985992

986993
&:hover,
987994
&:focus,

apps/files/js/filelist.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,10 @@
331331

332332
this.$el.find('thead th .columntitle').click(_.bind(this._onClickHeader, this));
333333

334-
// Toggle for grid view
335-
this.$showGridView = $('input#showgridview');
334+
// Toggle for grid view, only register once
335+
this.$showGridView = $('input#showgridview:not(.registered)');
336336
this.$showGridView.on('change', _.bind(this._onGridviewChange, this));
337+
this.$showGridView.addClass('registered');
337338
$('#view-toggle').tooltip({placement: 'bottom', trigger: 'hover'});
338339

339340
this._onResize = _.debounce(_.bind(this._onResize, this), 250);

apps/files/lib/Controller/ViewController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
257257
$params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
258258
$params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
259259
$params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
260+
$params['showgridview'] = $this->config->getUserValue($user, 'files', 'show_grid', true);
261+
$params['isIE'] = \OCP\Util::isIE();
260262
$showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
261263
$params['showHiddenFiles'] = $showHidden ? 1 : 0;
262264
$params['fileNotFound'] = $fileNotFound ? 1 : 0;

apps/files/list.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525
$userSession = \OC::$server->getUserSession();
2626
// TODO: move this to the generated config.js
2727
$publicUploadEnabled = $config->getAppValue('core', 'shareapi_allow_public_upload', 'yes');
28+
2829
$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', true);
2930
$isIE = \OCP\Util::isIE();
3031

3132
// renders the controls and table headers template
3233
$tmpl = new OCP\Template('files', 'list', '');
33-
$tmpl->assign('publicUploadEnabled', $publicUploadEnabled);
34+
3435
// gridview not available for ie
3536
$tmpl->assign('showgridview', $showgridview && !$isIE);
36-
$tmpl->assign('isIE', $isIE);
37+
$tmpl->assign('publicUploadEnabled', $publicUploadEnabled);
3738
$tmpl->printPage();
3839

apps/files/recentlist.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@
2323
*/
2424
// Check if we are a user
2525
OCP\User::checkLoggedIn();
26+
$config = \OC::$server->getConfig();
27+
$userSession = \OC::$server->getUserSession();
28+
29+
$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', true);
30+
$isIE = \OCP\Util::isIE();
2631

2732
$tmpl = new OCP\Template('files', 'recentlist', '');
2833

34+
// gridview not available for ie
35+
$tmpl->assign('showgridview', $showgridview && !$isIE);
36+
2937
$tmpl->printPage();

apps/files/simplelist.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@
2222
*/
2323

2424
// TODO: move to handlebars
25+
$config = \OC::$server->getConfig();
26+
$userSession = \OC::$server->getUserSession();
27+
28+
$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', true);
29+
$isIE = \OCP\Util::isIE();
2530

2631
// renders the controls and table headers template
2732
$tmpl = new OCP\Template('files', 'simplelist', '');
33+
34+
// gridview not available for ie
35+
$tmpl->assign('showgridview', $showgridview && !$isIE);
2836
$tmpl->printPage();
2937

apps/files/templates/index.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php /** @var $l \OCP\IL10N */ ?>
22
<?php $_['appNavigation']->printPage(); ?>
33
<div id="app-content">
4+
5+
<?php if (!$_['isIE']) { ?>
6+
<input type="checkbox" class="hidden-visually" id="showgridview"
7+
<?php if($_['showgridview']) { ?>checked="checked" <?php } ?>/>
8+
<label id="view-toggle" for="showgridview" class="button <?php p($_['showgridview'] ? 'icon-toggle-filelist' : 'icon-toggle-pictures') ?>"
9+
title="<?php p($l->t('Toggle grid view'))?>"></label>
10+
<?php } ?>
11+
412
<?php foreach ($_['appContents'] as $content) { ?>
513
<div id="app-content-<?php p($content['id']) ?>" class="hidden viewcontainer">
614
<?php print_unescaped($content['content']) ?>

apps/files/templates/list.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424
<?php endif;?>
2525
<input type="hidden" class="max_human_file_size"
2626
value="(max <?php isset($_['uploadMaxHumanFilesize']) ? p($_['uploadMaxHumanFilesize']) : ''; ?>)">
27-
<!-- IF NOT IE, SHOW GRIDVIEW -->
28-
<?php if (!$_['isIE']) { ?>
29-
<input type="checkbox" class="hidden-visually" id="showgridview"
30-
<?php if($_['showgridview']) { ?>checked="checked" <?php } ?>/>
31-
<label id="view-toggle" for="showgridview" class="button <?php p($_['showgridview'] ? 'icon-toggle-filelist' : 'icon-toggle-pictures') ?>"
32-
title="<?php p($l->t('Toggle grid view'))?>"></label>
33-
<?php } ?>
3427
</div>
3528

3629
<div id="emptycontent" class="hidden">
@@ -44,7 +37,6 @@
4437
<h2><?php p($l->t('No entries found in this folder')); ?></h2>
4538
<p></p>
4639
</div>
47-
4840
<table id="filestable" class="list-container <?php p($_['showgridview'] ? 'view-grid' : '') ?>" data-allow-public-upload="<?php p($_['publicUploadEnabled'])?>" data-preview-x="250" data-preview-y="250">
4941
<thead>
5042
<tr>

apps/files/templates/recentlist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<p></p>
1212
</div>
1313

14-
<table id="filestable" class="list-container view-grid">
14+
<table id="filestable" class="list-container <?php p($_['showgridview'] ? 'view-grid' : '') ?>">
1515
<thead>
1616
<tr>
1717
<th id='headerName' class="hidden column-name">

apps/files/templates/simplelist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<h2><?php p($l->t('No entries found in this folder')); ?></h2>
1414
<p></p>
1515
</div>
16-
<table id="filestable" class="list-container view-grid">
16+
<table id="filestable" class="list-container <?php p($_['showgridview'] ? 'view-grid' : '') ?>">
1717
<thead>
1818
<tr>
1919
<th id='headerName' class="hidden column-name">

0 commit comments

Comments
 (0)