Permalink
Browse files

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
  • Loading branch information...
trvrfrd authored and paglias committed Oct 15, 2018
1 parent 074837b commit 5f27bc5f90677c05857d87446be2da8e364c689b
Showing with 27 additions and 22 deletions.
  1. +27 −22 website/client/components/shops/market/equipmentSection.vue
@@ -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 result = this.filterGearItems();
let selectedSortKey = sortGearTypeMap[this.selectedSortGearBy.id];
let sortingByStat = selectedSortKey !== 'type' && selectedSortKey !== 'value';
let order = sortingByStat ? 'desc' : 'asc';
// 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;
let result = _filter(category[0].items, (gear) => {
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 () {

0 comments on commit 5f27bc5

Please sign in to comment.