(
domainKey,
config,
allowListSelectionChange = true
)
| 2083 | } |
| 2084 | } |
| 2085 | async function setupImportButton( |
| 2086 | domainKey, |
| 2087 | config, |
| 2088 | allowListSelectionChange = true |
| 2089 | ) { |
| 2090 | if (!UI.importBtn || !UI.listTab2) return false; |
| 2091 | console.log( |
| 2092 | `[setupImportButton] Setting up button for ${domainKey}. allowChange=${allowListSelectionChange}` |
| 2093 | ); |
| 2094 | |
| 2095 | if (importButtonClickListener || autoImportStopClickListener) { |
| 2096 | console.log( |
| 2097 | "[setupImportButton] Removing previous import button listeners." |
| 2098 | ); |
| 2099 | removeImportButtonClickListener(); |
| 2100 | removeAutoImportStopClickListener(); |
| 2101 | } |
| 2102 | |
| 2103 | let simpleName = domainKey; |
| 2104 | const domainParts = domainKey.split("."); |
| 2105 | if (domainParts.length >= 2) |
| 2106 | simpleName = domainParts[domainParts.length - 2]; |
| 2107 | simpleName = simpleName.charAt(0).toUpperCase() + simpleName.slice(1); |
| 2108 | const buttonText = `Import from ${simpleName}`; |
| 2109 | const truncatedText = truncateText(buttonText, 34); |
| 2110 | |
| 2111 | UI.importBtn.textContent = truncatedText; |
| 2112 | UI.importBtn.title = `Import data using "${domainKey}" configuration`; |
| 2113 | UI.importBtn.dataset.contextKey = domainKey; |
| 2114 | |
| 2115 | if (allowListSelectionChange) { |
| 2116 | const preferredListKey = await getPreferredImportListKey(domainKey); |
| 2117 | if (preferredListKey) { |
| 2118 | const selected = await selectListAndRefreshTextarea(preferredListKey); |
| 2119 | if (selected) { |
| 2120 | console.log( |
| 2121 | `Selected import list for ${domainKey}: ${preferredListKey}` |
| 2122 | ); |
| 2123 | } |
| 2124 | } else { |
| 2125 | clearPayloadInput(); |
| 2126 | updatePayloadLineCount(); |
| 2127 | } |
| 2128 | } else { |
| 2129 | console.log( |
| 2130 | `[setupImportButton] Keeping current list selection for ${domainKey}.` |
| 2131 | ); |
| 2132 | } |
| 2133 | |
| 2134 | console.log( |
| 2135 | `[setupImportButton] Setting button display to inline-block for ${domainKey}` |
| 2136 | ); |
| 2137 | UI.importBtn.style.display = "inline-block"; |
| 2138 | console.log( |
| 2139 | `[setupImportButton] Button display is now: ${UI.importBtn.style.display}` |
| 2140 | ); |
| 2141 | setManualImportButtonState(isCurrentlyAutoImporting, isImportPaused); |
| 2142 | if (isCurrentlyAutoImporting || isImportPaused) { |
no test coverage detected