mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
Merge branch 'mattstauffer-case-insensitive-order'
This commit is contained in:
commit
73b5c89a85
2 changed files with 25 additions and 1 deletions
|
@ -182,6 +182,30 @@
|
|||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Modified version of orderBy that is case insensitive
|
||||
*
|
||||
* @source https://github.com/vuejs/vue/blob/dev/src/filters/array-filters.js
|
||||
*/
|
||||
Vue.filter('caseInsensitiveOrderBy', (arr, sortKey, reverse) => {
|
||||
if (!sortKey) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
var order = (reverse && reverse < 0) ? -1 : 1
|
||||
|
||||
// sort on a copy to avoid mutating original array
|
||||
return arr.slice().sort((a, b) => {
|
||||
a = Vue.util.isObject(a) ? Vue.parsers.path.getPath(a, sortKey) : a
|
||||
b = Vue.util.isObject(b) ? Vue.parsers.path.getPath(b, sortKey) : b
|
||||
|
||||
a = a === undefined ? a : a.toLowerCase()
|
||||
b = b === undefined ? b : b.toLowerCase()
|
||||
|
||||
return a === b ? 0 : a > b ? order : -order
|
||||
});
|
||||
});
|
||||
|
||||
// Register the global directives
|
||||
Vue.directive('koel-focus', require('./directives/focus'));
|
||||
</script>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<tbody>
|
||||
<tr
|
||||
v-for="item in items
|
||||
| orderBy sortKey order
|
||||
| caseInsensitiveOrderBy sortKey order
|
||||
| filterBy q in 'title' 'album.name' 'album.artist.name'
|
||||
| limitBy numOfItems"
|
||||
is="song-item"
|
||||
|
|
Loading…
Reference in a new issue