From 5b762102185e0fd98639ae4d989e36f510209b46 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 12 Oct 2017 17:45:46 +0200 Subject: [PATCH] W.I.P vfsSelect Widget: - Fix mime types not being shown - Fix name being displayed encoded in save2vfs mail --- api/js/etemplate/vfsSelectUI.js | 2 +- api/src/Etemplate/Widget/Vfs.php | 38 +++++++++++++++------------ api/templates/default/vfsSelectUI.xet | 14 ++++------ mail/js/app.js | 4 +-- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/api/js/etemplate/vfsSelectUI.js b/api/js/etemplate/vfsSelectUI.js index 4537597f04..0297cf2862 100644 --- a/api/js/etemplate/vfsSelectUI.js +++ b/api/js/etemplate/vfsSelectUI.js @@ -280,6 +280,7 @@ app.classes.vfsSelectUI = (function(){ "use strict"; return AppJS.extend( case 'path': field = 'path'; value = widget.getValue(); break; case 'home': field = 'action'; value = 'home'; break; case 'app': field = 'app'; value = widget.getValue(); break; + case 'mime': field = 'mime'; value = widget.getValue(); break; } this.submit(field, value); }, @@ -295,7 +296,6 @@ app.classes.vfsSelectUI = (function(){ "use strict"; return AppJS.extend( { var arrMgrs = this.et2.getArrayMgrs(); arrMgrs.content.data[_field] = _val; - if (_field == 'dir') arrMgrs.content.data['button'] = 'ok'; jQuery.extend(arrMgrs.content.data, arrMgrs.modifications.data); this.et2.setArrayMgrs(arrMgrs); this.vfsSelectWidget._content(arrMgrs.content.data, _callback); diff --git a/api/src/Etemplate/Widget/Vfs.php b/api/src/Etemplate/Widget/Vfs.php index 0f0b430e4b..4e46d67f9c 100644 --- a/api/src/Etemplate/Widget/Vfs.php +++ b/api/src/Etemplate/Widget/Vfs.php @@ -392,32 +392,37 @@ class Vfs extends File { $response = Json\Response::get(); $readonlys = $sel_options = array(); + + if (isset($params['mime'])) + { + foreach((array)$params['mime'] as $key => $value) + { + if (is_numeric($key)) + { + $sel_options['mime'][$value] = lang('%1 files',strtoupper(Api\MimeMagic::mime2ext($value))).' ('.$value.')'; + } + else + { + $sel_options['mime'][$key] = lang('%1 files',strtoupper($value)).' ('.$key.')'; + } + } + } + if (!is_array($content)) { $content = array_merge($params, array( 'name' => (string)$params['name'], 'path' => empty($params['path']) ? - Api\Cache::getSession('filemanger', 'select_path'): $params['path'], + Api\Cache::getSession('filemanger', 'select_path'): $params['path'] )); - + unset($content['mime']); if (!in_array($content['mode'],array('open','open-multiple','saveas','select-dir'))) { throw new Api\Exception\WrongParameter("Wrong or unset required mode parameter!"); } - if (isset($content['options-mime'])) + if (isset($params['mime'])) { - $sel_options['mime'] = array(); - foreach((array)$params['mime'] as $key => $value) - { - if (is_numeric($key)) - { - $sel_options['mime'][$value] = lang('%1 files',strtoupper(Api\MimeMagic::mime2ext($value))).' ('.$value.')'; - } - else - { - $sel_options['mime'][$key] = lang('%1 files',strtoupper($value)).' ('.$key.')'; - } - } + $content['showmime'] = true; list($content['mime']) = each($sel_options['mime']); } } @@ -528,8 +533,7 @@ class Vfs extends File 'method' => $content['method'], 'id' => $content['id'], 'label' => $content['label'], - 'mime' => $content['mime'], - 'options-mime' => $sel_options['mime'], + 'showmime' => $content['showmime'], 'old_path' => $content['path'], 'old_app' => $content['app'] ) diff --git a/api/templates/default/vfsSelectUI.xet b/api/templates/default/vfsSelectUI.xet index e46f00bf8c..b4c8161186 100644 --- a/api/templates/default/vfsSelectUI.xet +++ b/api/templates/default/vfsSelectUI.xet @@ -5,13 +5,11 @@