refactor: remove orphaned functions after tab extraction
Remove loadColumnsForDatasource, searchDatasources, selectDatasource, toggleContextColumn, toggleSourceKeyCol, updateTargetKeyCol, isVirtual from page — all moved to ConfigTabForm.svelte. Add on datasourceId in ConfigTabForm to auto-load columns when parent sets datasourceId (loadJob) or user selects a datasource.
This commit is contained in:
@@ -78,6 +78,13 @@
|
||||
return (virtualColumns || []).includes(colName);
|
||||
}
|
||||
|
||||
// Auto-load columns when datasourceId changes (from parent loadJob or user selection)
|
||||
$effect(() => {
|
||||
if (datasourceId && environmentId) {
|
||||
loadColumnsForDatasource();
|
||||
}
|
||||
});
|
||||
|
||||
// ---- Datasource search ----
|
||||
let searchTimer = null;
|
||||
async function handleDatasourceSearch() {
|
||||
@@ -113,12 +120,6 @@
|
||||
targetSourceLanguageColumn = '';
|
||||
contextColumns = [];
|
||||
databaseDialect = ds.database_dialect || '';
|
||||
if (ds.database_id) {
|
||||
// will be picked up by parent via bind:datasourceId
|
||||
}
|
||||
if (datasourceId && environmentId) {
|
||||
loadColumnsForDatasource();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadColumnsForDatasource() {
|
||||
|
||||
@@ -73,8 +73,6 @@
|
||||
fetchJobs,
|
||||
createJob,
|
||||
updateJob,
|
||||
fetchDatasourceColumns,
|
||||
fetchDatasources,
|
||||
} from '$lib/api/translate.js';
|
||||
import MultiSelect from '$lib/components/ui/MultiSelect.svelte';
|
||||
import TranslationPreview from '$lib/components/translate/TranslationPreview.svelte';
|
||||
@@ -412,7 +410,6 @@
|
||||
} else {
|
||||
datasourceSearch = `Dataset #${j.source_datasource_id}`;
|
||||
}
|
||||
await loadColumnsForDatasource();
|
||||
}
|
||||
|
||||
uxState = 'configured';
|
||||
@@ -424,13 +421,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {Promise<void>} */
|
||||
async function loadColumnsForDatasource() {
|
||||
if (!datasourceId || !environmentId) {
|
||||
availableColumns = [];
|
||||
virtualColumns = [];
|
||||
return;
|
||||
}
|
||||
/** @param {Event} event */
|
||||
async function handleDatasourceChange(event) {
|
||||
const val = event.target.value;
|
||||
datasourceId = val;
|
||||
availableColumns = [];
|
||||
virtualColumns = [];
|
||||
// Reset column selections when datasource changes
|
||||
sourceKeyCols = [];
|
||||
targetKeyCols = [];
|
||||
translationColumn = '';
|
||||
contextColumns = [];
|
||||
}
|
||||
|
||||
isColumnsLoading = true;
|
||||
try {
|
||||
@@ -527,16 +529,10 @@
|
||||
async function handleEnvChange(event) {
|
||||
const newEnv = event.target.value;
|
||||
environmentId = newEnv;
|
||||
// Clear search state, but KEEP datasourceId if already loaded from job
|
||||
// — just reload columns with the new environment
|
||||
datasourceSearch = '';
|
||||
datasourceList = [];
|
||||
databaseDialect = '';
|
||||
targetDatabaseId = '';
|
||||
await loadDatabases();
|
||||
if (datasourceId) {
|
||||
await loadColumnsForDatasource();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {string} col */
|
||||
|
||||
Reference in New Issue
Block a user