Pass tag names to tagsSorter instead of taggedOperations values
This commit is contained in:
@@ -202,12 +202,14 @@ export const operationsWithTags = createSelector(
|
|||||||
|
|
||||||
export const taggedOperations = (state) => ({ getConfigs }) => {
|
export const taggedOperations = (state) => ({ getConfigs }) => {
|
||||||
let { tagsSorter, operationsSorter } = getConfigs()
|
let { tagsSorter, operationsSorter } = getConfigs()
|
||||||
|
|
||||||
return operationsWithTags(state)
|
return operationsWithTags(state)
|
||||||
.sort((operationA, operationB) => {
|
.sortBy(
|
||||||
|
(val, key) => key, // get the name of the tag to be passed to the sorter
|
||||||
|
(tagA, tagB) => {
|
||||||
let sortFn = (typeof tagsSorter === "function" ? tagsSorter : sorters.tagsSorter[ tagsSorter ])
|
let sortFn = (typeof tagsSorter === "function" ? tagsSorter : sorters.tagsSorter[ tagsSorter ])
|
||||||
return (!sortFn ? null : sortFn(operationA, operationB))
|
return (!sortFn ? null : sortFn(tagA, tagB))
|
||||||
})
|
}
|
||||||
|
)
|
||||||
.map((ops, tag) => {
|
.map((ops, tag) => {
|
||||||
let sortFn = (typeof operationsSorter === "function" ? operationsSorter : sorters.operationsSorter[ operationsSorter ])
|
let sortFn = (typeof operationsSorter === "function" ? operationsSorter : sorters.operationsSorter[ operationsSorter ])
|
||||||
let operations = (!sortFn ? ops : ops.sort(sortFn))
|
let operations = (!sortFn ? ops : ops.sort(sortFn))
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ export const sorters = {
|
|||||||
method: (a, b) => a.get("method").localeCompare(b.get("method"))
|
method: (a, b) => a.get("method").localeCompare(b.get("method"))
|
||||||
},
|
},
|
||||||
tagsSorter: {
|
tagsSorter: {
|
||||||
alpha: (a, b) => a.getIn([0, "operation", "tags", 0]).localeCompare(b.getIn([0, "operation", "tags", 0]))
|
alpha: (a, b) => a.localeCompare(b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user