Send only file names to the file selector callback.

This commit is contained in:
kovacsv 2021-11-30 10:29:01 +01:00
parent db57efeaf1
commit 07fe1d5509
3 changed files with 10 additions and 9 deletions

View File

@ -162,7 +162,8 @@ OV.Importer = class
let mainFile = importableFiles[0];
this.ImportLoadedMainFile (mainFile, settings, callbacks);
} else {
callbacks.onSelectMainFile (importableFiles, (mainFileIndex) => {
let fileNames = importableFiles.map (importableFile => importableFile.file.name);
callbacks.onSelectMainFile (fileNames, (mainFileIndex) => {
if (mainFileIndex === null) {
callbacks.onImportError (new OV.ImportError (OV.ImportErrorCode.NoImportableFile, null));
return;

View File

@ -36,11 +36,11 @@ OV.ThreeModelLoader = class
onFilesLoaded : () => {
this.callbacks.onImportStart ();
},
onSelectMainFile : (files, selectFile) => {
onSelectMainFile : (fileNames, selectFile) => {
if (!this.callbacks.onSelectMainFile) {
selectFile (0);
} else {
this.callbacks.onSelectMainFile (files, selectFile);
this.callbacks.onSelectMainFile (fileNames, selectFile);
}
},
onImportSuccess : (importResult) => {

View File

@ -23,7 +23,7 @@ OV.InitModelLoader = function (modelLoader, callbacks)
}
}
function ShowFileSelectorDialog (files, onSelect)
function ShowFileSelectorDialog (fileNames, onSelect)
{
let dialog = new OV.ButtonDialog ();
let contentDiv = dialog.Init ('Select Model', [
@ -45,11 +45,11 @@ OV.InitModelLoader = function (modelLoader, callbacks)
let fileListSection = OV.AddDiv (contentDiv, 'ov_dialog_section');
let fileList = OV.AddDiv (fileListSection, 'ov_dialog_import_file_list ov_thin_scrollbar');
for (let i = 0; i < files.length; i++) {
let file = files[i];
for (let i = 0; i < fileNames.length; i++) {
let fileName = fileNames[i];
let fileLink = OV.AddDiv (fileList, 'ov_dialog_file_link');
OV.AddSvgIconElement (fileLink, 'meshes', 'ov_file_link_img');
OV.AddDiv (fileLink, 'ov_dialog_file_link_text', file.file.name);
OV.AddDiv (fileLink, 'ov_dialog_file_link_text', fileName);
fileLink.addEventListener ('click', () => {
dialog.SetCloseHandler (null);
dialog.Hide ();
@ -79,9 +79,9 @@ OV.InitModelLoader = function (modelLoader, callbacks)
progressDialog.Init ('Loading Model');
progressDialog.Show ();
},
onSelectMainFile : (files, selectFile) => {
onSelectMainFile : (fileNames, selectFile) => {
progressDialog.Hide ();
modalDialog = ShowFileSelectorDialog (files, (index) => {
modalDialog = ShowFileSelectorDialog (fileNames, (index) => {
progressDialog.Show ();
selectFile (index);
});