cleaned up ugly url code
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
get '/category' do
|
get '/category' do
|
||||||
Category.order(:name).all.to_json(:include => [:sub_categories, :filter_criterias =>{:include => :filter_criteria_values} ])
|
Category.order(:name).all.to_json(:include => [:section, :sub_categories, :filter_criterias =>{:include => :filter_criteria_values} ])
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/category/:id' do
|
get '/category/:id' do
|
||||||
id = params[:id].to_i
|
id = params[:id].to_i
|
||||||
Category.find(id).to_json(:include => [:sub_categories, :filter_criterias =>{:include => :filter_criteria_values} ])
|
Category.find(id).to_json(:include => [:section, :sub_categories, :filter_criterias =>{:include => :filter_criteria_values}])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,17 +22,17 @@ var NavigationActions = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
goToCategory: function(category,section, query) {
|
goToCategory: function(category,section, query) {
|
||||||
console.log("Going to item details");
|
var url ='/sekcija/' + section.get('name') +'/kategorija/'+ category.get('id') + '/' + category.get('name');
|
||||||
var url ='/sekcija/' + section.get('name') +'/kategorija/'+ category.id + '/' + category.name;
|
|
||||||
|
|
||||||
var q = '?';
|
q = '';
|
||||||
if(query) {
|
if(query) {
|
||||||
for(var key in query) {
|
q = '?';
|
||||||
if (query.hasOwnProperty(key)) {
|
for(var key in query) {
|
||||||
q += "&" + key + '=' + query[key];
|
if (query.hasOwnProperty(key)) {
|
||||||
|
q += "&" + key + '=' + query[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
AppDispatcher.handleAction({
|
AppDispatcher.handleAction({
|
||||||
actionType: NavigationConstants.CHANGE_URL,
|
actionType: NavigationConstants.CHANGE_URL,
|
||||||
url: (url + q)
|
url: (url + q)
|
||||||
|
|||||||
@@ -23,13 +23,12 @@ var ByCategory = React.createClass({
|
|||||||
},
|
},
|
||||||
onFCClick: function(fc, fcv) {
|
onFCClick: function(fc, fcv) {
|
||||||
|
|
||||||
alert(fc.field_name);
|
|
||||||
var q = {};
|
var q = {};
|
||||||
q[fc.field_name] = fcv.filter_value;
|
q[fc.field_name] = fcv.filter_value;
|
||||||
// TODO: fix this, clean this up
|
// TODO: fix this, clean this up
|
||||||
var s = new Section({name: 'meho'});
|
var section = new Section(this.state.category.get('section'));
|
||||||
var c = this.state.category;
|
var category = this.state.category;
|
||||||
NavigationActions.goToCategory({id: c.get('id'), name: c.get('name')}, s, q)
|
NavigationActions.goToCategory(category, section, q)
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ var React = require('react'),
|
|||||||
SectionStore = require('../../stores/sectionStore'),
|
SectionStore = require('../../stores/sectionStore'),
|
||||||
SectionActions = require('../../actions/sectionActions.js'),
|
SectionActions = require('../../actions/sectionActions.js'),
|
||||||
NavigationActions = require('../../actions/navigationActions'),
|
NavigationActions = require('../../actions/navigationActions'),
|
||||||
Section = require('../../models/section');
|
Section = require('../../models/section'),
|
||||||
|
Category = require('../../models/category');
|
||||||
|
|
||||||
var BySection = React.createClass({
|
var BySection = React.createClass({
|
||||||
mixins: [Router.State],
|
mixins: [Router.State],
|
||||||
@@ -57,7 +58,7 @@ var BySection = React.createClass({
|
|||||||
</div> )
|
</div> )
|
||||||
},
|
},
|
||||||
onCategoryClick: function(category, section) {
|
onCategoryClick: function(category, section) {
|
||||||
NavigationActions.goToCategory(category, section);
|
NavigationActions.goToCategory(new Category(category), section);
|
||||||
|
|
||||||
},
|
},
|
||||||
componentWillReceiveProps: function(nextProps) {
|
componentWillReceiveProps: function(nextProps) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
var React = require('react'),
|
var React = require('react'),
|
||||||
SectionCollection = require('../../models/sectionCollection'),
|
SectionCollection = require('../../models/sectionCollection'),
|
||||||
Section = require('../../models/section'),
|
Section = require('../../models/section'),
|
||||||
|
Category = require('../../models/category'),
|
||||||
Backbone = require('backbone'),
|
Backbone = require('backbone'),
|
||||||
NavigationStore = require('../../stores/navigationStore'),
|
NavigationStore = require('../../stores/navigationStore'),
|
||||||
SectionStore = require('../../stores/sectionStore'),
|
SectionStore = require('../../stores/sectionStore'),
|
||||||
@@ -37,7 +38,7 @@ var SectionsListComponent = React.createClass({
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
onCategoryClick: function(category, section) {
|
onCategoryClick: function(category, section) {
|
||||||
NavigationActions.goToCategory(category, section);
|
NavigationActions.goToCategory(new Category(category), section);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
onSubcategoryClick: function(subcategory) {
|
onSubcategoryClick: function(subcategory) {
|
||||||
|
|||||||
Reference in New Issue
Block a user