assign biology assets to restricts and item assets to occupies
This commit is contained in:
parent
fc76e7cfe3
commit
3c36cd6aef
6 changed files with 43 additions and 46 deletions
|
@ -1096,7 +1096,7 @@ View.Search = function (wardrobe) {
|
|||
loadPage($(this).data('page'));
|
||||
});
|
||||
|
||||
this.initialize = $.proxy(wardrobe.item_zone_sets, 'load');
|
||||
this.initialize = $.proxy(wardrobe.zones, 'load');
|
||||
|
||||
wardrobe.search.setPerPage(PAGINATION.PER_PAGE);
|
||||
|
||||
|
@ -1247,17 +1247,38 @@ View.Search = function (wardrobe) {
|
|||
fit();
|
||||
});
|
||||
|
||||
wardrobe.item_zone_sets.bind('update', function (item_zone_sets) {
|
||||
var selects = $('#advanced-search-occupies, #advanced-search-restricts');
|
||||
var sorted_item_zone_sets = item_zone_sets.slice(0);
|
||||
item_zone_sets.sort(function(a, b) {
|
||||
if (a.label < b.label) return -1;
|
||||
else if (a.label > b.label) return 1;
|
||||
else return 0;
|
||||
wardrobe.zones.bind('update', function (zones) {
|
||||
var occupies = $('#advanced-search-occupies');
|
||||
var restricts = $('#advanced-search-restricts');
|
||||
|
||||
// Get sorted unique zone sets by their labels
|
||||
var labelMap = {};
|
||||
zones.forEach(function(zone) {
|
||||
labelMap[zone.plain_label] = {label: zone.label, typeId: zone.type_id};
|
||||
});
|
||||
item_zone_sets.forEach(function(set) {
|
||||
|
||||
var sets = {items: [], biology: []};
|
||||
Object.keys(labelMap).forEach(function(plainLabel) {
|
||||
var relevantSets = labelMap[plainLabel].typeId > 1 ?
|
||||
sets.items : sets.biology;
|
||||
relevantSets.push({plainLabel: plainLabel,
|
||||
label: labelMap[plainLabel].label});
|
||||
});
|
||||
Object.keys(sets).forEach(function(key) {
|
||||
sets[key].sort(function(a, b) {
|
||||
if (a.label < b.label) return -1;
|
||||
else if (a.label > b.label) return 1;
|
||||
else return 0;
|
||||
});
|
||||
});
|
||||
|
||||
sets.items.forEach(function(set) {
|
||||
$('<option/>', {value: set.plainLabel, text: set.label}).
|
||||
appendTo(selects);
|
||||
appendTo(occupies);
|
||||
});
|
||||
sets.biology.forEach(function(set) {
|
||||
$('<option/>', {value: set.plainLabel, text: set.label}).
|
||||
appendTo(restricts);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -251,19 +251,6 @@ function Wardrobe() {
|
|||
|
||||
Item.cache = {};
|
||||
|
||||
var ItemZoneSet = {};
|
||||
|
||||
ItemZoneSet.loadAll = function (success) {
|
||||
$.getJSON('/item_zone_sets.json', function (data) {
|
||||
Object.keys(data).forEach(function(key) {
|
||||
ItemZoneSet.all.push({plainLabel: key, label: data[key]});
|
||||
});
|
||||
success(ItemZoneSet.all);
|
||||
});
|
||||
}
|
||||
|
||||
ItemZoneSet.all = [];
|
||||
|
||||
function Outfit(data) {
|
||||
var outfit = this, previous_pet_type, worn_item_ids = [],
|
||||
closet_item_ids = [], new_record = true;
|
||||
|
@ -1300,15 +1287,13 @@ function Wardrobe() {
|
|||
}
|
||||
}
|
||||
|
||||
Controller.all.ItemZoneSets = function ItemZoneSetsController() {
|
||||
var item_zone_sets = this;
|
||||
|
||||
function onLoad(sets) {
|
||||
item_zone_sets.events.trigger('update', sets);
|
||||
}
|
||||
Controller.all.Zones = function ZonesController() {
|
||||
var zones = this;
|
||||
|
||||
this.load = function () {
|
||||
ItemZoneSet.loadAll(onLoad);
|
||||
$.getJSON('/zones.json', function(data) {
|
||||
zones.events.trigger('update', data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
class ItemZoneSetsController < ApplicationController
|
||||
def index
|
||||
render :json => Zone.for_items.sets
|
||||
end
|
||||
end
|
5
app/controllers/zones_controller.rb
Normal file
5
app/controllers/zones_controller.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class ZonesController < ApplicationController
|
||||
def index
|
||||
render json: Zone.all
|
||||
end
|
||||
end
|
|
@ -14,19 +14,11 @@ class Zone < ActiveRecord::Base
|
|||
includes(:translations).where(t[:plain_label].eq(Zone.plainify_label(label)))
|
||||
}
|
||||
scope :for_items, lambda { where(arel_table[:type_id].gt(1)) }
|
||||
|
||||
|
||||
def uncertain_label
|
||||
@sometimes ? "#{label} sometimes" : label
|
||||
end
|
||||
|
||||
def self.sets
|
||||
{}.tap do |sets|
|
||||
select([:id]).includes(:translations).each do |zone|
|
||||
sets[zone.plain_label] = zone.label
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.plainify_label(label)
|
||||
label.delete('\- /').parameterize
|
||||
end
|
||||
|
|
|
@ -11,8 +11,6 @@ OpenneoImpressItems::Application.routes.draw do
|
|||
|
||||
devise_for :users
|
||||
|
||||
match '/item_zone_sets.json' => 'ItemZoneSets#index'
|
||||
|
||||
# DEPRECATED
|
||||
match '/bodies/:body_id/swf_assets.json' => 'swf_assets#index', :as => :body_swf_assets
|
||||
|
||||
|
@ -35,6 +33,7 @@ OpenneoImpressItems::Application.routes.draw do
|
|||
resources :outfits, :only => [:show, :create, :update, :destroy]
|
||||
resources :pet_attributes, :only => [:index]
|
||||
resources :swf_assets, :only => [:index, :show]
|
||||
resources :zones, only: [:index]
|
||||
|
||||
scope 'import' do
|
||||
resources :closet_pages, :only => [:new, :create],
|
||||
|
|
Loading…
Reference in a new issue