From 1c5ee2f506902345b0b5020df47a2475da1da0c5 Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Thu, 13 Aug 2026 07:28:03 -0600 Subject: [PATCH] Handle missing file history when listing virology results The failure callback in getFileHistory called reject, which was never destructured from the promise executor, so a failed history lookup threw a ReferenceError instead of rejecting. It now logs and resolves so one unreadable file no longer drops the entire import list. A file placed on the server outside of an upload has no file system audit record, so history[0].data.date threw. Those rows now report their upload date as Unknown rather than substituting an unrelated timestamp. Promise.all had no rejection handler, so any failure left the Loading mask up with no feedback. It now hides the mask and alerts. --- .../resources/web/ehr/ext3/ehrGridFormPanel.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/WNPRC_EHR/resources/web/ehr/ext3/ehrGridFormPanel.js b/WNPRC_EHR/resources/web/ehr/ext3/ehrGridFormPanel.js index 34c7899ab..829869620 100644 --- a/WNPRC_EHR/resources/web/ehr/ext3/ehrGridFormPanel.js +++ b/WNPRC_EHR/resources/web/ehr/ext3/ehrGridFormPanel.js @@ -1077,8 +1077,8 @@ EHR.ext.GridFormPanel = Ext.extend(Ext.Panel, if (extension === 'xlsx' || extension === 'xls') { // need to get the date it was uploaded, // since 'record' only provides the date when the actual file was created - promises.push(getFileHistory(virologyResultsFolder, record.data.name).then((history) => { - files.push({"name": history[0], "uploaded": history[1][0].data.date}) + promises.push(getFileHistory(virologyResultsFolder, record.data.name).then((file) => { + files.push(file) })) } @@ -1113,6 +1113,10 @@ EHR.ext.GridFormPanel = Ext.extend(Ext.Panel, importFromFileWindow.removeAll(); importFromFileWindow.add(selectFilePanel); importFromFileWindow.doLayout(); + }).catch((e) => { + Ext.Msg.hide(); + console.error(e); + Ext.Msg.alert('Error', 'Unable to build the list of files to import.'); }) }, @@ -1130,14 +1134,17 @@ EHR.ext.GridFormPanel = Ext.extend(Ext.Panel, } }); function getFileHistory(fileSystem, filename) { + // Always resolves so one unreadable file still leaves the rest importable. return new Promise(resolve => { fileSystem.getHistory({ path: '/' + filename, success: function(fileSystem,path,history) { - resolve([filename,history]); + // A file placed on the server outside of an upload has no audit record. + resolve({name: filename, uploaded: history && history.length ? history[0].data.date : null}); }, failure: function(f) { - reject(f); + console.error('Unable to read file history for ' + filename, f); + resolve({name: filename, uploaded: null}); } }) }); @@ -1307,7 +1314,7 @@ EHR.ext.GridFormPanel = Ext.extend(Ext.Panel, html: '' + file.name + '' }, { - html: '' + new Date(file.uploaded).format("Y-m-d H:i")+ '' + html: '' + (file.uploaded ? new Date(file.uploaded).format("Y-m-d H:i") : 'Unknown') + '' }, ];