Standard collaboration patterns for all squad agents — worktree awareness, decisions, cross-agent communication
日本語の概要は準備中です。原文の説明を表示しています。
Frontend JavaScript patterns for event handling, form UX, and validation integration
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Applicable to: Web layer JavaScript (site.js, page-specific scripts)
Last Updated: 2026-04-11
Maintainer: Sparks (Frontend Developer)
When writing event listeners that conditionally block browser default behavior, always accept the event parameter and call preventDefault() before early returns.
❌ WRONG:
form.addEventListener('submit', function () {
if (someCondition) return; // ⚠️ Form still submits!
// ... handler logic
});
✅ CORRECT:
form.addEventListener('submit', function (event) {
if (someCondition) {
event.preventDefault(); // ✅ Form submission blocked
return;
}
// ... handler logic
});
preventDefault() don't stop the browser's default actionThe project's global form submit handler (site.js) implements double-submit prevention. IMPORTANT: Use button click event, NOT form submit event, to prevent race conditions.
❌ WRONG - Race Condition:
form.addEventListener('submit', function (event) {
if (btn.disabled) {
event.preventDefault();
return;
}
btn.disabled = true; // ⚠️ Too late! Second click already queued submit event
});
✅ CORRECT - Click Event:
btn.addEventListener('click', function (event) {
if (btn.disabled) {
event.preventDefault(); // Block if already disabled
return;
}
// Check client validation BEFORE disabling
if (typeof $ !== 'undefined' && $(form).valid && !$(form).valid()) {
return; // Let validation run, don't disable
}
btn.disabled = true; // Disable immediately on first click
btn.innerHTML = '<span>...</span>Saving...'; // Visual feedback
});
Why Click Event Prevents Race:
Key Points:
invalid-form.validate eventUse Bootstrap spinner for loading states:
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>Saving...';
Store original button HTML to restore on error:
btn.dataset.originalHtml = btn.innerHTML; // Save before change
// ... later, on error:
btn.innerHTML = btn.dataset.originalHtml; // Restore
delete btn.dataset.originalHtml;
The project uses jQuery Unobtrusive Validation. Listen for validation failures to reset button state:
$(form).on('invalid-form.validate', function () {
// Restore button if it was disabled for submit
if (btn.dataset.originalHtml) {
btn.innerHTML = btn.dataset.originalHtml;
delete btn.dataset.originalHtml;
btn.disabled = false;
}
});
JosephGuadagno.Broadcasting.Web/wwwroot/js/site.js.squad/decisions/inbox/switch-real-fix-708.md (2026-04-13)When a controller POST action has simple-type parameters (int, string, guid) that are NOT properties of the ViewModel, those parameters MUST be included in the route. Without them, ASP.NET Core routing cannot match the action, causing HTTP 400 Bad Request.
❌ WRONG:
@model EngagementSocialMediaPlatformViewModel
<!-- Missing route parameter - causes 400 error! -->
<form asp-action="AddPlatform" method="post">
<input type="hidden" asp-for="EngagementId" />
<!-- ... -->
</form>
Controller:
[HttpPost]
public async Task<IActionResult> AddPlatform(int engagementId, EngagementSocialMediaPlatformViewModel vm)
{
// ⚠️ Form POSTs to /Engagements/AddPlatform (no engagementId in route)
// ⚠️ ASP.NET Core expects route like /Engagements/AddPlatform/5
// ⚠️ Route doesn't match → HTTP 400
}
✅ CORRECT:
@model EngagementSocialMediaPlatformViewModel
<!-- Route parameter required for action matching -->
<form asp-action="AddPlatform" asp-route-engagementId="@Model.EngagementId" method="post">
<input type="hidden" asp-for="EngagementId" />
<!-- ... -->
</form>
Controller:
[HttpPost]
public async Task<IActionResult> AddPlatform(int engagementId, EngagementSocialMediaPlatformViewModel vm)
{
// ✅ Form POSTs to /Engagements/AddPlatform/5
// ✅ Route matches action signature
// ✅ engagementId = 5 (from route), vm.EngagementId = 5 (from POST body)
}
Having BOTH asp-route-X and a matching ViewModel property is NOT a conflict:
Use route parameters (asp-route-*) when:
Action(int id, ViewModelType model)Use model properties (hidden fields) when:
vm.EngagementId used to verify data integrityUse BOTH when:
Action(int routeParam, ViewModelType vm) where vm has a property matching routeParam.squad/decisions/inbox/sparks-708-route-parameter-correction.md (SUPERSEDES previous incorrect decision)JosephGuadagno.Broadcasting.Web/Views/Engagements/AddPlatform.cshtmlまだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Standard collaboration patterns for all squad agents — worktree awareness, decisions, cross-agent communication
日本語の概要は準備中です。原文の説明を表示しています。
Shared hard rules enforced across all squad agents
日本語の概要は準備中です。原文の説明を表示しています。
Comprehensive AI prompt engineering safety review and improvement prompt. Analyzes prompts for safety, bias, security vulnerabilities, and effectiveness while providing detailed improvement recommendations with extensive frameworks, testing methodologies, and educational content.
日本語の概要は準備中です。原文の説明を表示しています。
Migrate API controller scope checks to framework-enforced authorization policies while preserving ownership checks.
日本語の概要は準備中です。原文の説明を表示しています。
Review API DTO implementations for contract/domain separation, mapping patterns, and REST compliance
日本語の概要は準備中です。原文の説明を表示しています。
Register shared claims transformation and hierarchical role policies in the API without breaking existing scope enforcement.
日本語の概要は準備中です。原文の説明を表示しています。