mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-20 18:54:13 +00:00
Issue 10728: sort equipment by stat descending on Market page (#10734)
* sort equipment by stat descending in Market (issue #10728) * fix sorting equipment by PER in Market (new issue?) * move filter logic into method when sorting equipment in Market * consolidate sorting in sortedGearItems() into one _orderBy call
This commit is contained in:
parent
074837b274
commit
5f27bc5f90
1 changed files with 28 additions and 23 deletions
|
|
@ -62,7 +62,7 @@ layout-section(:title="$t('equipment')")
|
|||
import svgHealer from 'assets/svg/healer.svg';
|
||||
|
||||
import _filter from 'lodash/filter';
|
||||
import _sortBy from 'lodash/sortBy';
|
||||
import _orderBy from 'lodash/orderBy';
|
||||
import pinUtils from '../../../mixins/pinUtils';
|
||||
|
||||
const sortGearTypes = ['sortByType', 'sortByPrice', 'sortByCon', 'sortByPer', 'sortByStr', 'sortByInt'].map(g => ({id: g}));
|
||||
|
|
@ -71,6 +71,7 @@ layout-section(:title="$t('equipment')")
|
|||
sortByType: 'type',
|
||||
sortByPrice: 'value',
|
||||
sortByCon: 'con',
|
||||
sortByPer: 'per',
|
||||
sortByStr: 'str',
|
||||
sortByInt: 'int',
|
||||
};
|
||||
|
|
@ -116,9 +117,33 @@ layout-section(:title="$t('equipment')")
|
|||
return this.marketGearCategories.filter(c => c.id === this.selectedGroupGearByClass)[0];
|
||||
},
|
||||
sortedGearItems () {
|
||||
let category = _filter(this.marketGearCategories, ['identifier', this.selectedGroupGearByClass]);
|
||||
let result = this.filterGearItems();
|
||||
let selectedSortKey = sortGearTypeMap[this.selectedSortGearBy.id];
|
||||
let sortingByStat = selectedSortKey !== 'type' && selectedSortKey !== 'value';
|
||||
let order = sortingByStat ? 'desc' : 'asc';
|
||||
|
||||
let result = _filter(category[0].items, (gear) => {
|
||||
// split into unlocked and locked, then apply selected sort
|
||||
return _orderBy(result, ['locked', selectedSortKey], ['asc', order]);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getClassName (classType) {
|
||||
if (classType === 'wizard') {
|
||||
return this.$t('mage');
|
||||
} else {
|
||||
return this.$t(classType);
|
||||
}
|
||||
},
|
||||
gearSelected (item) {
|
||||
if (!item.locked) {
|
||||
this.$root.$emit('buyModal::showItem', item);
|
||||
}
|
||||
},
|
||||
filterGearItems () {
|
||||
let category = _filter(this.marketGearCategories, ['identifier', this.selectedGroupGearByClass]);
|
||||
let items = category[0].items;
|
||||
|
||||
return _filter(items, (gear) => {
|
||||
if (this.hideLocked && gear.locked) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -136,26 +161,6 @@ layout-section(:title="$t('equipment')")
|
|||
// hide already owned
|
||||
return !this.userItems.gear.owned[gear.key];
|
||||
});
|
||||
|
||||
// first all unlocked
|
||||
// then the selected sort
|
||||
result = _sortBy(result, [(item) => item.locked, sortGearTypeMap[this.selectedSortGearBy.id]]);
|
||||
|
||||
return result;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getClassName (classType) {
|
||||
if (classType === 'wizard') {
|
||||
return this.$t('mage');
|
||||
} else {
|
||||
return this.$t(classType);
|
||||
}
|
||||
},
|
||||
gearSelected (item) {
|
||||
if (!item.locked) {
|
||||
this.$root.$emit('buyModal::showItem', item);
|
||||
}
|
||||
},
|
||||
},
|
||||
created () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue