Adding apisSorter options, taking a string or a function as a configuration value

This commit is contained in:
Raphaël MARQUES
2017-06-27 15:29:07 +02:00
parent 96673d1376
commit 4fe27786f4
5 changed files with 67 additions and 53 deletions

View File

@@ -197,16 +197,21 @@ export const operationsWithTags = createSelector(
}
)
export const taggedOperations = ( state ) =>( { getConfigs } ) => {
let { operationsSorter }= getConfigs()
export const taggedOperations = (state) => ({ getConfigs }) => {
let { apisSorter, operationsSorter } = getConfigs();
return operationsWithTags(state).map((ops, tag) => {
let sortFn = typeof operationsSorter === "function" ? operationsSorter
: sorters.operationsSorter[operationsSorter]
let operations = !sortFn ? ops : ops.sort(sortFn)
return operationsWithTags(state)
.sort((operationA, operationB) => {
let sortFn = (typeof apisSorter === "function" ? apisSorter : sorters.apisSorter[ apisSorter ]);
return (!sortFn ? null : sortFn(operationA, operationB));
})
.map((ops, tag) => {
let sortFn = (typeof operationsSorter === "function" ? operationsSorter : sorters.operationsSorter[ operationsSorter ]);
let operations = (!sortFn ? ops : ops.sort(sortFn));
return Map({tagDetails: tagDetails(state, tag), operations: operations})})
}
return Map({ tagDetails: tagDetails(state, tag), operations: operations });
});
};
export const responses = createSelector(
state,