diff --git a/index.js b/index.js index 061167f..b26e479 100644 --- a/index.js +++ b/index.js @@ -34,6 +34,7 @@ module.exports.view = { boundary_rect: require('./view/boundary_rect'), boundary_country: require('./view/boundary_country'), sort_distance: require('./view/sort_distance'), + sort_popularity: require('./view/sort_popularity'), sources: require('./view/sources'), layers: require('./view/layers'), boundary_gid: require('./view/boundary_gid') diff --git a/view/sort_distance.js b/view/sort_distance.js index 1f3d049..e1c6f2a 100644 --- a/view/sort_distance.js +++ b/view/sort_distance.js @@ -2,7 +2,8 @@ module.exports = function( vs ){ // validate required params - if( !vs.isset('focus:point:lat') || + if( vs.var('sort:field').get() !== 'distance' || + !vs.isset('focus:point:lat') || !vs.isset('focus:point:lon') || !vs.isset('sort:distance:order') || !vs.isset('sort:distance:distance_type') || diff --git a/view/sort_popularity.js b/view/sort_popularity.js new file mode 100644 index 0000000..458c796 --- /dev/null +++ b/view/sort_popularity.js @@ -0,0 +1,15 @@ + +module.exports = function( vs ){ + if ( !vs.isset('sort:field') || + vs.var('sort:field').get() !== 'popularity' ) { + return null; + } + // base view + var view = { + popularity: { + order: 'desc', + } + }; + + return view; +};