Remember recently used folders in vfs select

This commit is contained in:
Hadi Nategh 2019-01-14 17:43:43 +01:00
parent 4a9b88468a
commit 8b661df737
2 changed files with 40 additions and 0 deletions

View File

@ -1172,6 +1172,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
name: this.options.name, name: this.options.name,
method: this.options.method method: this.options.method
}; };
attrs.recentPaths = this._getRecentPaths();
var callback = _callback || this._buildDialog; var callback = _callback || this._buildDialog;
egw(window).json( egw(window).json(
'EGroupware\\Api\\Etemplate\\Widget\\Vfs::ajax_vfsSelect_content', 'EGroupware\\Api\\Etemplate\\Widget\\Vfs::ajax_vfsSelect_content',
@ -1248,6 +1249,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
files = _value.path+'/'+_value.name; files = _value.path+'/'+_value.name;
break; break;
} }
self._setRecentPaths(_value.path);
self.value = files; self.value = files;
if (self.options.method && self.options.method !== 'download') if (self.options.method && self.options.method !== 'download')
{ {
@ -1306,6 +1308,28 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
}); });
}, },
/**
* Set recent path into sessionStorage
* @param {string} _path
*/
_setRecentPaths: function (_path)
{
var recentPaths = egw.getSessionItem('api', 'vfsRecentPaths') ?
egw.getSessionItem('api', 'vfsRecentPaths').split(',') : [];
if (recentPaths.indexOf(_path) == -1) recentPaths.push(_path);
egw.setSessionItem('api', 'vfsRecentPaths', recentPaths);
},
/**
* Get recent paths from sessionStorage
* @returns {Array} returns an array of recent paths
*/
_getRecentPaths: function ()
{
return egw.getSessionItem('api', 'vfsRecentPaths') ?
egw.getSessionItem('api', 'vfsRecentPaths').split(',') : [];
},
/** /**
* click handler * click handler
* @param {event object} e * @param {event object} e

View File

@ -470,6 +470,22 @@ class Vfs extends File
$favorites = \EGroupware\Api\Framework\Favorites::get_favorites('filemanager'); $favorites = \EGroupware\Api\Framework\Favorites::get_favorites('filemanager');
$n = 0; $n = 0;
$content['dir'] = array(); $content['dir'] = array();
//check for recent paths and add them to the top of favorites list
if (is_array($params['recentPaths']))
{
foreach($params['recentPaths'] as $p)
{
$mime = \EGroupware\Api\Vfs::mime_content_type($p);
$content['dir'][$n] = array(
'name' => $p,
'path' => $p,
'mime' => $mime,
'is_dir' => true
);
++$n;
}
}
foreach($favorites as $favorite) foreach($favorites as $favorite)
{ {
$path = $favorite['state']['path']; $path = $favorite['state']['path'];