-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resourceEvaluation end and add refresh deck action
- Loading branch information
Showing
13 changed files
with
79 additions
and
69 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
18 changes: 0 additions & 18 deletions
18
src/plugin/flashcard/Resources/modules/resources/flashcard/editor/store/selectors.js
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,36 +1,18 @@ | ||
import get from 'lodash/get' | ||
import {createSelector} from 'reselect' | ||
|
||
import {selectors as formSelectors} from '#/main/app/content/form/store/selectors' | ||
import {selectors as baseSelectors} from '#/plugin/flashcard/resources/flashcard/store/selectors' | ||
|
||
|
||
const STORE_NAME = 'editor' | ||
const FORM_NAME = `${baseSelectors.STORE_NAME}.flashcardForm` | ||
|
||
const flashcardDeck = (state) => formSelectors.data(formSelectors.form(state, FORM_NAME)) | ||
|
||
const flashcardDeckId = createSelector( | ||
[flashcardDeck], | ||
(flashcardDeck) => flashcardDeck.id | ||
) | ||
|
||
const flashcardDeckType = createSelector( | ||
[flashcardDeck], | ||
(flashcardDeck) => get(flashcardDeck, 'parameters.type') | ||
) | ||
|
||
const cards = createSelector( | ||
[flashcardDeck], | ||
(flashcardDeck) => flashcardDeck.cards || [] | ||
) | ||
|
||
|
||
export const selectors = { | ||
STORE_NAME, | ||
FORM_NAME, | ||
|
||
flashcardDeckId, | ||
flashcardDeckType, | ||
cards | ||
} |
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
34 changes: 25 additions & 9 deletions
34
src/plugin/flashcard/Resources/modules/resources/flashcard/store/actions.js
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,23 +1,39 @@ | ||
import { API_REQUEST } from '#/main/app/api' | ||
import {makeActionCreator} from '#/main/app/store/actions' | ||
import {selectors} from '#/plugin/flashcard/resources/flashcard/store/selectors' | ||
|
||
import {actions as resourceActions} from '#/main/core/resource/store' | ||
|
||
export const FLASHCARD_GET_DECK = 'FLASHCARD_GET_DECK' | ||
export const FLASHCARD_UPDATE_PROGRESSION = 'FLASHCARD_UPDATE_PROGRESSION' | ||
|
||
export const actions = {} | ||
|
||
actions.updateProgressionProp = makeActionCreator(selectors.FLASHCARD_UPDATE_PROGRESSION, 'id', 'is_successful') | ||
actions.updateCardProgression = makeActionCreator(FLASHCARD_UPDATE_PROGRESSION, 'id', 'is_successful') | ||
actions.refreshDeckAction = makeActionCreator(FLASHCARD_GET_DECK, 'data') | ||
|
||
actions.updateUserProgression = (cardId, isSuccessful) => (dispatch) => dispatch({ | ||
actions.updateProgression = (cardId, isSuccessful, silent = true) => ({ | ||
[API_REQUEST]: { | ||
silent: true, | ||
url: ['apiv2_flashcard_progression_update', { | ||
id: cardId, | ||
isSuccessful: isSuccessful | ||
} ], | ||
silent: silent, | ||
url: ['apiv2_flashcard_progression_update', {id: cardId, isSuccessful: isSuccessful}], | ||
request: { | ||
method: 'PUT' | ||
}, | ||
success: (data, dispatch) => { | ||
dispatch(actions.updateProgressionProp(cardId, isSuccessful)) | ||
dispatch(resourceActions.updateUserEvaluation(data.userEvaluation)) | ||
dispatch(actions.updateCardProgression(cardId, isSuccessful)) | ||
} | ||
} | ||
}) | ||
|
||
actions.refreshDeck = (deckId, silent = true) => ({ | ||
[API_REQUEST]: { | ||
silent: silent, | ||
url: ['apiv2_flashcard_deck_get', {id: deckId}], | ||
request: { | ||
method: 'GET' | ||
}, | ||
success: (data, dispatch) => { | ||
dispatch(actions.refreshDeckAction(data)) | ||
} | ||
} | ||
}) |
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