Skip to content

Commit

Permalink
Perspective view: sort by meaning by default regression #1089
Browse files Browse the repository at this point in the history
  • Loading branch information
myrix committed Dec 13, 2023
1 parent e8b3e27 commit 79f1c58
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/components/CorporaView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import { openModal } from "ducks/modals";
import {
addLexicalEntry,
resetEntriesSelection,
resetSortByField,
resetOrderedSortByField,
selectLexicalEntry,
setSortByField
setOrderedSortByField
} from "ducks/perspective";
import TranslationContext from "Layout/TranslationContext";
import { compositeIdToString as id2str } from "utils/compositeId";
Expand Down Expand Up @@ -1006,18 +1006,18 @@ P.defaultProps = {

const PerspectiveView = compose(
connect(
({ user, perspective: { sortByField, createdEntries, selectedEntries } }) => ({
({ user, perspective: { orderedSortByField, createdEntries, selectedEntries } }) => ({
user,
sortByField,
sortByField: orderedSortByField,
createdEntries,
selectedEntries
}),
dispatch =>
bindActionCreators(
{
addLexicalEntry,
setSortByField,
resetSortByField,
setSortByField: setOrderedSortByField,
resetSortByField: resetOrderedSortByField,
selectLexicalEntry,
resetEntriesSelection,
openModal
Expand Down
24 changes: 23 additions & 1 deletion src/ducks/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export const SET = "@data/perspective/SET";
export const SET_FILTER = "@data/perspective/SET_FILTER";
export const SET_SORT_MODE = "@data/perspective/SET_SORT_MODE";
export const RESET_SORT_MODE = "@data/perspective/RESET_SORT_MODE";
export const SET_ORDERED_SORT_MODE = "@data/perspective/SET_ORDERED_SORT_MODE";
export const RESET_ORDERED_SORT_MODE = "@data/perspective/RESET_ORDERED_SORT_MODE";
export const ADD_LEXICAL_ENTRY = "@data/perspective/ADD_LEXICAL_ENTRY";
export const SELECT_LEXICAL_ENTRY = "@data/perspective/SELECT_LEXICAL_ENTRY";
export const RESET_ENTRIES_SELECTION = "@data/perspective/RESET_ENTRIES_SELECTION";
Expand All @@ -30,7 +32,7 @@ function filter(state = "", action = {}) {
}
}

function sortByField(state = { field: null, order: "a" }, { type, payload }) {
function sortByField(state = { field: [66, 10], order: "a" }, { type, payload }) {
switch (type) {
case SET_SORT_MODE:
return payload;
Expand All @@ -41,6 +43,17 @@ function sortByField(state = { field: null, order: "a" }, { type, payload }) {
}
}

function orderedSortByField(state = { field: null, order: "a" }, { type, payload }) {
switch (type) {
case SET_ORDERED_SORT_MODE:
return payload;
case RESET_ORDERED_SORT_MODE:
return null;
default:
return state;
}
}

function createdEntries(state = [], { type, payload }) {
switch (type) {
case ADD_LEXICAL_ENTRY:
Expand All @@ -65,6 +78,7 @@ export default combineReducers({
params,
filter,
sortByField,
orderedSortByField,
createdEntries,
selectedEntries
});
Expand Down Expand Up @@ -97,6 +111,14 @@ export function resetSortByField() {
return { type: RESET_SORT_MODE, payload: null };
}

export function setOrderedSortByField(field, order) {
return { type: SET_ORDERED_SORT_MODE, payload: { field, order } };
}

export function resetOrderedSortByField() {
return { type: RESET_ORDERED_SORT_MODE, payload: null };
}

export function addLexicalEntry(entry) {
return { type: ADD_LEXICAL_ENTRY, payload: entry };
}
Expand Down

0 comments on commit 79f1c58

Please sign in to comment.