Commit 8d23f33c by Owen

selected element behavior change, 'other' field for radio list.

parent 43cddff7
...@@ -1483,7 +1483,6 @@ const inputRadiolist = (key, validation) => { ...@@ -1483,7 +1483,6 @@ const inputRadiolist = (key, validation) => {
inputTextBox.id = `dependentTB_${key}`; inputTextBox.id = `dependentTB_${key}`;
inputTextBox.classList.add('radioOther'); inputTextBox.classList.add('radioOther');
inputTextBox.style.display = 'none'; inputTextBox.style.display = 'none';
inputTextBox.style.padding = '0px';
dropdownContent.appendChild(inputTextBox); dropdownContent.appendChild(inputTextBox);
// Add event listener to the "other" radio button // Add event listener to the "other" radio button
......
...@@ -5,7 +5,7 @@ import { createLoadingModal, removeLoadingModal } from '../LoadingModal/LoadingM ...@@ -5,7 +5,7 @@ import { createLoadingModal, removeLoadingModal } from '../LoadingModal/LoadingM
import { logoutKeycloak } from '../Logout/Logout.js'; import { logoutKeycloak } from '../Logout/Logout.js';
import { ADD_NEW_OPTION, CURRENT_NODE, BPO_URL, DISPLAYED_DETAILS } from '../config.js'; import { ADD_NEW_OPTION, CURRENT_NODE, BPO_URL, DISPLAYED_DETAILS } from '../config.js';
import { DocumentControlWidget } from "../documentControlWidget/documentControlWidget.js"; import { DocumentControlWidget } from "../documentControlWidget/documentControlWidget.js";
import { createErrorModal } from '../genericPopup/genericPopup.js'; import { createErrorModal, createInfoModal } from '../genericPopup/genericPopup.js';
import { INDEXED_DB_STORAGE, HIGHLIGHT_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_NAME, INDEXED_DB_TBL_NAME, setIndexedDBStorage, setHighlightObject, setImageViewerObject, setBPOObject, BPO_OBJECT, DISPLAY_FIELD_OBJECT, setDisplayFieldObject, activateGDE, setDocumentControlObject, DOCUMENT_CONTROL_OBJECT, IS_GDE_ACTIVATED } from "../globalVariable.js"; import { INDEXED_DB_STORAGE, HIGHLIGHT_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_NAME, INDEXED_DB_TBL_NAME, setIndexedDBStorage, setHighlightObject, setImageViewerObject, setBPOObject, BPO_OBJECT, DISPLAY_FIELD_OBJECT, setDisplayFieldObject, activateGDE, setDocumentControlObject, DOCUMENT_CONTROL_OBJECT, IS_GDE_ACTIVATED } from "../globalVariable.js";
import PullToRefresh from './PullToRefresh.js'; import PullToRefresh from './PullToRefresh.js';
...@@ -44,14 +44,15 @@ export class ElementListWidget { ...@@ -44,14 +44,15 @@ export class ElementListWidget {
createLoadingModal("Fetching Elements", "Fetching Workers", null, null, null); createLoadingModal("Fetching Elements", "Fetching Workers", null, null, null);
this.global.pullToRefresh = PullToRefresh.init({ if (!this.global.pullToRefresh) {
mainElement: '#element-list', this.global.pullToRefresh = PullToRefresh.init({
onRefresh: async () => { mainElement: '#element-list',
// Call the init function again onRefresh: async () => {
await this.reloadElementList(nodeId, workerId); // Call the reloadElementList function again
} await this.reloadElementList(nodeId, workerId);
}); }
});
}
console.log(`Fetching workers for node ID: ${nodeId}`); console.log(`Fetching workers for node ID: ${nodeId}`);
const workerResponse = await fetchWorkersForNode(nodeId); const workerResponse = await fetchWorkersForNode(nodeId);
console.log("Worker API Response:", workerResponse); console.log("Worker API Response:", workerResponse);
...@@ -79,9 +80,17 @@ export class ElementListWidget { ...@@ -79,9 +80,17 @@ export class ElementListWidget {
/* console.log("Elements API Response:", elementResponse);*/ /* console.log("Elements API Response:", elementResponse);*/
if (elementResponse.successful && Array.isArray(elementResponse.elements)) { if (elementResponse.successful && Array.isArray(elementResponse.elements)) {
this.elements = elementResponse.elements.filter(element => if (elementResponse.elements.length === 0) {
selectedWorker.queueIndex.includes(element.queueIndex) // No more elements case
); removeLoadingModal();
// createInfoModal(null, "Close", "No more elements available.");
createErrorModal(null, "Close", "No more elements available.");
return;
} else {
this.elements = elementResponse.elements.filter(element =>
selectedWorker.queueIndex.includes(element.queueIndex)
);
}
} else { } else {
this.elements = []; this.elements = [];
removeLoadingModal(); removeLoadingModal();
...@@ -120,9 +129,16 @@ export class ElementListWidget { ...@@ -120,9 +129,16 @@ export class ElementListWidget {
/* console.log("Elements API Response:", elementResponse);*/ /* console.log("Elements API Response:", elementResponse);*/
if (elementResponse.successful && Array.isArray(elementResponse.elements)) { if (elementResponse.successful && Array.isArray(elementResponse.elements)) {
this.elements = elementResponse.elements.filter(element => if (elementResponse.elements.length === 0) {
selectedWorker.queueIndex.includes(element.queueIndex) // No more elements case
); // createInfoModal(null, "Close", "No more elements available.");
createErrorModal(null, "Close", "No more elements available.");
return;
} else {
this.elements = elementResponse.elements.filter(element =>
selectedWorker.queueIndex.includes(element.queueIndex)
);
}
} else { } else {
this.elements = []; this.elements = [];
createErrorModal(null, "Close", `Failed to fetch elements or received malformed data: ${elementResponse}`); createErrorModal(null, "Close", `Failed to fetch elements or received malformed data: ${elementResponse}`);
...@@ -301,21 +317,25 @@ export class ElementListWidget { ...@@ -301,21 +317,25 @@ export class ElementListWidget {
elementContainer.appendChild(elementDiv); elementContainer.appendChild(elementDiv);
elementList.appendChild(elementContainer); elementList.appendChild(elementContainer);
elementArrow.addEventListener("click", () =>{ // elementArrow.addEventListener("click", () =>{
this.showExtraDetails(element, elementContainer); // this.showExtraDetails(element, elementContainer);
}); // });
// Click event listener for each element container // Click event listener for each element container
elementContainer.addEventListener("click", () => { elementContainer.addEventListener("click", () => {
if (elementContainer.classList.contains("selected")) { if (elementContainer.classList.contains("selected")) {
elementArrow.style.transform = "rotate(180deg)";
deselectAll(); deselectAll();
} else { } else {
deselectAll(); deselectAll();
elementContainer.classList.add("selected"); elementContainer.classList.add("selected");
this.global.selectedElement = element; this.global.selectedElement = element;
this.global.queueIndex = element.queueIndex; // <-- Update the queueIndex here this.global.queueIndex = element.queueIndex; // <-- Update the queueIndex here
this.showExtraDetails(element, elementContainer);
this.global.encodeButton.disabled = false; this.global.encodeButton.disabled = false;
this.global.encodeButton.classList.remove("disabled"); this.global.encodeButton.classList.remove("disabled");
elementArrow.style.transform = "rotate(0deg)";
} }
}); });
}); });
...@@ -372,6 +392,7 @@ export class ElementListWidget { ...@@ -372,6 +392,7 @@ export class ElementListWidget {
// Remove the current container from the DOM // Remove the current container from the DOM
this.global.container.remove(); this.global.container.remove();
this.global.pullToRefresh.destroy();
// Continue with the original logic // Continue with the original logic
await createWebGdeInterface(null); await createWebGdeInterface(null);
......
...@@ -189,10 +189,10 @@ export function createConfirmationModal(okButtonFunction, popupTitleText, warnin ...@@ -189,10 +189,10 @@ export function createConfirmationModal(okButtonFunction, popupTitleText, warnin
document.getElementById("popupContainer").style.display = "flex"; document.getElementById("popupContainer").style.display = "flex";
document.getElementById("yesButtonModal").addEventListener("click", function () { document.getElementById("yesButtonModal").addEventListener("click", function () {
document.getElementById("backdropContainer").style.display = "none";
if (typeof okButtonFunction === "function") { if (typeof okButtonFunction === "function") {
okButtonFunction(); okButtonFunction();
} }
document.getElementById("backdropContainer").remove();
return true; return true;
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment