|
| 1 | +# Feature v0.9.7 Specification - Reset Zoom |
| 2 | + |
| 3 | +## Branch |
| 4 | +`feature/v0.9.7-reset-zoom` |
| 5 | + |
| 6 | +## Linked Issues |
| 7 | +- Fixes #60 |
| 8 | + |
| 9 | +## Overview |
| 10 | +Add a "Reset Zoom" button to the control bar that resets the zoom level to 100% (or viewport floor if larger). |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Feature: Reset Zoom Button |
| 15 | + |
| 16 | +### User Story |
| 17 | +As a user, I want to quickly reset the zoom to a standard view after zooming in/out, so I don't have to click multiple times to return to baseline. |
| 18 | + |
| 19 | +### Current Behavior |
| 20 | +- Zoom In/Out buttons adjust by ZOOM_STEP (5px) per click |
| 21 | +- No way to quickly return to baseline without multiple clicks |
| 22 | +- Each view mode maintains its own zoom level in `columnWidthByViewMode` |
| 23 | + |
| 24 | +### New Behavior |
| 25 | +- New "Reset" button appears left of "Zoom Out" |
| 26 | +- Clicking resets to `max(COLUMN_WIDTH_BASELINE, minColumnWidthByViewMode[currentViewMode])` |
| 27 | +- Zoom indicator updates immediately |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Fix Plan |
| 32 | + |
| 33 | +### Step 1: Add Reset Button HTML |
| 34 | +**File:** `webapps/gantt-chart/body.html` |
| 35 | + |
| 36 | +Add reset button before zoom-out button inside `.btn-group`: |
| 37 | + |
| 38 | +```html |
| 39 | +<button id="btn-zoom-reset" class="btn btn-icon" title="Reset Zoom to 100%" aria-label="Reset Zoom"> |
| 40 | + <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> |
| 41 | + <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/> |
| 42 | + <path d="M3 3v5h5"/> |
| 43 | + </svg> |
| 44 | +</button> |
| 45 | +``` |
| 46 | + |
| 47 | +### Step 2: Add Reset Button Event Handler |
| 48 | +**File:** `webapps/gantt-chart/app.js` |
| 49 | + |
| 50 | +In `setupControls()` function (around line 2290), add: |
| 51 | + |
| 52 | +```javascript |
| 53 | +const zoomResetBtn = document.getElementById('btn-zoom-reset'); |
| 54 | +if (zoomResetBtn) { |
| 55 | + zoomResetBtn.addEventListener('click', resetZoom); |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +### Step 3: Create resetZoom() Function |
| 60 | +**File:** `webapps/gantt-chart/app.js` |
| 61 | + |
| 62 | +Add new function after `adjustZoom()`: |
| 63 | + |
| 64 | +```javascript |
| 65 | +/** |
| 66 | + * Reset zoom to 100% or viewport floor (whichever is larger). |
| 67 | + * Uses the greater of COLUMN_WIDTH_BASELINE (75px) or the |
| 68 | + * calculated minimum for the current view mode. |
| 69 | + */ |
| 70 | +function resetZoom() { |
| 71 | + const viewFloor = minColumnWidthByViewMode[currentViewMode] || ABSOLUTE_FLOOR; |
| 72 | + const targetWidth = Math.max(COLUMN_WIDTH_BASELINE, viewFloor); |
| 73 | + const currentWidth = columnWidthByViewMode[currentViewMode] || COLUMN_WIDTH_BASELINE; |
| 74 | + |
| 75 | + if (targetWidth === currentWidth) { |
| 76 | + console.log('Zoom already at reset level:', targetWidth); |
| 77 | + return; |
| 78 | + } |
| 79 | + |
| 80 | + columnWidthByViewMode[currentViewMode] = targetWidth; |
| 81 | + ganttInstance.options.column_width = targetWidth; |
| 82 | + ganttInstance.change_view_mode(currentViewMode); |
| 83 | + updateZoomIndicator(); |
| 84 | + console.log('Zoom reset to:', targetWidth, '(' + Math.round((targetWidth / COLUMN_WIDTH_BASELINE) * 100) + '%) for', currentViewMode); |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +### Step 4: Version Bump |
| 89 | +**File:** `plugin.json` |
| 90 | + |
| 91 | +Change version from `"0.9.5"` to `"0.9.7"` |
| 92 | + |
| 93 | +--- |
| 94 | + |
| 95 | +## Files to Modify |
| 96 | + |
| 97 | +| File | Action | Description | |
| 98 | +|------|--------|-------------| |
| 99 | +| `webapps/gantt-chart/body.html` | Modify | Add reset button before zoom-out | |
| 100 | +| `webapps/gantt-chart/app.js` | Modify | Add resetZoom() function and event listener | |
| 101 | +| `plugin.json` | Modify | Version bump to 0.9.7 | |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +## Testing Checklist |
| 106 | +- [ ] Reset button appears left of Zoom Out button |
| 107 | +- [ ] Reset button has correct icon (circular arrow) |
| 108 | +- [ ] Reset button has tooltip "Reset Zoom to 100%" |
| 109 | +- [ ] Clicking reset at 150% zoom returns to 100% |
| 110 | +- [ ] Clicking reset at 50% zoom returns to 100% |
| 111 | +- [ ] If viewport floor > 100%, reset goes to floor instead |
| 112 | +- [ ] Zoom indicator shows correct percentage after reset |
| 113 | +- [ ] Reset works independently per view mode (Week, Month, etc.) |
| 114 | +- [ ] Dark mode styling works correctly |
| 115 | +- [ ] Button hover states work |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## User QA Gate |
| 120 | + |
| 121 | +**CRITICAL: Code must be committed BEFORE User QA.** |
| 122 | + |
| 123 | +**Pre-QA Commit Process:** |
| 124 | +1. After implementing the fix, commit with message: |
| 125 | + ``` |
| 126 | + feat(v0.9.7): Add Reset Zoom button (#60) |
| 127 | +
|
| 128 | + Adds a Reset button to the zoom controls that returns zoom to 100% |
| 129 | + (or viewport floor if larger). Button placed left of Zoom Out. |
| 130 | +
|
| 131 | + Changes: |
| 132 | + - body.html: Add reset button with circular arrow icon |
| 133 | + - app.js: Add resetZoom() function and event listener |
| 134 | + - plugin.json: Version bump to 0.9.7 |
| 135 | +
|
| 136 | + Fixes #60 |
| 137 | + ``` |
| 138 | + |
| 139 | +2. Verify commit: `git log --oneline -1` |
| 140 | +3. Notify user that code is ready for QA |
| 141 | + |
| 142 | +**QA Script for User:** |
| 143 | +``` |
| 144 | +1. Reload plugin in Dataiku (Actions menu → Reload) |
| 145 | +2. Open a Gantt chart with tasks |
| 146 | +3. Verify Reset button appears left of "−" (Zoom Out) button |
| 147 | +4. Hover over Reset button - confirm tooltip shows "Reset Zoom to 100%" |
| 148 | +5. Click Zoom In several times to reach 150%+ |
| 149 | +6. Click Reset - confirm zoom returns to 100% |
| 150 | +7. Click Zoom Out several times to reach 50% |
| 151 | +8. Click Reset - confirm zoom returns to 100% |
| 152 | +9. Switch to Month view, zoom to 200% |
| 153 | +10. Switch back to Week view - confirm Week's zoom was independent |
| 154 | +11. In Week view, click Reset - confirm it resets Week view |
| 155 | +12. Switch to Month view - confirm it still shows 200% |
| 156 | +13. (If dark mode) Toggle dark mode and verify button styling |
| 157 | +``` |
| 158 | + |
| 159 | +**Do not proceed to PR/merge until user confirms the fix works.** |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## Rollback Plan |
| 164 | +Revert the commit: `git revert HEAD` |
| 165 | + |
| 166 | +--- |
| 167 | + |
| 168 | +## Watch Out For |
| 169 | +- Button order: Reset must be BEFORE Zoom Out in HTML for correct visual order |
| 170 | +- SVG icon: Use inline SVG (FontAwesome classes don't work in Dataiku webapp context) |
| 171 | +- Per-view zoom: Each view mode has independent zoom - reset only affects current view |
0 commit comments