Added sort by tier and filter to current tier
This commit is contained in:
parent
f737f48545
commit
b9c2d479b7
|
@ -21,6 +21,9 @@ $pokemon-list-height = 50px
|
|||
margin-bottom 0!important
|
||||
width 100%
|
||||
|
||||
.filter-tier-box
|
||||
width 25px
|
||||
|
||||
.teambuilder .meta-info
|
||||
max-width 1368px
|
||||
|
||||
|
|
|
@ -26,9 +26,11 @@ class @PokemonEditView extends Backbone.View
|
|||
speciesTemplate: JST['teambuilder/species']
|
||||
nonStatsTemplate: JST['teambuilder/non_stats']
|
||||
movesTemplate: JST['teambuilder/moves']
|
||||
tierFilterBool: true
|
||||
|
||||
events:
|
||||
'change .sortSpecies': 'changeSort'
|
||||
'change .filter-tier': 'filterTier'
|
||||
'change .species_list': 'changeSpecies'
|
||||
'change .selected_nickname': 'changeNickname'
|
||||
'click .selected_shininess': 'changeShiny'
|
||||
|
@ -61,10 +63,41 @@ class @PokemonEditView extends Backbone.View
|
|||
@setGeneration(format.generation)
|
||||
# TODO: Set PBV limit based on conditions
|
||||
|
||||
filterTier:(e) =>
|
||||
thistier = @pokemon.getTeam().getTier().tierRank
|
||||
{SpeciesData, FormeData} = @generation
|
||||
if e.target.checked
|
||||
arr = @objectToArr(SpeciesData)
|
||||
console.log(thistier)
|
||||
for obj in arr
|
||||
obj.tier = window.PokeBattle.Tier.Tiers[FormeData[obj.pokename].default.tier[0]].tierRank
|
||||
console.log(arr)
|
||||
arr = _.filter arr, (thing) -> thing.tier is thistier
|
||||
obj = @arrToObject(arr)
|
||||
@speciesList = (species for species, data of obj)
|
||||
@render()
|
||||
else
|
||||
@speciesList = (species for species, data of SpeciesData)
|
||||
@render()
|
||||
|
||||
|
||||
objectToArr: (data) =>
|
||||
arr = []
|
||||
for key, val of data
|
||||
val.pokename = key
|
||||
arr.push(val)
|
||||
return arr
|
||||
|
||||
arrToObject: (arr) =>
|
||||
obj = {}
|
||||
for thing in arr
|
||||
obj[thing.pokename] = thing
|
||||
return obj
|
||||
|
||||
changeSort:(e) =>
|
||||
sort = $(e.currentTarget).val()
|
||||
if sort =="Default Sort"
|
||||
@sortSpecieslist("Default")
|
||||
if sort == "Sort"
|
||||
@sortSpecieslist("tier", false)
|
||||
else if sort == "Sort by Dexnumber"
|
||||
@sortSpecieslist("id", false)
|
||||
else if sort == "Invert by Dexnumber"
|
||||
|
@ -73,7 +106,10 @@ class @PokemonEditView extends Backbone.View
|
|||
@sortSpecieslist("pokename", false)
|
||||
else if sort == "Invert Alphabetically"
|
||||
@sortSpecieslist("pokename", true)
|
||||
|
||||
else if sort == "Sort by Tier"
|
||||
@sortSpecieslist("tier", false)
|
||||
else if sort == "Invert by Tier"
|
||||
@sortSpecieslist("tier", true)
|
||||
|
||||
sortSpecieslist: (option, reverse) =>
|
||||
{MoveData, SpeciesData, ItemData} = @generation
|
||||
|
@ -85,17 +121,18 @@ class @PokemonEditView extends Backbone.View
|
|||
@render()
|
||||
|
||||
sortObject: (data, option, reverse) ->
|
||||
arr = []
|
||||
for key, val of data
|
||||
val.pokename = key
|
||||
arr.push(val)
|
||||
arr = _.sortBy(arr, option)
|
||||
arr = @objectToArr(data)
|
||||
if option != 'tier'
|
||||
arr = _.sortBy(arr, option)
|
||||
else
|
||||
{FormeData} = @generation
|
||||
for obj in arr
|
||||
obj.tier = window.PokeBattle.Tier.Tiers[FormeData[obj.pokename].default.tier[0]].tierRank
|
||||
arr = _.sortBy(arr, 'tier')
|
||||
if reverse == true
|
||||
arr.reverse()
|
||||
newobj = {}
|
||||
for thing in arr
|
||||
newobj[thing.pokename] = thing
|
||||
finished = newobj
|
||||
obj = @arrToObject(arr)
|
||||
finished = obj
|
||||
|
||||
setGeneration: (generation) =>
|
||||
@generation = window.Generations[generation.toUpperCase()]
|
||||
|
@ -387,6 +424,13 @@ class @PokemonEditView extends Backbone.View
|
|||
return "<div class='clearfix'>#{item.text}<div class='tier'>#{tier.humanName}</div></div>"
|
||||
)
|
||||
attachSelectize(@$el.find(".selected_item"))
|
||||
filtertierbox = @$el.find(".filter-tier-box")[0]
|
||||
if @tierFilterBool is false
|
||||
filtertierbox.checked = true
|
||||
@tierFilterBool = true
|
||||
else if @tierFilterBool is true
|
||||
filtertierbox.checked = false
|
||||
@tierFilterBool = false
|
||||
return this
|
||||
|
||||
renderPokemon: =>
|
||||
|
|
|
@ -14,12 +14,17 @@ mixin printStat(statName, keyName)
|
|||
.meta-info.clearfix
|
||||
.left-side
|
||||
.species
|
||||
label.filter-tier
|
||||
input.filter-tier-box(type='checkbox')
|
||||
| Filter to Current Tier
|
||||
select.sortSpecies
|
||||
option=""
|
||||
option="Sort"
|
||||
option="Sort by Dexnumber"
|
||||
option="Invert by Dexnumber"
|
||||
option="Sort Alphabetically"
|
||||
option="Invert Alphabetically"
|
||||
option="Sort by Tier"
|
||||
option="Invert by Tier"
|
||||
select.species_list
|
||||
option
|
||||
each species in speciesList
|
||||
|
|
|
@ -454,6 +454,7 @@ h1{font-family:"PT Sans Narrow","Helvetica Neue",sans-serif;font-size:2em;font-w
|
|||
.teambuilder .selectize-input input{height:18px}
|
||||
.teambuilder{position:absolute;top:0;bottom:0;left:0;right:0;}
|
||||
.teambuilder select,.teambuilder input{margin-bottom:0 !important;width:100%}
|
||||
.teambuilder .filter-tier-box{width:25px}
|
||||
.teambuilder .meta-info{max-width:1368px}
|
||||
.teambuilder .meta-info .left-side,.teambuilder .meta-info .right-side{float:left;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
|
||||
.teambuilder .navigation{position:absolute;top:50px;bottom:0;background-color:rgba(223,231,232,0.5);width:160px;}
|
||||
|
|
114
public/js/app.js
114
public/js/app.js
|
@ -5538,6 +5538,9 @@
|
|||
this.setGeneration = __bind(this.setGeneration, this);
|
||||
this.sortSpecieslist = __bind(this.sortSpecieslist, this);
|
||||
this.changeSort = __bind(this.changeSort, this);
|
||||
this.arrToObject = __bind(this.arrToObject, this);
|
||||
this.objectToArr = __bind(this.objectToArr, this);
|
||||
this.filterTier = __bind(this.filterTier, this);
|
||||
this.setFormat = __bind(this.setFormat, this);
|
||||
this.initialize = __bind(this.initialize, this);
|
||||
return PokemonEditView.__super__.constructor.apply(this, arguments);
|
||||
|
@ -5551,8 +5554,11 @@
|
|||
|
||||
PokemonEditView.prototype.movesTemplate = JST['teambuilder/moves'];
|
||||
|
||||
PokemonEditView.prototype.tierFilterBool = true;
|
||||
|
||||
PokemonEditView.prototype.events = {
|
||||
'change .sortSpecies': 'changeSort',
|
||||
'change .filter-tier': 'filterTier',
|
||||
'change .species_list': 'changeSpecies',
|
||||
'change .selected_nickname': 'changeNickname',
|
||||
'click .selected_shininess': 'changeShiny',
|
||||
|
@ -5591,11 +5597,72 @@
|
|||
return this.setGeneration(format.generation);
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.filterTier = function(e) {
|
||||
var FormeData, SpeciesData, arr, data, obj, species, thistier, _i, _len, _ref;
|
||||
thistier = this.pokemon.getTeam().getTier().tierRank;
|
||||
_ref = this.generation, SpeciesData = _ref.SpeciesData, FormeData = _ref.FormeData;
|
||||
if (e.target.checked) {
|
||||
arr = this.objectToArr(SpeciesData);
|
||||
console.log(thistier);
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
obj = arr[_i];
|
||||
obj.tier = window.PokeBattle.Tier.Tiers[FormeData[obj.pokename]["default"].tier[0]].tierRank;
|
||||
}
|
||||
console.log(arr);
|
||||
arr = _.filter(arr, function(thing) {
|
||||
return thing.tier === thistier;
|
||||
});
|
||||
obj = this.arrToObject(arr);
|
||||
this.speciesList = (function() {
|
||||
var _results;
|
||||
_results = [];
|
||||
for (species in obj) {
|
||||
data = obj[species];
|
||||
_results.push(species);
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
return this.render();
|
||||
} else {
|
||||
this.speciesList = (function() {
|
||||
var _results;
|
||||
_results = [];
|
||||
for (species in SpeciesData) {
|
||||
data = SpeciesData[species];
|
||||
_results.push(species);
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
return this.render();
|
||||
}
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.objectToArr = function(data) {
|
||||
var arr, key, val;
|
||||
arr = [];
|
||||
for (key in data) {
|
||||
val = data[key];
|
||||
val.pokename = key;
|
||||
arr.push(val);
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.arrToObject = function(arr) {
|
||||
var obj, thing, _i, _len;
|
||||
obj = {};
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
thing = arr[_i];
|
||||
obj[thing.pokename] = thing;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.changeSort = function(e) {
|
||||
var sort;
|
||||
sort = $(e.currentTarget).val();
|
||||
if (sort === "Default Sort") {
|
||||
return this.sortSpecieslist("Default");
|
||||
if (sort === "Sort") {
|
||||
return this.sortSpecieslist("tier", false);
|
||||
} else if (sort === "Sort by Dexnumber") {
|
||||
return this.sortSpecieslist("id", false);
|
||||
} else if (sort === "Invert by Dexnumber") {
|
||||
|
@ -5604,6 +5671,10 @@
|
|||
return this.sortSpecieslist("pokename", false);
|
||||
} else if (sort === "Invert Alphabetically") {
|
||||
return this.sortSpecieslist("pokename", true);
|
||||
} else if (sort === "Sort by Tier") {
|
||||
return this.sortSpecieslist("tier", false);
|
||||
} else if (sort === "Invert by Tier") {
|
||||
return this.sortSpecieslist("tier", true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -5628,23 +5699,23 @@
|
|||
};
|
||||
|
||||
PokemonEditView.prototype.sortObject = function(data, option, reverse) {
|
||||
var arr, finished, key, newobj, thing, val, _i, _len;
|
||||
arr = [];
|
||||
for (key in data) {
|
||||
val = data[key];
|
||||
val.pokename = key;
|
||||
arr.push(val);
|
||||
var FormeData, arr, finished, obj, _i, _len;
|
||||
arr = this.objectToArr(data);
|
||||
if (option !== 'tier') {
|
||||
arr = _.sortBy(arr, option);
|
||||
} else {
|
||||
FormeData = this.generation.FormeData;
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
obj = arr[_i];
|
||||
obj.tier = window.PokeBattle.Tier.Tiers[FormeData[obj.pokename]["default"].tier[0]].tierRank;
|
||||
arr = _.sortBy(arr, 'tier');
|
||||
}
|
||||
}
|
||||
arr = _.sortBy(arr, option);
|
||||
if (reverse === true) {
|
||||
arr.reverse();
|
||||
}
|
||||
newobj = {};
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
thing = arr[_i];
|
||||
newobj[thing.pokename] = thing;
|
||||
}
|
||||
return finished = newobj;
|
||||
obj = this.arrToObject(arr);
|
||||
return finished = obj;
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.setGeneration = function(generation) {
|
||||
|
@ -6026,6 +6097,7 @@
|
|||
};
|
||||
|
||||
PokemonEditView.prototype.render = function() {
|
||||
var filtertierbox;
|
||||
this.$el.html(this.editTemplate({
|
||||
window: window,
|
||||
speciesList: this.speciesList,
|
||||
|
@ -6053,6 +6125,18 @@
|
|||
}
|
||||
});
|
||||
attachSelectize(this.$el.find(".selected_item"));
|
||||
filtertierbox = this.$el.find(".filter-tier-box")[0];
|
||||
console.log(filtertierbox);
|
||||
console.log(this.tierFilterBool);
|
||||
if (this.tierFilterBool === false) {
|
||||
console.log("false");
|
||||
filtertierbox.checked = true;
|
||||
this.tierFilterBool = true;
|
||||
} else if (this.tierFilterBool === true) {
|
||||
console.log("true");
|
||||
filtertierbox.checked = false;
|
||||
this.tierFilterBool = false;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
|
|
@ -865,7 +865,7 @@ var locals_ = (locals || {}),speciesList = locals_.speciesList,itemList = locals
|
|||
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {};
|
||||
buf.push("<tr><td class=\"stat-label\"><strong>" + (jade.escape((jade.interp = statName) == null ? '' : jade.interp)) + ":</strong></td><td class=\"ev-range-cell\"><input" + (jade.attrs({ 'type':("range"), 'min':("0"), 'max':("252"), 'step':("4"), 'data-stat':(keyName), "class": [('ev-entry')] }, {"type":true,"min":true,"max":true,"step":true,"data-stat":true})) + "/></td><td class=\"ev-cell\"><input" + (jade.attrs({ 'type':("text"), 'data-stat':(keyName), "class": [('ev-entry')] }, {"type":true,"data-stat":true})) + "/></td><td class=\"iv-cell\"><input" + (jade.attrs({ 'type':("text"), 'data-stat':(keyName), "class": [('iv-entry')] }, {"type":true,"data-stat":true})) + "/></td><td" + (jade.attrs({ 'data-stat':(keyName), "class": [('base-stat')] }, {"data-stat":true})) + "></td><td" + (jade.attrs({ 'data-stat':(keyName), "class": [('stat-total')] }, {"data-stat":true})) + "></td></tr>");
|
||||
};
|
||||
buf.push("<div class=\"meta-info clearfix\"><div class=\"left-side\"><div class=\"species\"><select class=\"sortSpecies\"><option>" + (jade.escape(null == (jade.interp = "") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort by Dexnumber") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert by Dexnumber") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort Alphabetically") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert Alphabetically") ? "" : jade.interp)) + "</option></select><select class=\"species_list\"><option></option>");
|
||||
buf.push("<div class=\"meta-info clearfix\"><div class=\"left-side\"><div class=\"species\"><label class=\"filter-tier\"><input type=\"checkbox\" class=\"filter-tier-box\"/>Filter to Current Tier</label><select class=\"sortSpecies\"><option>" + (jade.escape(null == (jade.interp = "Sort") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort by Dexnumber") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert by Dexnumber") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort Alphabetically") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert Alphabetically") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort by Tier") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert by Tier") ? "" : jade.interp)) + "</option></select><select class=\"species_list\"><option></option>");
|
||||
// iterate speciesList
|
||||
;(function(){
|
||||
var $$obj = speciesList;
|
||||
|
|
Loading…
Reference in New Issue