forked from extern/egroupware
Remember recently used folders in vfs select
This commit is contained in:
parent
4a9b88468a
commit
8b661df737
@ -1172,6 +1172,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
|
||||
name: this.options.name,
|
||||
method: this.options.method
|
||||
};
|
||||
attrs.recentPaths = this._getRecentPaths();
|
||||
var callback = _callback || this._buildDialog;
|
||||
egw(window).json(
|
||||
'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;
|
||||
break;
|
||||
}
|
||||
self._setRecentPaths(_value.path);
|
||||
self.value = files;
|
||||
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
|
||||
* @param {event object} e
|
||||
|
@ -470,6 +470,22 @@ class Vfs extends File
|
||||
$favorites = \EGroupware\Api\Framework\Favorites::get_favorites('filemanager');
|
||||
$n = 0;
|
||||
$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)
|
||||
{
|
||||
$path = $favorite['state']['path'];
|
||||
|
Loading…
Reference in New Issue
Block a user