-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some saving and loading from indexeddb. May want to rework so saving …
…happens in a centralized place that listens for rubric state changes. Also still need to save when a criteria is removed.
- Loading branch information
Showing
9 changed files
with
83 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
import { deleteRubric, saveRubric } from "../services/indexedDbService"; | ||
import { stateAndDispatch } from "../state"; | ||
import * as Actions from "../state/actions"; | ||
|
||
export function setRubricName(name: string) { | ||
const { dispatch } = stateAndDispatch(); | ||
dispatch(Actions.setRubricName(name)); | ||
} | ||
const { state: teacherTool, dispatch } = stateAndDispatch(); | ||
|
||
const oldName = teacherTool.rubric.name; | ||
|
||
if (oldName === name) { | ||
return; | ||
} | ||
|
||
const newRubric = { | ||
...teacherTool.rubric, | ||
name, | ||
} | ||
dispatch(Actions.setRubric(newRubric)); | ||
|
||
// To save the renamed rubric, we can simply save a version with the new name, | ||
// and then delete the entry with the previous name. | ||
async function saveRenamedRubric() { | ||
await saveRubric(newRubric); | ||
await deleteRubric(oldName); | ||
} | ||
|
||
// Fire and forget. We don't need to wait for the operation to finish. | ||
saveRenamedRubric(); | ||
} |
17 changes: 17 additions & 0 deletions
17
teachertool/src/transforms/tryLoadLastActiveRubricAsync.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { stateAndDispatch } from "../state"; | ||
import * as Actions from "../state/actions"; | ||
import { getLastActiveRubricAsync } from "../services/indexedDbService"; | ||
import { logDebug } from "../services/loggingService"; | ||
|
||
export async function tryLoadLastActiveRubricAsync() { | ||
const { dispatch } = stateAndDispatch(); | ||
|
||
const lastActiveRubric = await getLastActiveRubricAsync(); | ||
|
||
if (lastActiveRubric) { | ||
logDebug(`Loading last active rubric '${lastActiveRubric.name}'...`); | ||
dispatch(Actions.setRubric(lastActiveRubric)); | ||
} else { | ||
logDebug(`No last active rubric to load.`); | ||
} | ||
} |