From deb4977c1487fd44911c84898d755c268ffb40a1 Mon Sep 17 00:00:00 2001 From: Ronni Skansing Date: Tue, 21 Oct 2025 19:24:52 +0200 Subject: [PATCH] make campaign template wizard smaller Signed-off-by: Ronni Skansing --- .../src/routes/campaign-template/+page.svelte | 379 +++++++++--------- 1 file changed, 182 insertions(+), 197 deletions(-) diff --git a/frontend/src/routes/campaign-template/+page.svelte b/frontend/src/routes/campaign-template/+page.svelte index 764824d..bcbc92f 100644 --- a/frontend/src/routes/campaign-template/+page.svelte +++ b/frontend/src/routes/campaign-template/+page.svelte @@ -45,22 +45,20 @@ let form = null; let formValues = { id: null, - templateType: null, + templateType: 'Email', name: null, domain: null, landingPage: null, landingPageType: 'page', // 'page' or 'proxy' beforeLandingPage: null, - beforeLandingPageType: 'page', // 'page' or 'proxy' afterLandingPage: null, - afterLandingPageType: 'page', // 'page' or 'proxy' - afterLandingPageRedirectURL: null, + afterLandingPageRedirectURL: '', email: null, smtpConfiguration: null, apiSender: null, urlIdentifier: 'id', stateIdentifier: 'session', - urlPath: null + urlPath: '' }; let contextCompanyID = null; @@ -97,6 +95,7 @@ id: null, name: null }; + let showAdvancedOptions = false; $: { modalText = getModalText('template', modalMode); @@ -304,26 +303,14 @@ formValues.landingPageType === 'proxy' ? landingProxyMap.byValueOrNull(formValues.landingPage) : null, - beforeLandingPageID: - formValues.beforeLandingPageType === 'page' - ? beforeLandingPageMap.byValueOrNull(formValues.beforeLandingPage) - : null, - beforeLandingProxyID: - formValues.beforeLandingPageType === 'proxy' - ? beforeLandingProxyMap.byValueOrNull(formValues.beforeLandingPage) - : null, - afterLandingPageID: - formValues.afterLandingPageType === 'page' - ? afterLandingPageMap.byValueOrNull(formValues.afterLandingPage) - : null, - afterLandingProxyID: - formValues.afterLandingPageType === 'proxy' - ? afterLandingProxyMap.byValueOrNull(formValues.afterLandingPage) - : null, - afterLandingPageRedirectURL: formValues.afterLandingPageRedirectURL, + beforeLandingPageID: beforeLandingPageMap.byValueOrNull(formValues.beforeLandingPage), + beforeLandingProxyID: null, + afterLandingPageID: afterLandingPageMap.byValueOrNull(formValues.afterLandingPage), + afterLandingProxyID: null, + afterLandingPageRedirectURL: formValues.afterLandingPageRedirectURL || '', urlIdentifierID: identifierMap.byValueOrNull(formValues.urlIdentifier), stateIdentifierID: identifierMap.byValueOrNull(formValues.stateIdentifier), - urlPath: formValues.urlPath, + urlPath: formValues.urlPath || '', companyID: contextCompanyID }); if (!res.success) { @@ -356,26 +343,14 @@ formValues.landingPageType === 'proxy' ? landingProxyMap.byValueOrNull(formValues.landingPage) : null, - beforeLandingPageID: - formValues.beforeLandingPageType === 'page' - ? beforeLandingPageMap.byValueOrNull(formValues.beforeLandingPage) - : null, - beforeLandingProxyID: - formValues.beforeLandingPageType === 'proxy' - ? beforeLandingProxyMap.byValueOrNull(formValues.beforeLandingPage) - : null, - afterLandingPageID: - formValues.afterLandingPageType === 'page' - ? afterLandingPageMap.byValueOrNull(formValues.afterLandingPage) - : null, - afterLandingProxyID: - formValues.afterLandingPageType === 'proxy' - ? afterLandingProxyMap.byValueOrNull(formValues.afterLandingPage) - : null, - afterLandingPageRedirectURL: formValues.afterLandingPageRedirectURL, + beforeLandingPageID: beforeLandingPageMap.byValueOrNull(formValues.beforeLandingPage), + beforeLandingProxyID: null, + afterLandingPageID: afterLandingPageMap.byValueOrNull(formValues.afterLandingPage), + afterLandingProxyID: null, + afterLandingPageRedirectURL: formValues.afterLandingPageRedirectURL || '', urlIdentifierID: identifierMap.byValueOrNull(formValues.urlIdentifier), stateIdentifierID: identifierMap.byValueOrNull(formValues.stateIdentifier), - urlPath: formValues.urlPath + urlPath: formValues.urlPath || '' }); if (!res.success) { modalError = res.error; @@ -422,24 +397,23 @@ form.reset(); formValues = { id: null, - templateType: null, + templateType: 'Email', name: null, domain: null, landingPage: null, landingPageType: 'page', beforeLandingPage: null, - beforeLandingPageType: 'page', afterLandingPage: null, - afterLandingPageType: 'page', - afterLandingPageRedirectURL: null, + afterLandingPageRedirectURL: '', email: null, smtpConfiguration: null, apiSender: null, urlIdentifier: 'id', stateIdentifier: 'session', - urlPath: null + urlPath: '' }; modalError = ''; + showAdvancedOptions = false; }; /** @param {string} id */ @@ -488,7 +462,7 @@ if (template.smtpConfigurationID) { formValues.templateType = 'Email'; } else { - formValues.templateType = 'External API'; + formValues.templateType = 'API Sender'; } formValues.domain = domainMap.byKey(template.domainID); formValues.email = emailMap.byKey(template.emailID); @@ -502,28 +476,32 @@ formValues.landingPageType = 'proxy'; } - // handle before landing page (page or proxy) + // handle before landing page (only pages, no proxy) if (template.beforeLandingPageID) { formValues.beforeLandingPage = beforeLandingPageMap.byKey(template.beforeLandingPageID); - formValues.beforeLandingPageType = 'page'; - } else if (template.beforeLandingProxyID) { - formValues.beforeLandingPage = beforeLandingProxyMap.byKey(template.beforeLandingProxyID); - formValues.beforeLandingPageType = 'proxy'; } - // handle after landing page (page or proxy) + // handle after landing page (only pages, no proxy) if (template.afterLandingPageID) { formValues.afterLandingPage = afterLandingPageMap.byKey(template.afterLandingPageID); - formValues.afterLandingPageType = 'page'; - } else if (template.afterLandingProxyID) { - formValues.afterLandingPage = afterLandingProxyMap.byKey(template.afterLandingProxyID); - formValues.afterLandingPageType = 'proxy'; } - formValues.afterLandingPageRedirectURL = template.afterLandingPageRedirectURL; + formValues.afterLandingPageRedirectURL = template.afterLandingPageRedirectURL || ''; formValues.urlIdentifier = identifierMap.byKey(template.urlIdentifierID); formValues.stateIdentifier = identifierMap.byKey(template.stateIdentifierID); - formValues.urlPath = template.urlPath; + formValues.urlPath = template.urlPath || ''; + + // set advanced options visibility based on template configuration + showAdvancedOptions = !!( + ( + (template.urlPath && template.urlPath !== '') || + (template.afterLandingPageRedirectURL && template.afterLandingPageRedirectURL !== '') || + (template.urlIdentifierID && identifierMap.byKey(template.urlIdentifierID) !== 'id') || + (template.stateIdentifierID && + identifierMap.byKey(template.stateIdentifierID) !== 'session') || + template.apiSenderID + ) // Show advanced if using External API + ); }; @@ -794,69 +772,10 @@ Simulation URLs to allow:\n${allowListingData.simulationUrl}\n
- NameName
-
-
- -
-
-
- - - -
-

- Delivery Configuration -

-
-
- {#if formValues.templateType === 'Email' || !formValues.templateType} - SMTP Configuration - {:else if formValues.templateType === 'External API'} - API Sender - {/if} -
-
- Email -
-
-
- - -
-

- Domain & URL Configuration -

-
Domain
+
+
+ + + +
+

+ Email Configuration +

+
+ {#if formValues.templateType === 'Email' || !formValues.templateType} +
+ SMTP Configuration +
+ {:else if formValues.templateType === 'External API'} +
+ External API Sender +
+ {/if}
- URL Path -
-
- Query param key -
-
- State param keyEmail
@@ -902,13 +830,11 @@ Simulation URLs to allow:\n${allowListingData.simulationUrl}\n
- Before LandingBefore Landing @@ -922,24 +848,12 @@ Simulation URLs to allow:\n${allowListingData.simulationUrl}\n > - After LandingAfter Landing - -
- POST redirect URL -
@@ -961,9 +875,7 @@ Simulation URLs to allow:\n${allowListingData.simulationUrl}\n

- Before Landing {formValues.beforeLandingPageType === 'proxy' - ? 'Proxy' - : 'Page'} + Before Landing Page

- After Landing {formValues.afterLandingPageType === 'proxy' ? 'Proxy' : 'Page'} + After Landing Page

- -
-
-
+ {#if showAdvancedOptions} + +
+
+
- -
-
- 4 +
+
+ 4 +
+
+

+ POST Redirect URL +

+

+ {formValues.afterLandingPageRedirectURL || 'Not set'} +

+
-
-

- POST Redirect URL -

-

- {formValues.afterLandingPageRedirectURL || 'Not set'} -

-
-
+ {/if}
- + + {#if !showAdvancedOptions} +
+ +
+ {/if} + + {#if showAdvancedOptions} +
+

+ Advanced Options +

+
+
+ +
+
+ URL Path +
+
+ Query param key +
+
+ State param key +
+
+ POST redirect URL +
+
+
+ {/if} +