From db44357057369fcc3296a17b982299936feb613b Mon Sep 17 00:00:00 2001 From: Helena Jeeves Date: Thu, 22 Dec 2022 11:55:01 -0800 Subject: [PATCH 1/2] CADC-12092: first checkin of solution. Tested on jeevesh vm against keel-dev --- src/main/webapp/js/science_portal_form.js | 81 ++++++++++------------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/src/main/webapp/js/science_portal_form.js b/src/main/webapp/js/science_portal_form.js index 3158ee0..8411ce2 100644 --- a/src/main/webapp/js/science_portal_form.js +++ b/src/main/webapp/js/science_portal_form.js @@ -66,7 +66,7 @@ _selfPortalForm.getContextData() // Start loading container image lists - _selfPortalForm.getImageData() + _selfPortalForm.getFullImageList() } @@ -110,70 +110,60 @@ return null } + function isTypeInList(imageType) { + var isInList = (element) => element === imageType + var typeIndex = _selfPortalForm._sessionTypeList.findIndex(isInList) + if (typeIndex === -1) { + return false + } else { + return true + } + } // --------------- Image list functions - function getImageData() { - - for (var i = 0; i < _selfPortalForm._sessionTypeMap.session_types.length; i++) { - var curTypename = _selfPortalForm._sessionTypeMap.session_types[i].name - - // This needs to be done by type, and the type need to be - // pushed through to the 'then' so the right - // values are populated in the image object - var curTypeURL = _selfPortalForm.sessionURLs.images + '?type=' + curTypename - - // Do this so each call has it's own curTypeURL - // If the Promise is in this same function, the timing of the ajax - // calls is such that curTypeURL is the same for all lists so - // there's no effective lookup. - _getImageDataForType(curTypeURL, curTypename) - } - } - function _getImageDataForType(callURL, sessionType ){ - Promise.resolve(_getAjaxData(callURL)) + function getFullImageList(){ + var fullListURL = _selfPortalForm.sessionURLs.images + Promise.resolve(_getAjaxData(fullListURL)) .then(function (imageList) { - if (_selfPortalForm._ajaxCallCount !== -9) { - var imageIDList = new Array() - for (var i = 0; i < imageList.length; i++) { - imageIDList.push(imageList[i].id) + // init the image list structure to simplify the loop below + _selfPortalForm._imageData = {} + for (var j=0; j<_selfPortalForm._sessionTypeList.length; j++) { + _selfPortalForm._imageData[_selfPortalForm._sessionTypeList[j]] = { + 'imageList': new Array(), + "imageIDList": new Array() } + } - _selfPortalForm._ajaxCallCount-- - _selfPortalForm._imageData.push({ - "sessionType": sessionType, - "imageList": imageList, - "imageIDList": imageIDList - }) - - if (_selfPortalForm._ajaxCallCount === 0) { - trigger(_selfPortalForm, cadc.web.science.portal.form.events.onLoadFormDataDone) + for (var i=0; i Date: Thu, 22 Dec 2022 11:55:42 -0800 Subject: [PATCH 2/2] CADC-12092: up war file version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6f12cb2..dd5b35d 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ dependencies { sourceCompatibility = '1.8' group = 'ca.nrc.cadc' -version = '1010' +version = '1011' ext { intTest_user_name = 'CADCtest'