|
312 | 312 | return !routing.method_routing_id || routing.method_routing_id === ""; |
313 | 313 | } |
314 | 314 |
|
315 | | - onMount(() => { |
| 315 | + // Read deep-link query params (e.g. from Dynamic Endpoint operations table) |
| 316 | + // and pre-open the create form with fields pre-filled. |
| 317 | + let prefillBanner = $state<string | null>(null); |
| 318 | + function applyPrefillFromUrl() { |
| 319 | + if (typeof window === "undefined") return; |
| 320 | + const params = new URLSearchParams(window.location.search); |
| 321 | + const prefillMethod = params.get("prefill_method_name"); |
| 322 | + if (!prefillMethod) return; |
| 323 | +
|
| 324 | + const prefillConnector = params.get("prefill_connector_name") || ""; |
| 325 | + const prefillBankPattern = params.get("prefill_bank_id_pattern") || ""; |
| 326 | + const prefillExact = params.get("prefill_is_bank_id_exact_match") === "true"; |
| 327 | +
|
| 328 | + // Dynamic Endpoint operationIds are not part of /system/connector-method-names, |
| 329 | + // so add the prefilled name to the options list. Without this, bind:value on the |
| 330 | + // <select> can't match any <option> and the field resets to empty. |
| 331 | + if (!methodNames.includes(prefillMethod)) { |
| 332 | + methodNames = [prefillMethod, ...methodNames]; |
| 333 | + } |
| 334 | +
|
| 335 | + formData = { |
| 336 | + method_name: prefillMethod, |
| 337 | + connector_name: prefillConnector, |
| 338 | + is_bank_id_exact_match: prefillExact, |
| 339 | + bank_id_pattern: prefillBankPattern, |
| 340 | + parameters: "", |
| 341 | + }; |
| 342 | + showCreateForm = true; |
| 343 | + prefillBanner = `Pre-filled from a Dynamic Endpoint operation: ${prefillMethod}. Edit the connector and parameters before saving.`; |
| 344 | + scrollToForm(); |
| 345 | + } |
| 346 | +
|
| 347 | + onMount(async () => { |
316 | 348 | fetchMethodRoutings(); |
317 | | - fetchMethodNames(); |
318 | 349 | fetchConnectorNames(); |
319 | 350 | fetchBankIds(); |
| 351 | + // Await method names before applying the URL prefill so the <select> options |
| 352 | + // are populated when we set formData.method_name. |
| 353 | + await fetchMethodNames(); |
| 354 | + applyPrefillFromUrl(); |
320 | 355 | }); |
321 | 356 | </script> |
322 | 357 |
|
|
344 | 379 | {/if} |
345 | 380 | </div> |
346 | 381 |
|
| 382 | + <!-- Prefill banner (from Dynamic Endpoint deep-link) --> |
| 383 | + {#if prefillBanner} |
| 384 | + <div class="alert alert-info mb-6" data-testid="prefill-banner"> |
| 385 | + <strong>ℹ️</strong> |
| 386 | + {prefillBanner} |
| 387 | + <button onclick={() => (prefillBanner = null)} class="alert-close">×</button> |
| 388 | + </div> |
| 389 | + {/if} |
| 390 | + |
347 | 391 | <!-- Messages --> |
348 | 392 | {#if error} |
349 | 393 | <div class="alert alert-error mb-6"> |
|
1050 | 1094 | border-color: rgb(var(--color-success-800)); |
1051 | 1095 | } |
1052 | 1096 |
|
| 1097 | + .alert-info { |
| 1098 | + background: #dbeafe; |
| 1099 | + color: #1e40af; |
| 1100 | + border: 1px solid #bfdbfe; |
| 1101 | + } |
| 1102 | +
|
| 1103 | + :global([data-mode="dark"]) .alert-info { |
| 1104 | + background: rgba(59, 130, 246, 0.15); |
| 1105 | + color: #93c5fd; |
| 1106 | + border-color: rgba(59, 130, 246, 0.3); |
| 1107 | + } |
| 1108 | +
|
1053 | 1109 | .alert-close { |
1054 | 1110 | background: transparent; |
1055 | 1111 | border: none; |
|
0 commit comments