this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fixes

alice d29bdc4e 3b9f7b3d

+21 -44
+5 -5
index.html
··· 13 13 <div id="global-controls"> 14 14 <button id="undoBtn" disabled>Undo</button> 15 15 <button id="redoBtn" disabled>Redo</button> 16 - <button id="clearStorageBtn">Clear Storage</button> 17 - <button id="useLimitedValuesBtn">Use 8 Values (Default)</button> 16 + <button id="clearStorageBtn">Restart exercise</button> 17 + <button id="useLimitedValuesBtn">Use 10 Values (default, for testing)</button> 18 18 <button id="useAllValuesBtn">Use All Values</button> 19 19 </div> 20 20 </header> ··· 66 66 <div id="part2-notImportantContainer" class="card-container"></div> 67 67 </div> 68 68 </div> 69 - <button id="backToPart1">Back</button> 69 + <!-- <button id="backToPart1">Back</button> --> 70 70 <button id="toPart3">Next</button> 71 71 </section> 72 72 ··· 83 83 <div class="card-container" id="additionalContainer"></div> 84 84 </div> 85 85 </div> 86 - <button id="backToPart2">Back</button> 86 + <!-- <button id="backToPart2">Back</button> --> 87 87 <button id="toPart4">Next</button> 88 88 </section> 89 89 ··· 92 92 <h2>Part 4: Final Statements</h2> 93 93 <div id="finalStatements"></div> 94 94 <button id="finish">Finish</button> 95 - <button id="backToPart3">Back</button> 95 + <!-- <button id="backToPart3">Back</button> --> 96 96 </section> 97 97 98 98 <!-- Review/Export Page -->
+2 -2
index.test.ts
··· 4 4 import { describe, test, expect, beforeEach } from "bun:test"; 5 5 import { ALL_VALUE_DEFINITIONS, LIMITED_VALUE_DEFINITIONS, VALUES } from "./values"; // Import value counts for tests 6 6 const ALL_VALUES_COUNT = VALUES.length; 7 - const LIMITED_VALUES_COUNT = 8; 7 + const LIMITED_VALUES_COUNT = 10; 8 8 9 9 // Mock necessary DOM elements and event listeners 10 10 beforeEach(() => { ··· 250 250 expect(Object.keys(newState.finalStatements).length).toBe(0); // Statements cleared 251 251 }); 252 252 253 - test('Clicking "Use 8 Values" switches set back and resets state', () => { 253 + test('Clicking "Use 10 Values" switches set back and resets state', () => { 254 254 // Arrange: Start, switch to All using direct call 255 255 // const buttonAll = document.getElementById('useAllValuesBtn'); 256 256 // buttonAll?.click(); // Replace click simulation
+14 -37
index.ts
··· 20 20 import { UndoManager } from './undoManager'; 21 21 // Import the original VALUES array 22 22 import { VALUES } from './values'; 23 - import { debounce } from 'lodash'; // Import debounce from lodash 23 + // Import debounce and the necessary type from lodash 24 + import { debounce } from 'lodash'; 25 + import type { DebouncedFunc } from 'lodash'; // Use type-only import 24 26 25 27 // Define the structure based on the imported VALUES 26 28 interface ValueDefinition { ··· 30 32 31 33 // Recreate ALL_VALUES and LIMITED_VALUES based on the import 32 34 const ALL_VALUE_DEFINITIONS: ValueDefinition[] = VALUES; 33 - const LIMITED_VALUE_DEFINITIONS = ALL_VALUE_DEFINITIONS.slice(0, 8); 35 + const LIMITED_VALUE_DEFINITIONS = ALL_VALUE_DEFINITIONS.slice(0, 10); 34 36 35 37 // Create a global map for easy description lookup 36 38 const valueDefinitionsMap = new Map<string, string>( ··· 42 44 private state: AppState; 43 45 public undoManager: UndoManager<AppState>; 44 46 private storageKey: string = "valuesExerciseState"; 45 - // Re-add the property to hold the debounced function 46 - private debouncedUpdateFinalStatement: (cardId: number, value: string) => void; 47 + // Update type annotation to use DebouncedFunc 48 + private debouncedUpdateFinalStatement: DebouncedFunc<(cardId: number, value: string) => void>; 47 49 48 50 constructor() { 49 51 // Load state from localStorage or initialize default state. ··· 137 139 .map(card => ({ ...card, column: "unassigned" })); 138 140 this.updateState(newState); // Call updateState directly 139 141 }); 140 - document.getElementById("backToPart1")?.addEventListener("click", () => { 141 - // Simply undo the last state change 142 - const prevState = this.undoManager.undo(); 143 - if (prevState) { 144 - this.state = prevState; 145 - this.saveState(); 146 - this.render(); 147 - this.updateUndoRedoButtons(); 148 - } 149 - }); 150 142 document.getElementById("toPart3")?.addEventListener("click", () => { 151 143 const newState = this.undoManager.getState(); 152 144 // Check for unassigned cards before proceeding ··· 168 160 169 161 this.updateState(newState); // Call updateState directly 170 162 }); 171 - document.getElementById("backToPart2")?.addEventListener("click", () => { 172 - // Simply undo the last state change 173 - const prevState = this.undoManager.undo(); 174 - if (prevState) { 175 - this.state = prevState; 176 - this.saveState(); 177 - this.render(); 178 - this.updateUndoRedoButtons(); 179 - } 180 - }); 181 163 document.getElementById("toPart4")?.addEventListener("click", () => { 182 164 const newState = this.undoManager.getState(); 183 165 const coreCount = newState.cards.filter((c) => c.column === "core").length; ··· 188 170 newState.currentPart = "part4"; 189 171 this.updateState(newState); // Call updateState directly 190 172 }); 191 - document.getElementById("backToPart3")?.addEventListener("click", () => { 192 - // Simply undo the last state change 193 - const prevState = this.undoManager.undo(); 194 - if (prevState) { 195 - this.state = prevState; 196 - this.saveState(); 197 - this.render(); 198 - this.updateUndoRedoButtons(); 199 - } 200 - }); 201 173 document.getElementById("finish")?.addEventListener("click", () => { 174 + // Flush any pending debounced updates immediately 175 + this.debouncedUpdateFinalStatement.flush(); 176 + 202 177 const newState = this.undoManager.getState(); 203 178 // Check if all core values have statements 204 179 const coreCards = newState.cards.filter(c => c.column === 'core'); ··· 258 233 } 259 234 }); 260 235 261 - // Clear storage button 236 + // Clear storage button (renamed to Restart exercise) 262 237 document.getElementById("clearStorageBtn")?.addEventListener("click", () => { 263 - if (confirm("Are you sure you want to clear all saved data? This action cannot be undone.")) { 238 + // Update confirmation message 239 + if (confirm("Are you sure you want to restart the exercise? All progress will be lost. This action cannot be undone.")) { 264 240 localStorage.removeItem(this.storageKey); 265 - const newState = this.defaultState(); 241 + // Reset to the default state using the *current* value set preference 242 + const newState = this.defaultState(this.state.valueSet); 266 243 this.updateState(newState); 267 244 } 268 245 });