-
{{ type }} - {{ identifier }}
+
{{ type }} - {{ identifier }}
();
const valueSets = ref();
const variables = ref();
+const idParam = computed(() => route.query.id as string);
+const typeParam = computed(() => route.query.type as string);
+
const isValid = computed(() => !!type.value && !!identifier.value);
const tableOptions = computed(() => tables.value?.map((table) => ({ label: asTableId(table), value: asTableId(table) })) || []);
const table = computed(() => tables.value?.find((t) => asTableId(t) === tableId.value));
@@ -129,6 +134,18 @@ const rows = computed(() => {
return result;
});
+onMounted(() => {
+ if (idParam.value) {
+ identifier.value = idParam.value;
+ }
+ if (typeParam.value) {
+ type.value = typeParam.value;
+ }
+ if (isValid.value) {
+ onSubmit();
+ }
+});
+
function onClear() {
tables.value = undefined;
tableId.value = undefined;
@@ -137,12 +154,30 @@ function onClear() {
}
function onSubmit() {
+ if (!isValid.value) {
+ return;
+ }
loading.value = true;
onClear();
searchStore.getEntityTables(type.value, identifier.value)
.then((response) => {
tables.value = response;
- tableId.value = response.length > 0 ? asTableId(response[0]) : undefined;
+ if (response.length > 0) {
+ // if there is a table in the app context state, select it
+ if (datasourceStore.table) {
+ const tbl = tables.value?.find((t) => t.link === datasourceStore.table.link);
+ // check if the table is in the list
+ if (tbl) {
+ tableId.value = asTableId(tbl);
+ }
+ }
+ // otherwise select the first table
+ if (!tableId.value) {
+ tableId.value = asTableId(response[0]);
+ }
+ } else {
+ tableId.value = undefined;
+ }
onTableSelected();
})
.catch((error) => {