From 11f9196b426681dd0cc4f23cbf23a8dc9ca5a2d4 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 26 Feb 2024 14:26:14 -0700 Subject: [PATCH] Use new VFS Select in customfield type application-filemanager --- api/js/etemplate/Et2Vfs/Et2VfsSelectDialog.ts | 4 ++-- api/js/etemplate/et2_extension_customfields.ts | 11 ++++++----- api/src/Etemplate/Widget/Vfs.php | 7 +++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/api/js/etemplate/Et2Vfs/Et2VfsSelectDialog.ts b/api/js/etemplate/Et2Vfs/Et2VfsSelectDialog.ts index a8d6f21ae7..894287fdbb 100644 --- a/api/js/etemplate/Et2Vfs/Et2VfsSelectDialog.ts +++ b/api/js/etemplate/Et2Vfs/Et2VfsSelectDialog.ts @@ -304,7 +304,7 @@ export class Et2VfsSelectDialog // Set current file to first value if(this.value && this.value[0]) { - this.setCurrentFile(this._fileNodes.find(node => node.value.path == this.value[0])); + this.setCurrentResult(this._fileNodes.find(node => node.value.path == this.value[0])); } }); } @@ -487,7 +487,7 @@ export class Et2VfsSelectDialog } // Update selection, value, and display label - this.selectionChanged(); + this.searchResultSelected(); } /** diff --git a/api/js/etemplate/et2_extension_customfields.ts b/api/js/etemplate/et2_extension_customfields.ts index d4abbc01ad..3d4da20aea 100644 --- a/api/js/etemplate/et2_extension_customfields.ts +++ b/api/js/etemplate/et2_extension_customfields.ts @@ -26,6 +26,7 @@ import {et2_cloneObject, et2_no_init} from "./et2_core_common"; import {et2_DOMWidget} from "./et2_core_DOMWidget"; import {loadWebComponent} from "./Et2Widget/Et2Widget"; import {LitElement} from "lit"; +import {Et2VfsSelectButton} from "./Et2Vfs/Et2VfsSelectButton"; export class et2_customfields_list extends et2_valueWidget implements et2_IDetachedDOM, et2_IInput { @@ -808,19 +809,19 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac attrs, // Filemanager select { - label: '', + path: '~', mode: widget.options.multiple ? 'open-multiple' : 'open', method: 'EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_existing', - method_id: attrs.path, - button_label: egw.lang('Link') - }, {type: 'vfs-select'}); + methodId: attrs.path, + buttonLabel: this.egw().lang('Link') + }, {type: 'et2-vfs-select'}); select_attrs.id = attrs.id + '_vfs_select'; // This controls where the button is placed in the DOM this.rows[select_attrs.id] = cf[0]; // Do not store in the widgets list, one name for multiple widgets would cause problems - widget = et2_createWidget(select_attrs.type, select_attrs, this); + widget = loadWebComponent(select_attrs.type, select_attrs, this); jQuery(widget.getDOMNode(widget)).css('vertical-align','top').prependTo(cf); } return false; diff --git a/api/src/Etemplate/Widget/Vfs.php b/api/src/Etemplate/Widget/Vfs.php index 43d54aba3d..b302bf67b3 100644 --- a/api/src/Etemplate/Widget/Vfs.php +++ b/api/src/Etemplate/Widget/Vfs.php @@ -620,6 +620,13 @@ class Vfs extends File { $content['path'] = $response['path'] = Api\Vfs::get_home_dir(); } + if(!Api\Vfs::is_readable($content['path'])) + { + if($content['path'] && str_contains($content['path'], ':') && $path = static::get_vfs_path($content['path'])) + { + $content['path'] = $response['path'] = $path; + } + } $response['writable'] = Api\Vfs::is_writable($content['path']); // Filemanager favorites as directories