feat(clickTtPlayerRegistrationService, MembersView): enhance Click-TT registration flow and UI feedback
- Replaced the abort confirmation flow with a new function to open the application after a search, improving user experience by directly navigating to the application. - Updated error handling to provide clearer messages when a confirm dialog is encountered, enhancing traceability. - Modified the MembersView to track application submission status and display detailed success/error messages, improving user feedback during the registration process. - Introduced a new method to format and display trace details, aiding in debugging and user communication.
This commit is contained in:
@@ -368,13 +368,40 @@ function injectProxyNavigationScript(html, proxyBaseUrl, pageBaseUrl, sid) {
|
||||
"console.log('[ClickTT Proxy] inline confirm elements json',JSON.stringify(elements));",
|
||||
'}catch(e){}',
|
||||
'}',
|
||||
'function bindInlineConfirmElements(){',
|
||||
'try{',
|
||||
"var elements=[].slice.call(document.querySelectorAll('[onclick*=\"confirm(\"]'));",
|
||||
'elements.forEach(function(el,index){',
|
||||
"if(el.__clickttConfirmBound)return;",
|
||||
'el.__clickttConfirmBound=true;',
|
||||
"el.addEventListener('click',function(event){",
|
||||
"try{console.log('[ClickTT Proxy] direct confirm element click',{index:index,tag:el.tagName,name:el.getAttribute('name'),value:el.getAttribute('value'),href:el.getAttribute('href'),onclick:el.getAttribute('onclick'),text:(el.textContent||'').trim().slice(0,120)});}catch(e){}",
|
||||
'var allowed=shouldAllowInlineConfirm(el);',
|
||||
'if(!allowed){',
|
||||
'event.preventDefault();',
|
||||
'event.stopPropagation();',
|
||||
'return false;',
|
||||
'}',
|
||||
"var href=el.getAttribute&&el.getAttribute('href');",
|
||||
'var targetUrl=normalizeUrl(href,PAGE_BASE_URL);',
|
||||
'if(targetUrl&&shouldProxyUrl(targetUrl)){',
|
||||
'event.preventDefault();',
|
||||
'event.stopPropagation();',
|
||||
'navigateViaProxy(targetUrl);',
|
||||
'return false;',
|
||||
'}',
|
||||
'return true;',
|
||||
'},true);',
|
||||
'});',
|
||||
'}catch(e){}',
|
||||
'}',
|
||||
'function getSubmitTarget(form, submitter){',
|
||||
"var action=submitter&&submitter.getAttribute?submitter.getAttribute('formaction'):null;",
|
||||
'if(action)return normalizeUrl(action,PAGE_BASE_URL);',
|
||||
"return normalizeUrl((form&&form.getAttribute?form.getAttribute('action'):null)||PAGE_BASE_URL,PAGE_BASE_URL);",
|
||||
'}',
|
||||
'var lastSubmitter=null;',
|
||||
'if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",logInlineConfirmElements,{once:true});}else{logInlineConfirmElements();}',
|
||||
'if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",function(){logInlineConfirmElements();bindInlineConfirmElements();},{once:true});}else{logInlineConfirmElements();bindInlineConfirmElements();}',
|
||||
"document.addEventListener('click',function(event){",
|
||||
"var anchor=event.target&&event.target.closest?event.target.closest('a[href]'):null;",
|
||||
"var submitControl=event.target&&event.target.closest?event.target.closest('button, input[type=\"submit\"], input[type=\"image\"]'):null;",
|
||||
|
||||
@@ -86,7 +86,7 @@ class ClickTtPlayerRegistrationService {
|
||||
await this._clickByText(page, 'Personen suchen', trace);
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
|
||||
await this._abortIfConfirmFlow(page);
|
||||
await this._openApplicationAfterSearch(page, trace);
|
||||
await this._fillApplicationForm(page, memberJson, primaryEmail);
|
||||
await this._clickByText(page, 'Weiter >>', trace);
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
@@ -288,11 +288,41 @@ class ClickTtPlayerRegistrationService {
|
||||
await fillIfEmpty(13, email);
|
||||
}
|
||||
|
||||
async _abortIfConfirmFlow(page) {
|
||||
async _openApplicationAfterSearch(page, trace) {
|
||||
const explicitApplicationLink = page.getByText(/Spielberechtigung beantragen/i).first();
|
||||
if (await explicitApplicationLink.count()) {
|
||||
let dialogSeen = false;
|
||||
page.once('dialog', async (dialog) => {
|
||||
dialogSeen = true;
|
||||
this._trace(trace, 'dialog', {
|
||||
kind: dialog.type(),
|
||||
message: sanitizePageText(dialog.message())
|
||||
});
|
||||
await dialog.accept();
|
||||
});
|
||||
|
||||
this._trace(trace, 'step', {
|
||||
name: 'click',
|
||||
label: 'Spielberechtigung beantragen',
|
||||
selector: 'text=/Spielberechtigung beantragen/i'
|
||||
});
|
||||
await explicitApplicationLink.click();
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
|
||||
this._trace(trace, 'step', {
|
||||
name: 'search-result-application-opened',
|
||||
dialogSeen,
|
||||
url: page.url()
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmLocator = page.locator('[onclick*="confirm("]').first();
|
||||
if (await confirmLocator.count()) {
|
||||
const text = sanitizePageText(await confirmLocator.innerText().catch(() => '') || await confirmLocator.getAttribute('value').catch(() => '') || '');
|
||||
throw new HttpError(`Der Antrag befindet sich im noch nicht automatisierten click-TT-Confirm-/Neuanlage-Flow${text ? `: ${text}` : ''}`, 409);
|
||||
const text = sanitizePageText(
|
||||
await confirmLocator.innerText().catch(() => '') || await confirmLocator.getAttribute('value').catch(() => '') || ''
|
||||
);
|
||||
throw new HttpError(`Click-TT-Suchergebnis mit Confirm gefunden, aber kein klickbares Antragselement per Label erkannt${text ? `: ${text}` : ''}`, 409);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user