[pbs-devel] [PATCH widget-toolkit v1 2/3] fix #4001: FileBrowser: show number of items in a directory as size
Stefan Sterz
s.sterz at proxmox.com
Thu May 5 15:52:49 CEST 2022
Signed-off-by: Stefan Sterz <s.sterz at proxmox.com>
---
src/window/FileBrowser.js | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js
index bb262bc..54967c2 100644
--- a/src/window/FileBrowser.js
+++ b/src/window/FileBrowser.js
@@ -2,6 +2,19 @@ Ext.define('proxmox-file-tree', {
extend: 'Ext.data.Model',
fields: ['filepath', 'text', 'type', 'size',
+ {
+ name: 'sizedisplay',
+ calculate: data => {
+ if (data.size === undefined) {
+ return '';
+ } else if (data.type === 'd') {
+ let fs = data.size === 1 ? gettext('{0} item') : gettext('{0} items');
+ return Ext.String.format(fs, data.size);
+ }
+
+ return Proxmox.Utils.format_size(data.size);
+ },
+ },
{
name: 'mtime',
type: 'date',
@@ -270,10 +283,15 @@ Ext.define("Proxmox.window.FileBrowser", {
},
{
text: gettext('Size'),
- dataIndex: 'size',
- renderer: value => value === undefined ? '' : Proxmox.Utils.format_size(value),
+ dataIndex: 'sizedisplay',
sorter: {
sorterFn: function(a, b) {
+ if (a.data.type === 'd' && b.data.type !== 'd') {
+ return -1;
+ } else if (a.data.type !== 'd' && b.data.type === 'd') {
+ return 1;
+ }
+
let asize = a.data.size || 0;
let bsize = b.data.size || 0;
--
2.30.2
More information about the pbs-devel
mailing list