|
2834 | 2834 | }); |
2835 | 2835 | document.getElementById("bulkEditModal").style.display = "none"; |
2836 | 2836 | renderResults(_cases, _ctx); |
| 2837 | + showToast(`Bulk update applied to ${ids.length} test case${ids.length === 1 ? "" : "s"}.`); |
2837 | 2838 | }); |
2838 | 2839 |
|
2839 | 2840 | // Bulk run modal |
|
2900 | 2901 | okCount++; |
2901 | 2902 | }); |
2902 | 2903 | document.getElementById("bulkRunModal").style.display = "none"; |
2903 | | - if (okCount > 0) showModal("Run Added", `Run cycle "${cycle}" added to ${okCount} case(s).`); |
| 2904 | + if (okCount > 0) showToast(`Run cycle "${cycle}" added to ${okCount} case${okCount === 1 ? "" : "s"}.`); |
2904 | 2905 | renderResults(_cases, _ctx); |
2905 | 2906 | }); |
2906 | 2907 |
|
|
3008 | 3009 |
|
3009 | 3010 | mo.style.display = "none"; |
3010 | 3011 | renderResults(_cases, _ctx); |
| 3012 | + const isNew = !iStr || iStr === "-1"; |
| 3013 | + showToast(isNew ? "Test case added successfully." : "Test case updated successfully."); |
3011 | 3014 | }); |
3012 | 3015 | ["editCaseModalClose", "editCaseModalCancel"].forEach((id) => |
3013 | 3016 | on(id, "click", () => { |
|
3073 | 3076 | }; |
3074 | 3077 | document.getElementById("editSuiteModal").style.display = "none"; |
3075 | 3078 | renderResults(_cases, _ctx); |
| 3079 | + showToast("Suite updated successfully."); |
3076 | 3080 | }); |
3077 | 3081 | ["editSuiteModalClose", "editSuiteModalCancel"].forEach((id) => |
3078 | 3082 | on(id, "click", () => { |
|
3105 | 3109 | } |
3106 | 3110 | document.getElementById("editPlanModal").style.display = "none"; |
3107 | 3111 | renderResults(_cases, _ctx); |
| 3112 | + showToast("Plan updated successfully."); |
3108 | 3113 | }); |
3109 | 3114 | ["editPlanModalClose", "editPlanModalCancel"].forEach((id) => |
3110 | 3115 | on(id, "click", () => { |
|
3842 | 3847 | document.getElementById("bulkModal").style.display = "block"; |
3843 | 3848 | } |
3844 | 3849 |
|
| 3850 | + /** |
| 3851 | + * Show a lightweight, auto-dismissing toast notification. |
| 3852 | + * @param {string} message – text to display |
| 3853 | + * @param {"success"|"error"|"info"} [type] – visual style (default: "success") |
| 3854 | + * @param {number} [duration] – ms before auto-dismiss (default: 3000) |
| 3855 | + */ |
| 3856 | + function showToast(message, type = "success", duration = 3000) { |
| 3857 | + // Inject styles once |
| 3858 | + if (!document.getElementById("qfg-toast-style")) { |
| 3859 | + const s = document.createElement("style"); |
| 3860 | + s.id = "qfg-toast-style"; |
| 3861 | + s.textContent = ` |
| 3862 | + #qfg-toast-container { |
| 3863 | + position: fixed; bottom: 28px; right: 28px; |
| 3864 | + display: flex; flex-direction: column; gap: 10px; |
| 3865 | + z-index: 99999; pointer-events: none; |
| 3866 | + } |
| 3867 | + .qfg-toast { |
| 3868 | + display: flex; align-items: center; gap: 10px; |
| 3869 | + padding: 12px 18px; border-radius: 10px; |
| 3870 | + font-size: .85rem; font-weight: 600; line-height: 1.4; |
| 3871 | + box-shadow: 0 6px 24px rgba(0,0,0,.18); |
| 3872 | + pointer-events: auto; cursor: default; |
| 3873 | + animation: qfgToastIn .25s cubic-bezier(.4,0,.2,1) forwards; |
| 3874 | + max-width: 340px; |
| 3875 | + } |
| 3876 | + .qfg-toast.qfg-toast-out { |
| 3877 | + animation: qfgToastOut .3s cubic-bezier(.4,0,.2,1) forwards; |
| 3878 | + } |
| 3879 | + .qfg-toast-success { background:#166534; color:#dcfce7; border-left:4px solid #4ade80; } |
| 3880 | + .qfg-toast-error { background:#7f1d1d; color:#fee2e2; border-left:4px solid #f87171; } |
| 3881 | + .qfg-toast-info { background:#1e3a5f; color:#dbeafe; border-left:4px solid #60a5fa; } |
| 3882 | + .qfg-toast-icon { font-size:1.1rem; flex-shrink:0; } |
| 3883 | + .qfg-toast-close { |
| 3884 | + margin-left:auto; background:none; border:none; cursor:pointer; |
| 3885 | + color:inherit; opacity:.7; font-size:.9rem; padding:0 2px; |
| 3886 | + flex-shrink:0; line-height:1; |
| 3887 | + } |
| 3888 | + .qfg-toast-close:hover { opacity:1; } |
| 3889 | + @keyframes qfgToastIn { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} } |
| 3890 | + @keyframes qfgToastOut { from{opacity:1;transform:translateY(0)} to{opacity:0;transform:translateY(16px)} } |
| 3891 | + `; |
| 3892 | + document.head.appendChild(s); |
| 3893 | + } |
| 3894 | + |
| 3895 | + // Ensure container exists |
| 3896 | + let container = document.getElementById("qfg-toast-container"); |
| 3897 | + if (!container) { |
| 3898 | + container = document.createElement("div"); |
| 3899 | + container.id = "qfg-toast-container"; |
| 3900 | + document.body.appendChild(container); |
| 3901 | + } |
| 3902 | + |
| 3903 | + const icons = { success: "✅", error: "❌", info: "ℹ️" }; |
| 3904 | + const toast = document.createElement("div"); |
| 3905 | + toast.className = `qfg-toast qfg-toast-${type}`; |
| 3906 | + toast.innerHTML = ` |
| 3907 | + <span class="qfg-toast-icon">${icons[type] || icons.success}</span> |
| 3908 | + <span>${message}</span> |
| 3909 | + <button class="qfg-toast-close" title="Dismiss">✕</button> |
| 3910 | + `; |
| 3911 | + |
| 3912 | + const dismiss = () => { |
| 3913 | + toast.classList.add("qfg-toast-out"); |
| 3914 | + toast.addEventListener("animationend", () => toast.remove(), { once: true }); |
| 3915 | + }; |
| 3916 | + toast.querySelector(".qfg-toast-close").addEventListener("click", dismiss); |
| 3917 | + container.appendChild(toast); |
| 3918 | + setTimeout(dismiss, duration); |
| 3919 | + } |
| 3920 | + |
3845 | 3921 | function closeModal() { |
3846 | 3922 | document.getElementById("bulkModal").style.display = "none"; |
3847 | 3923 | } |
|
0 commit comments