aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-10-04 15:14:15 +0200
committerJan-Christoph Borchardt <hey@jancborchardt.net>2018-10-18 13:44:07 +0200
commitc4cce1413487f5a0e870dd2139a4c624a97981fd (patch)
tree29fbd6c36d3ca8de130f37d9ce8b6ca376347eb0 /apps
parent49fda8ba56860918d2e424ca07c94c08237846d4 (diff)
downloadnextcloud-server-c4cce1413487f5a0e870dd2139a4c624a97981fd.tar.gz
nextcloud-server-c4cce1413487f5a0e870dd2139a4c624a97981fd.zip
Remember toggle and events handler
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/appinfo/routes.php5
-rw-r--r--apps/files/js/filelist.js19
-rw-r--r--apps/files/lib/Controller/ApiController.php12
-rw-r--r--apps/files/list.php3
-rw-r--r--apps/files/templates/list.php6
5 files changed, 39 insertions, 6 deletions
diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php
index 1147bdf9c4f..61bc1d99a5d 100644
--- a/apps/files/appinfo/routes.php
+++ b/apps/files/appinfo/routes.php
@@ -62,6 +62,11 @@ $application->registerRoutes(
'verb' => 'POST'
],
[
+ 'name' => 'API#showGridView',
+ 'url' => '/api/v1/showgridview',
+ 'verb' => 'POST'
+ ],
+ [
'name' => 'view#index',
'url' => '/',
'verb' => 'GET',
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 441b8f0a12f..357b1b06016 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -328,7 +328,8 @@
this.$el.find('thead th .columntitle').click(_.bind(this._onClickHeader, this));
// Toggle for grid view
- $('#view-toggle').on('click', this._onGridToggle);
+ this.$showGridView = $('input#showgridview');
+ this.$showGridView.on('change', _.bind(this._onGridviewChange, this));
this._onResize = _.debounce(_.bind(this._onResize, this), 250);
$('#app-content').on('appresized', this._onResize);
@@ -591,10 +592,20 @@
},
/**
- * Event handler for grid view toggle
+ * Toggle showing gridview by default or not
+ *
+ * @returns {undefined}
*/
- _onGridToggle: function() {
- $('.list-container').toggleClass('view-grid');
+ _onGridviewChange: function() {
+ var show = this.$showGridView.is(':checked');
+ $.post(OC.generateUrl('/apps/files/api/v1/showgridview'), {
+ show: show
+ });
+ this.$showGridView.next('#view-toggle')
+ .removeClass('icon-toggle-filelist icon-toggle-pictures')
+ .addClass(show ? 'icon-toggle-filelist' : 'icon-toggle-pictures')
+
+ $('.list-container').toggleClass('view-grid', show);
},
/**
diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php
index 9443b9776ae..3c1eb6e43fb 100644
--- a/apps/files/lib/Controller/ApiController.php
+++ b/apps/files/lib/Controller/ApiController.php
@@ -268,6 +268,18 @@ class ApiController extends Controller {
}
/**
+ * Toggle default for files grid view
+ *
+ * @NoAdminRequired
+ *
+ * @param bool $show
+ */
+ public function showGridView($show) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_grid', (int)$show);
+ return new Response();
+ }
+
+ /**
* Toggle default for showing/hiding xxx folder
*
* @NoAdminRequired
diff --git a/apps/files/list.php b/apps/files/list.php
index 93044d4c587..3b54d5ed242 100644
--- a/apps/files/list.php
+++ b/apps/files/list.php
@@ -22,11 +22,14 @@
*/
$config = \OC::$server->getConfig();
+$userSession = \OC::$server->getUserSession();
// TODO: move this to the generated config.js
$publicUploadEnabled = $config->getAppValue('core', 'shareapi_allow_public_upload', 'yes');
+$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', false);
// renders the controls and table headers template
$tmpl = new OCP\Template('files', 'list', '');
$tmpl->assign('publicUploadEnabled', $publicUploadEnabled);
+$tmpl->assign('showgridview', $showgridview);
$tmpl->printPage();
diff --git a/apps/files/templates/list.php b/apps/files/templates/list.php
index c77cbb4d7c1..0c92cf8a1d4 100644
--- a/apps/files/templates/list.php
+++ b/apps/files/templates/list.php
@@ -24,7 +24,9 @@
<?php endif;?>
<input type="hidden" class="max_human_file_size"
value="(max <?php isset($_['uploadMaxHumanFilesize']) ? p($_['uploadMaxHumanFilesize']) : ''; ?>)">
- <button id="view-toggle" class="button view-toggle icon-toggle-pictures has-tooltip" title="<?php p($l->t('Toggle grid view'))?>"></button>
+ <input type="checkbox" class="hidden" id="showgridview"
+ <?php if($_['showgridview']) { ?>checked="checked" <?php } ?>/>
+ <label id="view-toggle" for="showgridview" class="button view-toggle <?php p($_['showgridview'] ? 'icon-toggle-filelist' : 'icon-toggle-pictures') ?> has-tooltip" title="<?php p($l->t('Toggle grid view'))?>"></label>
</div>
<div id="emptycontent" class="hidden">
@@ -39,7 +41,7 @@
<p></p>
</div>
-<table id="filestable" class="list-container view-grid" data-allow-public-upload="<?php p($_['publicUploadEnabled'])?>" data-preview-x="250" data-preview-y="250">
+<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">
<thead>
<tr>
<th id="headerSelection" class="hidden column-selection">